Changeset View
Changeset View
Standalone View
Standalone View
sys/fs/nfsserver/nfs_nfsdsocket.c
| Context not available. | |||||
| #ifndef APPLEKEXT | #ifndef APPLEKEXT | ||||
| #include <fs/nfs/nfsport.h> | #include <fs/nfs/nfsport.h> | ||||
| extern struct nfsstats newnfsstats; | extern struct nfsstatsv1 nfsstatsv1; | ||||
| extern struct nfsrvfh nfs_pubfh, nfs_rootfh; | extern struct nfsrvfh nfs_pubfh, nfs_rootfh; | ||||
| extern int nfs_pubfhset, nfs_rootfhset; | extern int nfs_pubfhset, nfs_rootfhset; | ||||
| extern struct nfsv4lock nfsv4rootfs_lock; | extern struct nfsv4lock nfsv4rootfs_lock; | ||||
| Context not available. | |||||
| NFSV4OP_COMMIT, | NFSV4OP_COMMIT, | ||||
| }; | }; | ||||
| static struct mtx nfsrvd_statmtx; | |||||
| MTX_SYSINIT(nfsst, &nfsrvd_statmtx, "NFSstat", MTX_DEF); | |||||
| static void | |||||
| nfsrvd_statstart(int op, struct bintime *now) | |||||
| { | |||||
| if (op > (NFSV41_NOPS + NFSV4OP_FAKENOPS)) { | |||||
| printf("%s: op %d invalid\n", __func__, op); | |||||
| return; | |||||
| } | |||||
| mtx_lock(&nfsrvd_statmtx); | |||||
| if (nfsstatsv1.srvstartcnt == nfsstatsv1.srvdonecnt) { | |||||
| if (now != NULL) | |||||
| nfsstatsv1.busyfrom = *now; | |||||
| else | |||||
| binuptime(&nfsstatsv1.busyfrom); | |||||
| } | |||||
| nfsstatsv1.srvrpccnt[op]++; | |||||
| nfsstatsv1.srvstartcnt++; | |||||
| mtx_unlock(&nfsrvd_statmtx); | |||||
| } | |||||
| static void | |||||
| nfsrvd_statend(int op, uint64_t bytes, struct bintime *now, | |||||
| struct bintime *then) | |||||
| { | |||||
| struct bintime dt, lnow; | |||||
| if (op > (NFSV41_NOPS + NFSV4OP_FAKENOPS)) { | |||||
| printf("%s: op %d invalid\n", __func__, op); | |||||
| return; | |||||
| } | |||||
| if (now == NULL) { | |||||
| now = &lnow; | |||||
| binuptime(now); | |||||
| } | |||||
| mtx_lock(&nfsrvd_statmtx); | |||||
| nfsstatsv1.srvbytes[op] += bytes; | |||||
| nfsstatsv1.srvops[op]++; | |||||
| if (then != NULL) { | |||||
| dt = *now; | |||||
| bintime_sub(&dt, then); | |||||
| bintime_add(&nfsstatsv1.srvduration[op], &dt); | |||||
| } | |||||
| dt = *now; | |||||
| bintime_sub(&dt, &nfsstatsv1.busyfrom); | |||||
| bintime_add(&nfsstatsv1.busytime, &dt); | |||||
| nfsstatsv1.busyfrom = *now; | |||||
| nfsstatsv1.srvdonecnt++; | |||||
| mtx_unlock(&nfsrvd_statmtx); | |||||
| } | |||||
| /* | /* | ||||
| * Do an RPC. Basically, get the file handles translated to vnode pointers | * Do an RPC. Basically, get the file handles translated to vnode pointers | ||||
| * and then call the appropriate server routine. The server routines are | * and then call the appropriate server routine. The server routines are | ||||
| Context not available. | |||||
| */ | */ | ||||
| if (nd->nd_repstat && (nd->nd_flag & ND_NFSV2)) { | if (nd->nd_repstat && (nd->nd_flag & ND_NFSV2)) { | ||||
| *nd->nd_errp = nfsd_errmap(nd); | *nd->nd_errp = nfsd_errmap(nd); | ||||
| NFSINCRGLOBAL(newnfsstats.srvrpccnt[nfsv3to4op[nd->nd_procnum]]); | nfsrvd_statstart(nfsv3to4op[nd->nd_procnum], /*now*/ NULL); | ||||
| nfsrvd_statend(nfsv3to4op[nd->nd_procnum], /*bytes*/ 0, | |||||
| /*now*/ NULL, /*then*/ NULL); | |||||
| if (mp != NULL && nfs_writerpc[nd->nd_procnum] != 0) | if (mp != NULL && nfs_writerpc[nd->nd_procnum] != 0) | ||||
| vn_finished_write(mp); | vn_finished_write(mp); | ||||
| goto out; | goto out; | ||||
| Context not available. | |||||
| if (nd->nd_flag & ND_NFSV4) { | if (nd->nd_flag & ND_NFSV4) { | ||||
| nfsrvd_compound(nd, isdgram, tag, taglen, minorvers, p); | nfsrvd_compound(nd, isdgram, tag, taglen, minorvers, p); | ||||
| } else { | } else { | ||||
| struct bintime start_time; | |||||
| binuptime(&start_time); | |||||
| nfsrvd_statstart(nfsv3to4op[nd->nd_procnum], &start_time); | |||||
| if (nfs_retfh[nd->nd_procnum] == 1) { | if (nfs_retfh[nd->nd_procnum] == 1) { | ||||
| if (vp) | if (vp) | ||||
| NFSVOPUNLOCK(vp, 0); | NFSVOPUNLOCK(vp, 0); | ||||
| Context not available. | |||||
| } | } | ||||
| if (mp != NULL && nfs_writerpc[nd->nd_procnum] != 0) | if (mp != NULL && nfs_writerpc[nd->nd_procnum] != 0) | ||||
| vn_finished_write(mp); | vn_finished_write(mp); | ||||
| NFSINCRGLOBAL(newnfsstats.srvrpccnt[nfsv3to4op[nd->nd_procnum]]); | |||||
| nfsrvd_statend(nfsv3to4op[nd->nd_procnum], /*bytes*/ 0, | |||||
| /*now*/ NULL, /*then*/ &start_time); | |||||
| } | } | ||||
| if (error) { | if (error) { | ||||
| if (error != EBADRPC) | if (error != EBADRPC) | ||||
| Context not available. | |||||
| nfsrvd_compound(struct nfsrv_descript *nd, int isdgram, u_char *tag, | nfsrvd_compound(struct nfsrv_descript *nd, int isdgram, u_char *tag, | ||||
| int taglen, u_int32_t minorvers, NFSPROC_T *p) | int taglen, u_int32_t minorvers, NFSPROC_T *p) | ||||
| { | { | ||||
| int i, lktype, op, op0 = 0; | int i, lktype, op, op0 = 0, statsinprog = 0; | ||||
| u_int32_t *tl; | u_int32_t *tl; | ||||
| struct nfsclient *clp, *nclp; | struct nfsclient *clp, *nclp; | ||||
| int numops, error = 0, igotlock; | int numops, error = 0, igotlock; | ||||
| Context not available. | |||||
| struct nfsexstuff nes, vpnes, savevpnes; | struct nfsexstuff nes, vpnes, savevpnes; | ||||
| fsid_t cur_fsid, save_fsid; | fsid_t cur_fsid, save_fsid; | ||||
| static u_int64_t compref = 0; | static u_int64_t compref = 0; | ||||
| struct bintime start_time; | |||||
| NFSVNO_EXINIT(&vpnes); | NFSVNO_EXINIT(&vpnes); | ||||
| NFSVNO_EXINIT(&savevpnes); | NFSVNO_EXINIT(&savevpnes); | ||||
| Context not available. | |||||
| *repp = *tl; | *repp = *tl; | ||||
| op = fxdr_unsigned(int, *tl); | op = fxdr_unsigned(int, *tl); | ||||
| NFSD_DEBUG(4, "op=%d\n", op); | NFSD_DEBUG(4, "op=%d\n", op); | ||||
| binuptime(&start_time); | |||||
| nfsrvd_statstart(op, &start_time); | |||||
| statsinprog = 1; | |||||
| if (op < NFSV4OP_ACCESS || | if (op < NFSV4OP_ACCESS || | ||||
| (op >= NFSV4OP_NOPS && (nd->nd_flag & ND_NFSV41) == 0) || | (op >= NFSV4OP_NOPS && (nd->nd_flag & ND_NFSV41) == 0) || | ||||
| (op >= NFSV41_NOPS && (nd->nd_flag & ND_NFSV41) != 0)) { | (op >= NFSV41_NOPS && (nd->nd_flag & ND_NFSV41) != 0)) { | ||||
| Context not available. | |||||
| } | } | ||||
| if (nfsv4_opflag[op].savereply) | if (nfsv4_opflag[op].savereply) | ||||
| nd->nd_flag |= ND_SAVEREPLY; | nd->nd_flag |= ND_SAVEREPLY; | ||||
| NFSINCRGLOBAL(newnfsstats.srvrpccnt[nd->nd_procnum]); | |||||
| switch (op) { | switch (op) { | ||||
| case NFSV4OP_PUTFH: | case NFSV4OP_PUTFH: | ||||
| error = nfsrv_mtofh(nd, &fh); | error = nfsrv_mtofh(nd, &fh); | ||||
| Context not available. | |||||
| } | } | ||||
| error = 0; | error = 0; | ||||
| } | } | ||||
| if (statsinprog != 0) { | |||||
| nfsrvd_statend(op, /*bytes*/ 0, /*now*/ NULL, | |||||
| /*then*/ &start_time); | |||||
| statsinprog = 0; | |||||
| } | |||||
| retops++; | retops++; | ||||
| if (nd->nd_repstat) { | if (nd->nd_repstat) { | ||||
| *repp = nfsd_errmap(nd); | *repp = nfsd_errmap(nd); | ||||
| Context not available. | |||||
| } | } | ||||
| } | } | ||||
| nfsmout: | nfsmout: | ||||
| if (statsinprog != 0) { | |||||
| nfsrvd_statend(op, /*bytes*/ 0, /*now*/ NULL, | |||||
| /*then*/ &start_time); | |||||
| statsinprog = 0; | |||||
| } | |||||
| if (error) { | if (error) { | ||||
| if (error == EBADRPC || error == NFSERR_BADXDR) | if (error == EBADRPC || error == NFSERR_BADXDR) | ||||
| nd->nd_repstat = NFSERR_BADXDR; | nd->nd_repstat = NFSERR_BADXDR; | ||||
| Context not available. | |||||