git: 43fbd0e7a74b - main - lockf: elide vnode interlock in the common case in lf_purgelocks

From: Mateusz Guzik <mjg_at_FreeBSD.org>
Date: Wed, 14 Sep 2022 23:33:15 UTC
The branch main has been updated by mjg:

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

commit 43fbd0e7a74b75c18e9fc76f371bd85edf6bb0b4
Author:     Mateusz Guzik <mjg@FreeBSD.org>
AuthorDate: 2022-09-14 23:04:22 +0000
Commit:     Mateusz Guzik <mjg@FreeBSD.org>
CommitDate: 2022-09-14 23:04:22 +0000

    lockf: elide vnode interlock in the common case in lf_purgelocks
    
    The interlock was already taken and released when dooming, thus by
    API contract locking state cannot be legally installed.
    
    At the same time the state is almost never there to begin with.
---
 sys/kern/kern_lockf.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/sys/kern/kern_lockf.c b/sys/kern/kern_lockf.c
index 98e29b2c9292..171a0a861c6d 100644
--- a/sys/kern/kern_lockf.c
+++ b/sys/kern/kern_lockf.c
@@ -764,14 +764,13 @@ lf_purgelocks(struct vnode *vp, struct lockf **statep)
 	 * sleeping waiting for locks on this vnode and then free all
 	 * the remaining locks.
 	 */
-	VI_LOCK(vp);
 	KASSERT(VN_IS_DOOMED(vp),
 	    ("lf_purgelocks: vp %p has not vgone yet", vp));
 	state = *statep;
 	if (state == NULL) {
-		VI_UNLOCK(vp);
 		return;
 	}
+	VI_LOCK(vp);
 	*statep = NULL;
 	if (LIST_EMPTY(&state->ls_active) && state->ls_threads == 0) {
 		KASSERT(LIST_EMPTY(&state->ls_pending),