Skip to contentSkip to conversation

nfsd: convert global state_lock to per-net deleg_lock

PATCH In review Jeff Layton 2 participants 2 messages Feb 24

Subsystems (2)
lore
Share & tools
lore

Jeff Layton

author maintainer
#0 lore raw

PATCH 1/1 nfsd: convert global state_lock to per-net deleg_lock

Replace the global state_lock spinlock with a per-nfsd_net deleg_lock. The state_lock was only used to protect delegation lifecycle operations (the del_recall_lru list and delegation hash/unhash), all of which are scoped to a single network namespace. Making the lock per-net removes a source of unnecessary contention between containers.

---
 fs/nfsd/netns.h     |  3 +++
 fs/nfsd/nfs4state.c | 62 +++++++++++++++++++++++++++--------------------------
 fs/nfsd/state.h     |  2 +-
 3 files changed, 36 insertions(+), 31 deletions(-)
fs/nfsd/netns.h +3 -0
index 0071cc25fbc23282d928c6cb9a8c5468c4560c33..71193dd96b58680172cc6b55f8eaf8fe437a3323 100644
@@ -101,6 +101,9 @@ struct nfsd_net {
 	struct list_head close_lru;
 	struct list_head del_recall_lru;
 
+	/* protects del_recall_lru and delegation hash/unhash */
+	spinlock_t deleg_lock;
+
 	/* protected by blocked_locks_lock */
 	struct list_head blocked_locks_lru;
 
fs/nfsd/nfs4state.c +32 -30

214 lines not on this page · raw message

fs/nfsd/state.h +1 -1
index 4a246b07dee0f88af2cd7383d46329512363ff83..07528004989edc4c09694ae97aa0d5ed0e6dd5cd 100644
@@ -123,7 +123,7 @@ struct nfs4_stid {
 #define SC_TYPE_LAYOUT		BIT(3)
 	unsigned short		sc_type;
 
-/* state_lock protects sc_status for delegation stateids.
+/* nn->deleg_lock protects sc_status for delegation stateids.
  * ->cl_lock protects sc_status for open and lock stateids.
  * ->st_mutex also protect sc_status for open stateids.
  * ->ls_lock protects sc_status for layout stateids.

---
base-commit: 9affc4c96f49744c7eab647d922fc82d290834b2
change-id: 20260224-nfsd-deleg-lock-45d00443c33d

Best regards,

Signature · 1 line
Jeff Layton <[email protected]>
maintainer
#1 lore raw

From: Chuck Lever <[email protected]>

Quoted 8 lines · Jeff Layton

Replace the global state_lock spinlock with a per-nfsd_net deleg_lock. The state_lock was only used to protect delegation lifecycle operations (the del_recall_lru list and delegation hash/unhash), all of which are scoped to a single network namespace. Making the lock per-net removes a source of unnecessary contention between containers.

[...]

Applied to nfsd-testing with minor changes, thanks!

[1/1] nfsd: convert global state_lock to per-net deleg_lock

      commit: 87d8659010fe5ba78759ad7b8780656f1c3d350a

--
Chuck Lever