Skip to contentSkip to conversation

nfsd: add a spinlock to nfs4_stid

PATCH Applied Jeff Layton 2 participants 3 messages Oct 1, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nfsd: add a spinlock to nfs4_stid

...to allow seqid morphing to be serialized wrt to its copying.

---
 fs/nfsd/nfs4state.c |  1 +
 fs/nfsd/state.h     | 13 +++++++------
 2 files changed, 8 insertions(+), 6 deletions(-)
fs/nfsd/nfs4state.c +1 -0
index bec2cc7eac78..156fc9183728 100644
@@ -577,6 +577,7 @@ struct nfs4_stid *nfs4_alloc_stid(struct nfs4_client *cl,
 	stid->sc_stateid.si_opaque.so_clid = cl->cl_clientid;
 	/* Will be incremented before return to client: */
 	atomic_set(&stid->sc_count, 1);
+	spin_lock_init(&stid->sc_lock);
 
 	/*
 	 * It shouldn't be a problem to reuse an opaque stateid value.
fs/nfsd/state.h +7 -6
index 6f35fec88517..e3a191ea771c 100644
@@ -84,7 +84,7 @@ struct nfsd4_callback_ops {
  * fields that are of general use to any stateid.
  */
 struct nfs4_stid {
-	atomic_t sc_count;
+	atomic_t		sc_count;
 #define NFS4_OPEN_STID 1
 #define NFS4_LOCK_STID 2
 #define NFS4_DELEG_STID 4
@@ -94,11 +94,12 @@ struct nfs4_stid {
 #define NFS4_REVOKED_DELEG_STID 16
 #define NFS4_CLOSED_DELEG_STID 32
 #define NFS4_LAYOUT_STID 64
-	unsigned char sc_type;
-	stateid_t sc_stateid;
-	struct nfs4_client *sc_client;
-	struct nfs4_file *sc_file;
-	void (*sc_free)(struct nfs4_stid *);
+	unsigned char		sc_type;
+	stateid_t		sc_stateid;
+	spinlock_t		sc_lock;
+	struct nfs4_client	*sc_client;
+	struct nfs4_file	*sc_file;
+	void			(*sc_free)(struct nfs4_stid *);
 };
 
 /*
Signature · 1 line
2.4.3
#1 lore raw
Quoted 41 lines · On Thu, 1 Oct 2015 09:05:50 -0400 Jeff Layton <[email protected]> wrote:

...to allow seqid morphing to be serialized wrt to its copying.

---
 fs/nfsd/nfs4state.c |  1 +
 fs/nfsd/state.h     | 13 +++++++------
 2 files changed, 8 insertions(+), 6 deletions(-)
fs/nfsd/nfs4state.c +1 -0
index bec2cc7eac78..156fc9183728 100644
@@ -577,6 +577,7 @@ struct nfs4_stid *nfs4_alloc_stid(struct nfs4_client *cl,
 	stid->sc_stateid.si_opaque.so_clid = cl->cl_clientid;
 	/* Will be incremented before return to client: */
 	atomic_set(&stid->sc_count, 1);
+	spin_lock_init(&stid->sc_lock);
 
 	/*
 	 * It shouldn't be a problem to reuse an opaque stateid value.
fs/nfsd/state.h +1 -5
index 6f35fec88517..e3a191ea771c 100644
@@ -84,7 +84,7 @@ struct nfsd4_callback_ops {
  * fields that are of general use to any stateid.
  */
 struct nfs4_stid {
-	atomic_t sc_count;
+	atomic_t		sc_count;
 #define NFS4_OPEN_STID 1
 #define NFS4_LOCK_STID 2
 #define NFS4_DELEG_STID 4
@@ -94,11 +94,12 @@ struct nfs4_stid {
 #define NFS4_REVOKED_DELEG_STID 16
 #define NFS4_CLOSED_DELEG_STID 32
 #define NFS4_LAYOUT_STID 64
-	unsigned char sc_type;
-	stateid_t sc_stateid;
-	struct nfs4_client *sc_client;
-	struct nfs4_file *sc_file;

fs/nfsd/state.h struct nfs4_stid { · line 105

Quoted 10 lines
fs/nfsd/state.h +6 -1
-	void (*sc_free)(struct nfs4_stid *);
+	unsigned char		sc_type;
+	stateid_t		sc_stateid;
+	spinlock_t		sc_lock;
+	struct nfs4_client	*sc_client;
+	struct nfs4_file	*sc_file;
+	void			(*sc_free)(struct nfs4_stid *);
 };
 
 /*

Obviously the previously sent patch should be squashed in with this one. I meant to squash them before sending, but forgot. I'll do that if I need to respin though.

Signature · 1 line
Jeff Layton <[email protected]>
#2 lore raw
Quoted 53 lines · Jeff Layton
Quoted 50 lines · On Thu, 1 Oct 2015 09:05:50 -0400 Jeff Layton <[email protected]> wrote:

...to allow seqid morphing to be serialized wrt to its copying.

---
 fs/nfsd/nfs4state.c |  1 +
 fs/nfsd/state.h     | 13 +++++++------
 2 files changed, 8 insertions(+), 6 deletions(-)
fs/nfsd/nfs4state.c +1 -0
index bec2cc7eac78..156fc9183728 100644
@@ -577,6 +577,7 @@ struct nfs4_stid *nfs4_alloc_stid(struct nfs4_client *cl,
 	stid->sc_stateid.si_opaque.so_clid = cl->cl_clientid;
 	/* Will be incremented before return to client: */
 	atomic_set(&stid->sc_count, 1);
+	spin_lock_init(&stid->sc_lock);
 
 	/*
 	 * It shouldn't be a problem to reuse an opaque stateid value.
fs/nfsd/state.h +7 -6
index 6f35fec88517..e3a191ea771c 100644
@@ -84,7 +84,7 @@ struct nfsd4_callback_ops {
  * fields that are of general use to any stateid.
  */
 struct nfs4_stid {
-	atomic_t sc_count;
+	atomic_t		sc_count;
 #define NFS4_OPEN_STID 1
 #define NFS4_LOCK_STID 2
 #define NFS4_DELEG_STID 4
@@ -94,11 +94,12 @@ struct nfs4_stid {
 #define NFS4_REVOKED_DELEG_STID 16
 #define NFS4_CLOSED_DELEG_STID 32
 #define NFS4_LAYOUT_STID 64
-	unsigned char sc_type;
-	stateid_t sc_stateid;
-	struct nfs4_client *sc_client;
-	struct nfs4_file *sc_file;
-	void (*sc_free)(struct nfs4_stid *);
+	unsigned char		sc_type;
+	stateid_t		sc_stateid;
+	spinlock_t		sc_lock;
+	struct nfs4_client	*sc_client;
+	struct nfs4_file	*sc_file;
+	void			(*sc_free)(struct nfs4_stid *);
 };
 
Quoted 5 lines

fs/nfsd/state.h struct nfs4_stid { · line 105

Quoted 1 line
fs/nfsd/state.h +0 -0
 /*

Obviously the previously sent patch should be squashed in with this one. I meant to squash them before sending, but forgot. I'll do that if I need to respin though.

Thanks, applied; see my for-4.4-incoming branch to make sure I got it right....

I'm waffling a bit, but currently thinking I'll leave it for 4.4 given it's a relatively small race that we haven't seen in the wild.

--b.