aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfsd
diff options
context:
space:
mode:
authorJ. Bruce Fields <bfields@redhat.com>2013-04-09 17:42:28 -0400
committerJ. Bruce Fields <bfields@redhat.com>2013-04-09 17:42:28 -0400
commit23340032e64d70ce76817a88e8193c8040b095cf (patch)
tree12d7ebaea1fdc309f92514c96033b6a471053e1b /fs/nfsd
parent06b332a52293a45324320b6b446a7fa677fb6702 (diff)
nfsd4: clean up validate_stateid
The logic here is better expressed with a switch statement. While we're here, CLOSED stateids (or stateids of an unkown type--which would indicate a server bug) should probably return nfserr_bad_stateid, though this behavior shouldn't affect any non-buggy client. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd')
-rw-r--r--fs/nfsd/nfs4state.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 67017fcebb21..add9721ab059 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -3456,13 +3456,22 @@ static __be32 nfsd4_validate_stateid(struct nfs4_client *cl, stateid_t *stateid)
3456 status = check_stateid_generation(stateid, &s->sc_stateid, 1); 3456 status = check_stateid_generation(stateid, &s->sc_stateid, 1);
3457 if (status) 3457 if (status)
3458 return status; 3458 return status;
3459 if (!(s->sc_type & (NFS4_OPEN_STID | NFS4_LOCK_STID))) 3459 switch (s->sc_type) {
3460 case NFS4_DELEG_STID:
3461 return nfs_ok;
3462 case NFS4_OPEN_STID:
3463 case NFS4_LOCK_STID:
3464 ols = openlockstateid(s);
3465 if (ols->st_stateowner->so_is_open_owner
3466 && !(openowner(ols->st_stateowner)->oo_flags
3467 & NFS4_OO_CONFIRMED))
3468 return nfserr_bad_stateid;
3460 return nfs_ok; 3469 return nfs_ok;
3461 ols = openlockstateid(s); 3470 default:
3462 if (ols->st_stateowner->so_is_open_owner 3471 printk("unknown stateid type %x\n", s->sc_type);
3463 && !(openowner(ols->st_stateowner)->oo_flags & NFS4_OO_CONFIRMED)) 3472 case NFS4_CLOSED_STID:
3464 return nfserr_bad_stateid; 3473 return nfserr_bad_stateid;
3465 return nfs_ok; 3474 }
3466} 3475}
3467 3476
3468static __be32 nfsd4_lookup_stateid(stateid_t *stateid, unsigned char typemask, 3477static __be32 nfsd4_lookup_stateid(stateid_t *stateid, unsigned char typemask,