aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfsd
diff options
context:
space:
mode:
authorJ. Bruce Fields <bfields@redhat.com>2011-09-06 16:48:57 -0400
committerJ. Bruce Fields <bfields@redhat.com>2011-09-13 18:27:31 -0400
commit4d71ab8751c1d749f9fdf84ec094989adf579493 (patch)
tree82e3d8ece2e19e5b817e682e2959770158aed099 /fs/nfsd
parent4581d1409977c5fe686a4ed487cdce2e50031826 (diff)
nfsd4: split up find_stateid
Minor cleanup. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd')
-rw-r--r--fs/nfsd/nfs4state.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index f0eccc236a0d..aa088bc3b169 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -1068,21 +1068,29 @@ same_stateid(stateid_t *id_one, stateid_t *id_two)
1068 return id_one->si_fileid == id_two->si_fileid; 1068 return id_one->si_fileid == id_two->si_fileid;
1069} 1069}
1070 1070
1071static struct nfs4_stateid *find_stateid(stateid_t *t, int flags) 1071static struct nfs4_stateid *find_stateid(stateid_t *t)
1072{ 1072{
1073 struct nfs4_stateid *s; 1073 struct nfs4_stateid *s;
1074 unsigned int hashval; 1074 unsigned int hashval;
1075 1075
1076 hashval = stateid_hashval(t->si_stateownerid, t->si_fileid); 1076 hashval = stateid_hashval(t->si_stateownerid, t->si_fileid);
1077 list_for_each_entry(s, &stateid_hashtbl[hashval], st_hash) { 1077 list_for_each_entry(s, &stateid_hashtbl[hashval], st_hash)
1078 if (!same_stateid(&s->st_stateid, t)) 1078 if (same_stateid(&s->st_stateid, t))
1079 continue; 1079 return s;
1080 if (flags & LOCK_STATE && s->st_type != NFS4_LOCK_STID) 1080 return NULL;
1081 return NULL; 1081}
1082 if (flags & OPEN_STATE && s->st_type != NFS4_OPEN_STID) 1082
1083 return NULL; 1083static struct nfs4_stateid *find_stateid_by_type(stateid_t *t, int flags)
1084{
1085 struct nfs4_stateid *s;
1086
1087 s = find_stateid(t);
1088 if (!s)
1089 return NULL;
1090 if (flags & LOCK_STATE && s->st_type == NFS4_LOCK_STID)
1091 return s;
1092 if (flags & OPEN_STATE && s->st_type == NFS4_OPEN_STID)
1084 return s; 1093 return s;
1085 }
1086 return NULL; 1094 return NULL;
1087} 1095}
1088 1096
@@ -3241,7 +3249,7 @@ __be32 nfs4_validate_stateid(stateid_t *stateid, bool has_session)
3241 goto out; 3249 goto out;
3242 3250
3243 status = nfserr_expired; 3251 status = nfserr_expired;
3244 stp = find_stateid(stateid, 0); 3252 stp = find_stateid(stateid);
3245 if (!stp) 3253 if (!stp)
3246 goto out; 3254 goto out;
3247 status = nfserr_bad_stateid; 3255 status = nfserr_bad_stateid;
@@ -3306,7 +3314,7 @@ nfs4_preprocess_stateid_op(struct nfsd4_compound_state *cstate,
3306 BUG_ON(!*filpp); 3314 BUG_ON(!*filpp);
3307 } 3315 }
3308 } else { /* open or lock stateid */ 3316 } else { /* open or lock stateid */
3309 stp = find_stateid(stateid, flags); 3317 stp = find_stateid(stateid);
3310 if (!stp) 3318 if (!stp)
3311 goto out; 3319 goto out;
3312 status = nfserr_bad_stateid; 3320 status = nfserr_bad_stateid;
@@ -3381,7 +3389,7 @@ nfsd4_free_stateid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
3381 goto out; 3389 goto out;
3382 } 3390 }
3383 3391
3384 stp = find_stateid(stateid, 0); 3392 stp = find_stateid(stateid);
3385 if (!stp) { 3393 if (!stp) {
3386 ret = nfserr_bad_stateid; 3394 ret = nfserr_bad_stateid;
3387 goto out; 3395 goto out;
@@ -3440,7 +3448,7 @@ nfs4_preprocess_seqid_op(struct nfsd4_compound_state *cstate, u32 seqid,
3440 * the confirmed flag is incorrecly set, or the generation 3448 * the confirmed flag is incorrecly set, or the generation
3441 * number is incorrect. 3449 * number is incorrect.
3442 */ 3450 */
3443 *stpp = find_stateid(stateid, flags); 3451 *stpp = find_stateid_by_type(stateid, flags);
3444 if (*stpp == NULL) 3452 if (*stpp == NULL)
3445 return nfserr_expired; 3453 return nfserr_expired;
3446 3454