git: fe53e046cd9c - main - nfs client: switch nfs_advlock() to use exclusive vnode lock

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Wed, 27 Aug 2025 22:37:31 UTC
The branch main has been updated by kib:

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

commit fe53e046cd9ce9c95a118ac0374e94336f16a37f
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2025-08-27 16:57:06 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2025-08-27 22:36:50 +0000

    nfs client: switch nfs_advlock() to use exclusive vnode lock
    
    It eliminates the need to upgrade the lock in the function.
    More importantly, the calls to nfs_advlock_p()/nlm_advlock() sometimes
    flush buffers, which requires exclusive locking.
    
    Reported and tested by: bz
    Reviewed by:    rmacklem
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
    Differential revision:  https://reviews.freebsd.org/D52195
---
 sys/fs/nfsclient/nfs_clvnops.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/sys/fs/nfsclient/nfs_clvnops.c b/sys/fs/nfsclient/nfs_clvnops.c
index a8b06fdb261b..eee571a04821 100644
--- a/sys/fs/nfsclient/nfs_clvnops.c
+++ b/sys/fs/nfsclient/nfs_clvnops.c
@@ -3474,7 +3474,7 @@ nfs_advlock(struct vop_advlock_args *ap)
 	u_quad_t size;
 	struct nfsmount *nmp;
 
-	error = NFSVOPLOCK(vp, LK_SHARED);
+	error = NFSVOPLOCK(vp, LK_EXCLUSIVE);
 	if (error != 0)
 		return (EBADF);
 	nmp = VFSTONFS(vp->v_mount);
@@ -3511,11 +3511,6 @@ nfs_advlock(struct vop_advlock_args *ap)
 			cred = p->p_ucred;
 		else
 			cred = td->td_ucred;
-		NFSVOPLOCK(vp, LK_UPGRADE | LK_RETRY);
-		if (VN_IS_DOOMED(vp)) {
-			error = EBADF;
-			goto out;
-		}
 
 		/*
 		 * If this is unlocking a write locked region, flush and