nfsd: ensure that seqid morphing operations are atomic wrt to copies
[firefly-linux-kernel-4.4.55.git] / fs / nfsd / state.h
index 1fa0f3848d4eb6324dbf391145ac1ef25f023874..77fdf4de91baa102dbefd2f15c5314be40aff162 100644 (file)
@@ -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 *);
 };
 
 /*
@@ -364,15 +365,6 @@ struct nfs4_client_reclaim {
        char                    cr_recdir[HEXDIR_LEN]; /* recover dir */
 };
 
-static inline void
-update_stateid(stateid_t *stateid)
-{
-       stateid->si_generation++;
-       /* Wraparound recommendation from 3530bis-13 9.1.3.2: */
-       if (stateid->si_generation == 0)
-               stateid->si_generation = 1;
-}
-
 /* A reasonable value for REPLAY_ISIZE was estimated as follows:  
  * The OPEN response, typically the largest, requires 
  *   4(status) + 8(stateid) + 20(changeinfo) + 4(rflags) +  8(verifier) + 
@@ -595,6 +587,7 @@ struct nfs4_stid *nfs4_alloc_stid(struct nfs4_client *cl,
                struct kmem_cache *slab);
 void nfs4_unhash_stid(struct nfs4_stid *s);
 void nfs4_put_stid(struct nfs4_stid *s);
+void nfs4_inc_and_copy_stateid(stateid_t *dst, struct nfs4_stid *stid);
 void nfs4_remove_reclaim_record(struct nfs4_client_reclaim *, struct nfsd_net *);
 extern void nfs4_release_reclaim(struct nfsd_net *);
 extern struct nfs4_client_reclaim *nfsd4_find_reclaim_client(const char *recdir,