Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 12 May 2021 02:43:16 GMT
From:      Rick Macklem <rmacklem@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 8686e00fdfac - stable/12 - nfscl: add check for NULL clp and forced dismounts to nfscl_delegreturnvp()
Message-ID:  <202105120243.14C2hGmQ085679@gitrepo.freebsd.org>

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

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

commit 8686e00fdfac505cded6d8f4a4bcf8e51fc10349
Author:     Rick Macklem <rmacklem@FreeBSD.org>
AuthorDate: 2021-04-28 00:30:16 +0000
Commit:     Rick Macklem <rmacklem@FreeBSD.org>
CommitDate: 2021-05-12 02:38:42 +0000

    nfscl: add check for NULL clp and forced dismounts to nfscl_delegreturnvp()
    
    Commit aad780464fad added a function called nfscl_delegreturnvp()
    to return delegations during the NFS VOP_RECLAIM().
    The function erroneously assumed that nm_clp would
    be non-NULL. It will be NULL for NFSV4.0 mounts until
    a regular file is opened. It will also be NULL during
    vflush() in nfs_unmount() for a forced dismount.
    
    This patch adds a check for clp == NULL to fix this.
    
    Also, since it makes no sense to call nfscl_delegreturnvp()
    during a forced dismount, the patch adds a check for that
    case and does not do the call during forced dismounts.
    
    PR:     255436
    (cherry picked from commit f6fec55fe30088bbefd3efe70b62565399a7b9b8)
---
 sys/fs/nfsclient/nfs_clnode.c  | 10 +++++++++-
 sys/fs/nfsclient/nfs_clstate.c |  6 ++++--
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/sys/fs/nfsclient/nfs_clnode.c b/sys/fs/nfsclient/nfs_clnode.c
index cdebf9c56631..278d4f4900fe 100644
--- a/sys/fs/nfsclient/nfs_clnode.c
+++ b/sys/fs/nfsclient/nfs_clnode.c
@@ -286,6 +286,9 @@ ncl_reclaim(struct vop_reclaim_args *ap)
 	struct vnode *vp = ap->a_vp;
 	struct nfsnode *np = VTONFS(vp);
 	struct nfsdmap *dp, *dp2;
+	struct mount *mp;
+
+	mp = vp->v_mount;
 
 	/*
 	 * If the NLM is running, give it a chance to abort pending
@@ -317,7 +320,12 @@ ncl_reclaim(struct vop_reclaim_args *ap)
 		 * vfs_hash_remove(), since it cannot be recalled once the
 		 * nfs node is no longer available.
 		 */
-		nfscl_delegreturnvp(vp, td);
+		MNT_ILOCK(mp);
+		if ((mp->mnt_kern_flag & MNTK_UNMOUNTF) == 0) {
+			MNT_IUNLOCK(mp);
+			nfscl_delegreturnvp(vp, td);
+		} else
+			MNT_IUNLOCK(mp);
 	}
 
 	vfs_hash_remove(vp);
diff --git a/sys/fs/nfsclient/nfs_clstate.c b/sys/fs/nfsclient/nfs_clstate.c
index 5d2641e1f4b0..e705af31185b 100644
--- a/sys/fs/nfsclient/nfs_clstate.c
+++ b/sys/fs/nfsclient/nfs_clstate.c
@@ -3267,10 +3267,12 @@ nfscl_delegreturnvp(vnode_t vp, NFSPROC_T *p)
 
 	np = VTONFS(vp);
 	cred = newnfs_getcred();
+	dp = NULL;
 	NFSLOCKCLSTATE();
 	clp = VFSTONFS(vp->v_mount)->nm_clp;
-	dp = nfscl_finddeleg(clp, np->n_fhp->nfh_fh,
-	    np->n_fhp->nfh_len);
+	if (clp != NULL)
+		dp = nfscl_finddeleg(clp, np->n_fhp->nfh_fh,
+		    np->n_fhp->nfh_len);
 	if (dp != NULL) {
 		nfscl_cleandeleg(dp);
 		nfscl_freedeleg(&clp->nfsc_deleg, dp, false);



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