diff options
author | J. Bruce Fields <bfields@redhat.com> | 2011-09-16 18:56:20 -0400 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2011-09-17 10:31:16 -0400 |
commit | 2da1cec713bc6d3ec9732e7d48b8bc0453580fd3 (patch) | |
tree | ff00317454df850f2e06ceaa4dabb84e64e3cc5f /fs/nfsd | |
parent | 38c387b52d8404f8fd29d8c26bebc83a80733657 (diff) |
nfsd4: simplify free_stateid
We no longer need is_deleg_stateid, for example.
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd')
-rw-r--r-- | fs/nfsd/nfs4state.c | 66 |
1 files changed, 15 insertions, 51 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index a174841b262e..fdd03f6ae044 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c | |||
@@ -1098,16 +1098,6 @@ static struct nfs4_stid *find_stateid(stateid_t *t) | |||
1098 | return NULL; | 1098 | return NULL; |
1099 | } | 1099 | } |
1100 | 1100 | ||
1101 | static struct nfs4_ol_stateid *find_ol_stateid(stateid_t *t) | ||
1102 | { | ||
1103 | struct nfs4_stid *s; | ||
1104 | |||
1105 | s = find_stateid(t); | ||
1106 | if (!s) | ||
1107 | return NULL; | ||
1108 | return openlockstateid(s); | ||
1109 | } | ||
1110 | |||
1111 | static struct nfs4_stid *find_stateid_by_type(stateid_t *t, char typemask) | 1101 | static struct nfs4_stid *find_stateid_by_type(stateid_t *t, char typemask) |
1112 | { | 1102 | { |
1113 | struct nfs4_stid *s; | 1103 | struct nfs4_stid *s; |
@@ -3251,11 +3241,6 @@ static int check_stateid_generation(stateid_t *in, stateid_t *ref, bool has_sess | |||
3251 | return nfserr_old_stateid; | 3241 | return nfserr_old_stateid; |
3252 | } | 3242 | } |
3253 | 3243 | ||
3254 | static int is_delegation_stateid(stateid_t *stateid) | ||
3255 | { | ||
3256 | return stateid->si_fileid == 0; | ||
3257 | } | ||
3258 | |||
3259 | __be32 nfs4_validate_stateid(stateid_t *stateid, bool has_session) | 3244 | __be32 nfs4_validate_stateid(stateid_t *stateid, bool has_session) |
3260 | { | 3245 | { |
3261 | struct nfs4_stid *s; | 3246 | struct nfs4_stid *s; |
@@ -3353,16 +3338,6 @@ out: | |||
3353 | } | 3338 | } |
3354 | 3339 | ||
3355 | static __be32 | 3340 | static __be32 |
3356 | nfsd4_free_delegation_stateid(stateid_t *stateid) | ||
3357 | { | ||
3358 | struct nfs4_delegation *dp = find_deleg_stateid(stateid); | ||
3359 | if (dp) | ||
3360 | return nfserr_locks_held; | ||
3361 | |||
3362 | return nfserr_bad_stateid; | ||
3363 | } | ||
3364 | |||
3365 | static __be32 | ||
3366 | nfsd4_free_lock_stateid(struct nfs4_ol_stateid *stp) | 3341 | nfsd4_free_lock_stateid(struct nfs4_ol_stateid *stp) |
3367 | { | 3342 | { |
3368 | if (check_for_locks(stp->st_file, lockowner(stp->st_stateowner))) | 3343 | if (check_for_locks(stp->st_file, lockowner(stp->st_stateowner))) |
@@ -3382,40 +3357,32 @@ nfsd4_test_stateid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
3382 | return nfs_ok; | 3357 | return nfs_ok; |
3383 | } | 3358 | } |
3384 | 3359 | ||
3385 | /* | ||
3386 | * Free a state id | ||
3387 | */ | ||
3388 | __be32 | 3360 | __be32 |
3389 | nfsd4_free_stateid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | 3361 | nfsd4_free_stateid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, |
3390 | struct nfsd4_free_stateid *free_stateid) | 3362 | struct nfsd4_free_stateid *free_stateid) |
3391 | { | 3363 | { |
3392 | stateid_t *stateid = &free_stateid->fr_stateid; | 3364 | stateid_t *stateid = &free_stateid->fr_stateid; |
3393 | struct nfs4_ol_stateid *stp; | 3365 | struct nfs4_stid *s; |
3394 | __be32 ret; | 3366 | __be32 ret = nfserr_bad_stateid; |
3395 | 3367 | ||
3396 | nfs4_lock_state(); | 3368 | nfs4_lock_state(); |
3397 | if (is_delegation_stateid(stateid)) { | 3369 | s = find_stateid(stateid); |
3398 | ret = nfsd4_free_delegation_stateid(stateid); | 3370 | if (!s) |
3399 | goto out; | ||
3400 | } | ||
3401 | |||
3402 | stp = find_ol_stateid(stateid); | ||
3403 | if (!stp) { | ||
3404 | ret = nfserr_bad_stateid; | ||
3405 | goto out; | ||
3406 | } | ||
3407 | ret = check_stateid_generation(stateid, &stp->st_stid.sc_stateid, 1); | ||
3408 | if (ret) | ||
3409 | goto out; | 3371 | goto out; |
3410 | 3372 | switch (s->sc_type) { | |
3411 | if (stp->st_stid.sc_type == NFS4_OPEN_STID) { | 3373 | case NFS4_DELEG_STID: |
3412 | ret = nfserr_locks_held; | 3374 | ret = nfserr_locks_held; |
3413 | goto out; | 3375 | goto out; |
3414 | } else { | 3376 | case NFS4_OPEN_STID: |
3415 | ret = nfsd4_free_lock_stateid(stp); | 3377 | case NFS4_LOCK_STID: |
3416 | goto out; | 3378 | ret = check_stateid_generation(stateid, &s->sc_stateid, 1); |
3379 | if (ret) | ||
3380 | goto out; | ||
3381 | if (s->sc_type == NFS4_LOCK_STID) | ||
3382 | ret = nfsd4_free_lock_stateid(openlockstateid(s)); | ||
3383 | else | ||
3384 | ret = nfserr_locks_held; | ||
3417 | } | 3385 | } |
3418 | |||
3419 | out: | 3386 | out: |
3420 | nfs4_unlock_state(); | 3387 | nfs4_unlock_state(); |
3421 | return ret; | 3388 | return ret; |
@@ -3698,9 +3665,6 @@ nfsd4_delegreturn(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
3698 | status = nfserr_stale_stateid; | 3665 | status = nfserr_stale_stateid; |
3699 | if (STALE_STATEID(stateid)) | 3666 | if (STALE_STATEID(stateid)) |
3700 | goto out; | 3667 | goto out; |
3701 | status = nfserr_bad_stateid; | ||
3702 | if (!is_delegation_stateid(stateid)) | ||
3703 | goto out; | ||
3704 | status = nfserr_expired; | 3668 | status = nfserr_expired; |
3705 | dp = find_deleg_stateid(stateid); | 3669 | dp = find_deleg_stateid(stateid); |
3706 | if (!dp) | 3670 | if (!dp) |