git: 724a71a58dee - stable/13 - nfscl: Use NFSMNTP_DELEGISSUED in two more functions

From: Rick Macklem <rmacklem_at_FreeBSD.org>
Date: Sun, 14 Nov 2021 03:18:08 UTC
The branch stable/13 has been updated by rmacklem:

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

commit 724a71a58deedc84eae9a0052eac75d65e4d03ed
Author:     Rick Macklem <rmacklem@FreeBSD.org>
AuthorDate: 2021-10-30 03:35:02 +0000
Commit:     Rick Macklem <rmacklem@FreeBSD.org>
CommitDate: 2021-11-14 03:14:39 +0000

    nfscl: Use NFSMNTP_DELEGISSUED in two more functions
    
    Commit 5e5ca4c8fc53 added a NFSMNTP_DELEGISSUED flag to indicate when
    a delegation has been issued to the mount.  For the common case
    where an NFSv4 server is not issuing delegations, this flag
    can be checked to avoid acquisition of the NFSCLSTATEMUTEX.
    
    This patch adds checks for NFSMNTP_DELEGISSUED being set
    to two more functions.
    
    This change appears to be performance neutral for a small number
    of opens, but should reduce lock contention for a large number of opens
    for the common case where server is not issuing delegations.
    
    (cherry picked from commit dc6dd769de63c4eceb8899205a5d780d9f278fd2)
---
 sys/fs/nfsclient/nfs_clstate.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/sys/fs/nfsclient/nfs_clstate.c b/sys/fs/nfsclient/nfs_clstate.c
index ced5bfeb2880..f1d661e7c90a 100644
--- a/sys/fs/nfsclient/nfs_clstate.c
+++ b/sys/fs/nfsclient/nfs_clstate.c
@@ -4590,6 +4590,12 @@ nfscl_mustflush(vnode_t vp)
 	nmp = VFSTONFS(vp->v_mount);
 	if (!NFSHASNFSV4(nmp))
 		return (1);
+	NFSLOCKMNT(nmp);
+	if ((nmp->nm_privflag & NFSMNTP_DELEGISSUED) == 0) {
+		NFSUNLOCKMNT(nmp);
+		return (1);
+	}
+	NFSUNLOCKMNT(nmp);
 	NFSLOCKCLSTATE();
 	clp = nfscl_findcl(nmp);
 	if (clp == NULL) {
@@ -4773,6 +4779,12 @@ nfscl_renamedeleg(vnode_t fvp, nfsv4stateid_t *fstp, int *gotfdp, vnode_t tvp,
 	*gottdp = 0;
 	if (NFSHASPNFS(nmp))
 		return (retcnt);
+	NFSLOCKMNT(nmp);
+	if ((nmp->nm_privflag & NFSMNTP_DELEGISSUED) == 0) {
+		NFSUNLOCKMNT(nmp);
+		return (retcnt);
+	}
+	NFSUNLOCKMNT(nmp);
 	NFSLOCKCLSTATE();
 	/*
 	 * Loop around waiting for: