nfscl: Move delegation high water variables into clientID

Without this patch, the variables used to maintain a high
water limit for delegations are global and apply to all
mounts.  This patch moves them into the clientID structure,
which makes them per mount.  This is needed to add support
for the CB_RECALL_ANY callback in a future commit.

The only effect of this patch is an increase in the
total number of delegations held if there are multiple NFSv4
mounts to NFSv4 servers with delegations enabled.
Since the default of NFSCLDELEGHIGHWATER is fairly small,
this should not have a significant impact.

MFC after:	2 weeks
This commit is contained in:
Rick Macklem 2025-02-16 16:01:54 -08:00
parent bcf1d8ee35
commit f5aff1871d
2 changed files with 10 additions and 7 deletions

View file

@ -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;

View file

@ -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--;
}
}