git: 5d9215b315a9 - stable/12 - nfscl: Move release of the clientID lock into nfscl_doclose()

From: Rick Macklem <rmacklem_at_FreeBSD.org>
Date: Thu, 18 Nov 2021 22:59:38 UTC
The branch stable/12 has been updated by rmacklem:

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

commit 5d9215b315a9e2b90d36ba90c4a8c84306bcfee4
Author:     Rick Macklem <rmacklem@FreeBSD.org>
AuthorDate: 2021-10-16 22:49:38 +0000
Commit:     Rick Macklem <rmacklem@FreeBSD.org>
CommitDate: 2021-11-18 22:55:24 +0000

    nfscl: Move release of the clientID lock into nfscl_doclose()
    
    This patch moves release of the shared clientID lock from nfsrpc_close()
    just after the nfscl_doclose() call to the end of nfscl_doclose() call.
    This does make the code cleaner, since the shared lock is acquired at
    the beginning of nfscl_doclose().  The only semantics change is that
    the code no longer drops and reaquires the NFSCLSTATELOCK() mutex,
    which I do not believe will have a negative effect on the NFSv4 client.
    
    This is being done to prepare the code for a future patch that fixes
    the case where an NFSv4.1/4.2 server replies NFSERR_DELAY to a Close
    operation.
    
    (cherry picked from commit e2aab5e2d73486aa76bb861d583bbce021661601)
---
 sys/fs/nfsclient/nfs_clrpcops.c | 11 +++++------
 sys/fs/nfsclient/nfs_clstate.c  |  1 +
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/sys/fs/nfsclient/nfs_clrpcops.c b/sys/fs/nfsclient/nfs_clrpcops.c
index d6072bf2523e..f2eb3af5f101 100644
--- a/sys/fs/nfsclient/nfs_clrpcops.c
+++ b/sys/fs/nfsclient/nfs_clrpcops.c
@@ -716,13 +716,12 @@ nfsrpc_close(vnode_t vp, int doclose, NFSPROC_T *p)
 		return (0);
 	if (doclose)
 		error = nfscl_doclose(vp, &clp, p);
-	else
+	else {
 		error = nfscl_getclose(vp, &clp);
-	if (error)
-		return (error);
-
-	nfscl_clientrelease(clp);
-	return (0);
+		if (error == 0)
+			nfscl_clientrelease(clp);
+	}
+	return (error);
 }
 
 /*
diff --git a/sys/fs/nfsclient/nfs_clstate.c b/sys/fs/nfsclient/nfs_clstate.c
index ad4f16df8be8..9bd9b8759c51 100644
--- a/sys/fs/nfsclient/nfs_clstate.c
+++ b/sys/fs/nfsclient/nfs_clstate.c
@@ -3267,6 +3267,7 @@ lookformore:
 			op = LIST_NEXT(op, nfso_list);
 		}
 	}
+	nfscl_clrelease(clp);
 	NFSUNLOCKCLSTATE();
 	/*
 	 * recallp has been set NULL by nfscl_retoncloselayout() if it was