diff --git a/sys/fs/nfs/nfsclstate.h b/sys/fs/nfs/nfsclstate.h index d9f5ed13b54..84088a2a4fd 100644 --- a/sys/fs/nfs/nfsclstate.h +++ b/sys/fs/nfs/nfsclstate.h @@ -116,6 +116,8 @@ struct nfsclclient { struct proc *nfsc_renewthread; struct nfsmount *nfsc_nmp; time_t nfsc_expire; + int nfsc_delegcnt; + int nfsc_deleghighwater; u_int32_t nfsc_clientidrev; u_int32_t nfsc_rev; u_int32_t nfsc_renew; diff --git a/sys/fs/nfsclient/nfs_clstate.c b/sys/fs/nfsclient/nfs_clstate.c index f5621fd0a75..86b51a7b334 100644 --- a/sys/fs/nfsclient/nfs_clstate.c +++ b/sys/fs/nfsclient/nfs_clstate.c @@ -94,8 +94,6 @@ NFSCLSTATEMUTEX; int nfscl_inited = 0; struct nfsclhead nfsclhead; /* Head of clientid list */ -static int nfscl_deleghighwater = NFSCLDELEGHIGHWATER; -static int nfscl_delegcnt = 0; static int nfscl_layoutcnt = 0; static int nfscl_getopen(struct nfsclownerhead *, struct nfsclopenhash *, u_int8_t *, int, u_int8_t *, u_int8_t *, u_int32_t, @@ -462,7 +460,7 @@ nfscl_deleg(mount_t mp, struct nfsclclient *clp, u_int8_t *nfhp, nfsdl_hash); dp->nfsdl_timestamp = NFSD_MONOSEC + 120; nfsstatsv1.cldelegates++; - nfscl_delegcnt++; + clp->nfsc_delegcnt++; } else { /* * A delegation already exists. If the new one is a Write @@ -919,6 +917,8 @@ nfscl_getcl(struct mount *mp, struct ucred *cred, NFSPROC_T *p, for (i = 0; i < NFSCLLAYOUTHASHSIZE; i++) LIST_INIT(&clp->nfsc_layouthash[i]); clp->nfsc_flags = NFSCLFLAGS_INITED; + clp->nfsc_delegcnt = 0; + clp->nfsc_deleghighwater = NFSCLDELEGHIGHWATER; clp->nfsc_clientidrev = 1; clp->nfsc_cbident = nfscl_nextcbident(); nfscl_fillclid(nmp->nm_clval, uuid, clp->nfsc_id, @@ -1751,10 +1751,10 @@ nfscl_freedeleg(struct nfscldeleghead *hdp, struct nfscldeleg *dp, bool freeit) TAILQ_REMOVE(hdp, dp, nfsdl_list); LIST_REMOVE(dp, nfsdl_hash); + dp->nfsdl_clp->nfsc_delegcnt--; if (freeit) free(dp, M_NFSCLDELEG); nfsstatsv1.cldelegates--; - nfscl_delegcnt--; } /* @@ -2864,7 +2864,7 @@ tryagain: nfsdl_list); LIST_REMOVE(dp, nfsdl_hash); TAILQ_INSERT_HEAD(&dh, dp, nfsdl_list); - nfscl_delegcnt--; + clp->nfsc_delegcnt--; nfsstatsv1.cldelegates--; } NFSLOCKCLSTATE(); @@ -2894,7 +2894,8 @@ tryagain: * The tailq list is in LRU order. */ dp = TAILQ_LAST(&clp->nfsc_deleg, nfscldeleghead); - while (nfscl_delegcnt > nfscl_deleghighwater && dp != NULL) { + while (clp->nfsc_delegcnt > clp->nfsc_deleghighwater && + dp != NULL) { ndp = TAILQ_PREV(dp, nfscldeleghead, nfsdl_list); if (dp->nfsdl_rwlock.nfslock_usecnt == 0 && dp->nfsdl_rwlock.nfslock_lock == 0 && @@ -2921,7 +2922,7 @@ tryagain: TAILQ_REMOVE(&clp->nfsc_deleg, dp, nfsdl_list); LIST_REMOVE(dp, nfsdl_hash); TAILQ_INSERT_HEAD(&dh, dp, nfsdl_list); - nfscl_delegcnt--; + clp->nfsc_delegcnt--; nfsstatsv1.cldelegates--; } }