NFSv4: Fix a bug in __nfs4_find_state_byowner
authorTrond Myklebust <Trond.Myklebust@netapp.com>
Tue, 3 Jul 2007 18:41:19 +0000 (14:41 -0400)
committerTrond Myklebust <Trond.Myklebust@netapp.com>
Wed, 11 Jul 2007 03:40:40 +0000 (23:40 -0400)
The test for state->state == 0 does not tell you that the stateid is in the
process of being freed. It really tells you that the stateid is not yet
initialised...

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
fs/nfs/nfs4state.c

index ab0b5ab..ac816b3 100644 (file)
@@ -333,13 +333,10 @@ __nfs4_find_state_byowner(struct inode *inode, struct nfs4_state_owner *owner)
        struct nfs4_state *state;
 
        list_for_each_entry(state, &nfsi->open_states, inode_states) {
-               /* Is this in the process of being freed? */
-               if (state->state == 0)
+               if (state->owner != owner)
                        continue;
-               if (state->owner == owner) {
-                       atomic_inc(&state->count);
+               if (atomic_inc_not_zero(&state->count))
                        return state;
-               }
        }
        return NULL;
 }