Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 17 Feb 2025 00:03:04 GMT
From:      Rick Macklem <rmacklem@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: f5aff1871d32 - main - nfscl: Move delegation high water variables into clientID
Message-ID:  <202502170003.51H034lY096841@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by rmacklem:

URL: https://cgit.FreeBSD.org/src/commit/?id=f5aff1871d3273b3cd3621ea5d3e37cdd807e66f

commit f5aff1871d3273b3cd3621ea5d3e37cdd807e66f
Author:     Rick Macklem <rmacklem@FreeBSD.org>
AuthorDate: 2025-02-17 00:01:54 +0000
Commit:     Rick Macklem <rmacklem@FreeBSD.org>
CommitDate: 2025-02-17 00:01:54 +0000

    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
---
 sys/fs/nfs/nfsclstate.h        |  2 ++
 sys/fs/nfsclient/nfs_clstate.c | 15 ++++++++-------
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/sys/fs/nfs/nfsclstate.h b/sys/fs/nfs/nfsclstate.h
index d9f5ed13b54f..84088a2a4fd2 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 f5621fd0a758..86b51a7b3343 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--;
 			}
 		    }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202502170003.51H034lY096841>