Changeset View
Changeset View
Standalone View
Standalone View
sys/fs/nfsserver/nfs_nfsdsocket.c
| 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 procnum, struct bintime *now) | |||||
| { | |||||
| if (procnum > (NFSV4OP_NOPS + NFSV4OP_FAKENOPS)) { | |||||
| printf("%s: procnum %d invalid\n", __func__, procnum); | |||||
| return; | |||||
| } | |||||
| mtx_lock(&nfsrvd_statmtx); | |||||
| if (newnfsstats.srvstartcnt == newnfsstats.srvdonecnt) { | |||||
| if (now != NULL) | |||||
| newnfsstats.busyfrom = *now; | |||||
| else | |||||
| binuptime(&newnfsstats.busyfrom); | |||||
| } | |||||
| newnfsstats.srvrpccnt[procnum]++; | |||||
| newnfsstats.srvstartcnt++; | |||||
| mtx_unlock(&nfsrvd_statmtx); | |||||
| } | |||||
| static void | |||||
| nfsrvd_statend(int procnum, uint64_t bytes, struct bintime *now, | |||||
| struct bintime *then) | |||||
| { | |||||
| struct bintime dt, lnow; | |||||
| if (procnum > (NFSV4OP_NOPS + NFSV4OP_FAKENOPS)) { | |||||
| printf("%s: procnum %d invalid\n", __func__, procnum); | |||||
| return; | |||||
| } | |||||
| if (now == NULL) { | |||||
| now = &lnow; | |||||
| binuptime(now); | |||||
| } | |||||
| mtx_lock(&nfsrvd_statmtx); | |||||
| newnfsstats.srvbytes[procnum] += bytes; | |||||
| newnfsstats.srvops[procnum]++; | |||||
| if (then != NULL) { | |||||
| dt = *now; | |||||
| bintime_sub(&dt, then); | |||||
| bintime_add(&newnfsstats.srvduration[procnum], &dt); | |||||
| } | |||||
| dt = *now; | |||||
| bintime_sub(&dt, &newnfsstats.busyfrom); | |||||
| bintime_add(&newnfsstats.busytime, &dt); | |||||
| newnfsstats.busyfrom = *now; | |||||
| newnfsstats.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. | |||||
| 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. | |||||
| } | } | ||||
| 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]); | |||||
| binuptime(&start_time); | |||||
| nfsrvd_statstart(nd->nd_procnum, &start_time); | |||||
| switch (op) { | switch (op) { | ||||
| case NFSV4OP_PUTFH: | case NFSV4OP_PUTFH: | ||||
| error = nfsrv_mtofh(nd, &fh); | error = nfsrv_mtofh(nd, &fh); | ||||
| if (error) | if (error) { | ||||
| nfsrvd_statend(nd->nd_procnum, /*bytes*/ 0, | |||||
| /*now*/ NULL, /*then*/ &start_time); | |||||
| goto nfsmout; | goto nfsmout; | ||||
| } | |||||
| if (!nd->nd_repstat) | if (!nd->nd_repstat) | ||||
| nfsd_fhtovp(nd, &fh, LK_SHARED, &nvp, &nes, | nfsd_fhtovp(nd, &fh, LK_SHARED, &nvp, &nes, | ||||
| NULL, 0, p); | NULL, 0, p); | ||||
| Context not available. | |||||
| } | } | ||||
| } | } | ||||
| }; | }; | ||||
| 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. | |||||
| } | } | ||||
| error = 0; | error = 0; | ||||
| } | } | ||||
| nfsrvd_statend(nd->nd_procnum, /*bytes*/ 0, | |||||
| /*now*/ NULL, /*then*/ &start_time); | |||||
| retops++; | retops++; | ||||
| if (nd->nd_repstat) { | if (nd->nd_repstat) { | ||||
| *repp = nfsd_errmap(nd); | *repp = nfsd_errmap(nd); | ||||
| Context not available. | |||||