git: fd1c5c6cfca5 - stable/12 - nfsv4 client: fix forced dismount when sleeping on nfsv4lck

Rick Macklem rmacklem at FreeBSD.org
Fri Apr 2 00:30:08 UTC 2021


The branch stable/12 has been updated by rmacklem:

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

commit fd1c5c6cfca58a47bc087b0722360f76024a2594
Author:     Rick Macklem <rmacklem at FreeBSD.org>
AuthorDate: 2021-03-19 21:09:33 +0000
Commit:     Rick Macklem <rmacklem at FreeBSD.org>
CommitDate: 2021-04-02 00:26:44 +0000

    nfsv4 client: fix forced dismount when sleeping on nfsv4lck
    
    During a recent NFSv4 testing event a test server caused a hang
    where "umount -N" failed.  The renew thread was sleeping on "nfsv4lck"
    and the "umount" was sleeping, waiting for the renew thread to
    terminate.
    
    This is the first of two patches that is hoped to fix the renew thread
    so that it will terminate when "umount -N" is done on the mount.
    
    nfsv4_lock() checks for forced dismount, but only after it wakes up
    from msleep().  Without this patch, a wakeup() call was required.
    This patch adds a 1second timeout on the msleep(), so that it will
    wake up and see the forced dismount flag.  Normally a wakeup()
    will occur in less than 1second, but if a premature return from
    msleep() does occur, it will simply loop around and msleep() again.
    
    While here, replace the nfsmsleep() wrapper that was used for portability
    with the actual msleep() call and make the same change for nfsv4_getref().
    
    (cherry picked from commit 5f742d3879deb1f46f2d151d5ef84f49e8d6afe6)
---
 sys/fs/nfs/nfs_commonsubs.c | 10 ++++------
 sys/fs/nfs/nfs_var.h        |  4 ++--
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/sys/fs/nfs/nfs_commonsubs.c b/sys/fs/nfs/nfs_commonsubs.c
index 7c54b503b286..9c6bee466272 100644
--- a/sys/fs/nfs/nfs_commonsubs.c
+++ b/sys/fs/nfs/nfs_commonsubs.c
@@ -2224,7 +2224,7 @@ nfsmout:
  */
 int
 nfsv4_lock(struct nfsv4lock *lp, int iwantlock, int *isleptp,
-    void *mutex, struct mount *mp)
+    struct mtx *mutex, struct mount *mp)
 {
 
 	if (isleptp)
@@ -2252,8 +2252,7 @@ nfsv4_lock(struct nfsv4lock *lp, int iwantlock, int *isleptp,
 		lp->nfslock_lock |= NFSV4LOCK_WANTED;
 		if (isleptp)
 			*isleptp = 1;
-		(void) nfsmsleep(&lp->nfslock_lock, mutex,
-		    PZERO - 1, "nfsv4lck", NULL);
+		msleep(&lp->nfslock_lock, mutex, PVFS, "nfsv4lck", hz);
 		if (iwantlock && !(lp->nfslock_lock & NFSV4LOCK_LOCK) &&
 		    lp->nfslock_usecnt == 0) {
 			lp->nfslock_lock &= ~NFSV4LOCK_LOCKWANTED;
@@ -2303,7 +2302,7 @@ nfsv4_relref(struct nfsv4lock *lp)
  * return without getting a refcnt for that case.
  */
 void
-nfsv4_getref(struct nfsv4lock *lp, int *isleptp, void *mutex,
+nfsv4_getref(struct nfsv4lock *lp, int *isleptp, struct mtx *mutex,
     struct mount *mp)
 {
 
@@ -2319,8 +2318,7 @@ nfsv4_getref(struct nfsv4lock *lp, int *isleptp, void *mutex,
 		lp->nfslock_lock |= NFSV4LOCK_WANTED;
 		if (isleptp)
 			*isleptp = 1;
-		(void) nfsmsleep(&lp->nfslock_lock, mutex,
-		    PZERO - 1, "nfsv4gr", NULL);
+		msleep(&lp->nfslock_lock, mutex, PVFS, "nfsv4gr", hz);
 	}
 	if (mp != NULL && NFSCL_FORCEDISM(mp))
 		return;
diff --git a/sys/fs/nfs/nfs_var.h b/sys/fs/nfs/nfs_var.h
index 08701b68bb40..4bc1101e3b8d 100644
--- a/sys/fs/nfs/nfs_var.h
+++ b/sys/fs/nfs/nfs_var.h
@@ -325,10 +325,10 @@ int nfsv4_loadattr(struct nfsrv_descript *, vnode_t,
     struct nfsv3_pathconf *, struct statfs *, struct nfsstatfs *,
     struct nfsfsinfo *, NFSACL_T *,
     int, int *, u_int32_t *, u_int32_t *, NFSPROC_T *, struct ucred *);
-int nfsv4_lock(struct nfsv4lock *, int, int *, void *, struct mount *);
+int nfsv4_lock(struct nfsv4lock *, int, int *, struct mtx *, struct mount *);
 void nfsv4_unlock(struct nfsv4lock *, int);
 void nfsv4_relref(struct nfsv4lock *);
-void nfsv4_getref(struct nfsv4lock *, int *, void *, struct mount *);
+void nfsv4_getref(struct nfsv4lock *, int *, struct mtx *, struct mount *);
 int nfsv4_getref_nonblock(struct nfsv4lock *);
 int nfsv4_testlock(struct nfsv4lock *);
 int nfsrv_mtostr(struct nfsrv_descript *, char *, int);


More information about the dev-commits-src-all mailing list