git: 6fc80c13284f - stable/13 - nfscl: Check for a forced dismount in nfscl_getref()

From: Rick Macklem <rmacklem_at_FreeBSD.org>
Date: Wed, 17 Nov 2021 01:21:59 UTC
The branch stable/13 has been updated by rmacklem:

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

commit 6fc80c13284fd3c7e53a273a7ef001e66fe7f7be
Author:     Rick Macklem <rmacklem@FreeBSD.org>
AuthorDate: 2021-11-03 00:28:13 +0000
Commit:     Rick Macklem <rmacklem@FreeBSD.org>
CommitDate: 2021-11-17 01:18:34 +0000

    nfscl: Check for a forced dismount in nfscl_getref()
    
    The nfscl_getref() function is called within nfscl_doiods() when
    the NFSv4.1/4.2 pNFS client is doing I/O on a DS.  As such,
    nfscl_getref() needs to check for a forced dismount.
    This patch adds that check.
    
    Found during a recent IETF NFSv4 working group testing event.
    
    (cherry picked from commit 331883a2f2e9ae5567085e4cd3a7ae3db2a2b022)
---
 sys/fs/nfsclient/nfs_clstate.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/sys/fs/nfsclient/nfs_clstate.c b/sys/fs/nfsclient/nfs_clstate.c
index f1d661e7c90a..51f901bf14fc 100644
--- a/sys/fs/nfsclient/nfs_clstate.c
+++ b/sys/fs/nfsclient/nfs_clstate.c
@@ -4909,6 +4909,7 @@ int
 nfscl_getref(struct nfsmount *nmp)
 {
 	struct nfsclclient *clp;
+	int ret;
 
 	NFSLOCKCLSTATE();
 	clp = nfscl_findcl(nmp);
@@ -4916,9 +4917,12 @@ nfscl_getref(struct nfsmount *nmp)
 		NFSUNLOCKCLSTATE();
 		return (0);
 	}
-	nfsv4_getref(&clp->nfsc_lock, NULL, NFSCLSTATEMUTEXPTR, NULL);
+	nfsv4_getref(&clp->nfsc_lock, NULL, NFSCLSTATEMUTEXPTR, nmp->nm_mountp);
+	ret = 1;
+	if (NFSCL_FORCEDISM(nmp->nm_mountp))
+		ret = 0;
 	NFSUNLOCKCLSTATE();
-	return (1);
+	return (ret);
 }
 
 /*