git: 331883a2f2e9 - main - nfscl: Check for a forced dismount in nfscl_getref()

From: Rick Macklem <rmacklem_at_FreeBSD.org>
Date: Wed, 03 Nov 2021 00:31:26 UTC
The branch main has been updated by rmacklem:

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

commit 331883a2f2e9ae5567085e4cd3a7ae3db2a2b022
Author:     Rick Macklem <rmacklem@FreeBSD.org>
AuthorDate: 2021-11-03 00:28:13 +0000
Commit:     Rick Macklem <rmacklem@FreeBSD.org>
CommitDate: 2021-11-03 00:28:13 +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.
    
    MFC after:      2 weeks
---
 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 523cc59039af..22c0da1bcef8 100644
--- a/sys/fs/nfsclient/nfs_clstate.c
+++ b/sys/fs/nfsclient/nfs_clstate.c
@@ -4907,6 +4907,7 @@ int
 nfscl_getref(struct nfsmount *nmp)
 {
 	struct nfsclclient *clp;
+	int ret;
 
 	NFSLOCKCLSTATE();
 	clp = nfscl_findcl(nmp);
@@ -4914,9 +4915,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);
 }
 
 /*