NFSv4: We must set NFS_OPEN_STATE flag in nfs_resync_open_stateid_locked
authorTrond Myklebust <trond.myklebust@primarydata.com>
Wed, 22 Jul 2015 17:46:13 +0000 (13:46 -0400)
committerTrond Myklebust <trond.myklebust@primarydata.com>
Wed, 22 Jul 2015 21:10:51 +0000 (17:10 -0400)
Otherwise, nfs4_select_rw_stateid() will always return the zero stateid
instead of the correct open stateid.

Fixes: f95549cf24660 ("NFSv4: More CLOSE/OPEN races")
Cc: stable@vger.kernel.org # 4.0+
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
fs/nfs/nfs4proc.c

index c5c9e0d070f858de749f44098e4b4da11c345cdf..9264994ec9d3487c00e001faf917fd0f418ae977 100644 (file)
@@ -1200,12 +1200,15 @@ static bool nfs_need_update_open_stateid(struct nfs4_state *state,
 
 static void nfs_resync_open_stateid_locked(struct nfs4_state *state)
 {
+       if (!(state->n_wronly || state->n_rdonly || state->n_rdwr))
+               return;
        if (state->n_wronly)
                set_bit(NFS_O_WRONLY_STATE, &state->flags);
        if (state->n_rdonly)
                set_bit(NFS_O_RDONLY_STATE, &state->flags);
        if (state->n_rdwr)
                set_bit(NFS_O_RDWR_STATE, &state->flags);
+       set_bit(NFS_OPEN_STATE, &state->flags);
 }
 
 static void nfs_clear_open_stateid_locked(struct nfs4_state *state,