aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs
diff options
context:
space:
mode:
authorTrond Myklebust <trond.myklebust@primarydata.com>2014-02-10 18:20:47 -0500
committerTrond Myklebust <trond.myklebust@primarydata.com>2014-02-19 21:21:05 -0500
commite999e80ee9fc47f1febbec6823deda3537dbbd22 (patch)
treee76d471f251cb27d93912ca6192c8dae413f1407 /fs/nfs
parent2c64c57dfc4b7946f7abd8af653f55af581bc2c3 (diff)
NFSv4: Don't update the open stateid unless it is newer than the old one
This patch is in preparation for the NFSv4.1 parallel open capability. Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Diffstat (limited to 'fs/nfs')
-rw-r--r--fs/nfs/nfs4_fs.h10
-rw-r--r--fs/nfs/nfs4proc.c21
2 files changed, 27 insertions, 4 deletions
diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h
index a5b27c2d9689..df81fcc138a7 100644
--- a/fs/nfs/nfs4_fs.h
+++ b/fs/nfs/nfs4_fs.h
@@ -500,6 +500,16 @@ static inline bool nfs4_stateid_match(const nfs4_stateid *dst, const nfs4_statei
500 return memcmp(dst, src, sizeof(*dst)) == 0; 500 return memcmp(dst, src, sizeof(*dst)) == 0;
501} 501}
502 502
503static inline bool nfs4_stateid_match_other(const nfs4_stateid *dst, const nfs4_stateid *src)
504{
505 return memcmp(dst->other, src->other, NFS4_STATEID_OTHER_SIZE) == 0;
506}
507
508static inline bool nfs4_stateid_is_newer(const nfs4_stateid *s1, const nfs4_stateid *s2)
509{
510 return (s32)(be32_to_cpu(s1->seqid) - be32_to_cpu(s2->seqid)) > 0;
511}
512
503static inline bool nfs4_valid_open_stateid(const struct nfs4_state *state) 513static inline bool nfs4_valid_open_stateid(const struct nfs4_state *state)
504{ 514{
505 return test_bit(NFS_STATE_RECOVERY_FAILED, &state->flags) == 0; 515 return test_bit(NFS_STATE_RECOVERY_FAILED, &state->flags) == 0;
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 2da6a698b8f7..96e0bd42f38c 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -1137,12 +1137,20 @@ static void update_open_stateflags(struct nfs4_state *state, fmode_t fmode)
1137 nfs4_state_set_mode_locked(state, state->state | fmode); 1137 nfs4_state_set_mode_locked(state, state->state | fmode);
1138} 1138}
1139 1139
1140static bool nfs_need_update_open_stateid(struct nfs4_state *state,
1141 nfs4_stateid *stateid)
1142{
1143 if (test_and_set_bit(NFS_OPEN_STATE, &state->flags) == 0)
1144 return true;
1145 if (!nfs4_stateid_match_other(stateid, &state->open_stateid))
1146 return true;
1147 if (nfs4_stateid_is_newer(stateid, &state->open_stateid))
1148 return true;
1149 return false;
1150}
1151
1140static void nfs_set_open_stateid_locked(struct nfs4_state *state, nfs4_stateid *stateid, fmode_t fmode) 1152static void nfs_set_open_stateid_locked(struct nfs4_state *state, nfs4_stateid *stateid, fmode_t fmode)
1141{ 1153{
1142 if (test_bit(NFS_DELEGATED_STATE, &state->flags) == 0)
1143 nfs4_stateid_copy(&state->stateid, stateid);
1144 nfs4_stateid_copy(&state->open_stateid, stateid);
1145 set_bit(NFS_OPEN_STATE, &state->flags);
1146 switch (fmode) { 1154 switch (fmode) {
1147 case FMODE_READ: 1155 case FMODE_READ:
1148 set_bit(NFS_O_RDONLY_STATE, &state->flags); 1156 set_bit(NFS_O_RDONLY_STATE, &state->flags);
@@ -1153,6 +1161,11 @@ static void nfs_set_open_stateid_locked(struct nfs4_state *state, nfs4_stateid *
1153 case FMODE_READ|FMODE_WRITE: 1161 case FMODE_READ|FMODE_WRITE:
1154 set_bit(NFS_O_RDWR_STATE, &state->flags); 1162 set_bit(NFS_O_RDWR_STATE, &state->flags);
1155 } 1163 }
1164 if (!nfs_need_update_open_stateid(state, stateid))
1165 return;
1166 if (test_bit(NFS_DELEGATED_STATE, &state->flags) == 0)
1167 nfs4_stateid_copy(&state->stateid, stateid);
1168 nfs4_stateid_copy(&state->open_stateid, stateid);
1156} 1169}
1157 1170
1158static void nfs_set_open_stateid(struct nfs4_state *state, nfs4_stateid *stateid, fmode_t fmode) 1171static void nfs_set_open_stateid(struct nfs4_state *state, nfs4_stateid *stateid, fmode_t fmode)