{
int status;
- status = nfs41_test_stateid(server, stateid, cred);
+ switch (stateid->type) {
+ default:
+ break;
+ case NFS4_INVALID_STATEID_TYPE:
+ case NFS4_SPECIAL_STATEID_TYPE:
+ return -NFS4ERR_BAD_STATEID;
+ case NFS4_REVOKED_STATEID_TYPE:
+ goto out_free;
+ }
+ status = nfs41_test_stateid(server, stateid, cred);
switch (status) {
case -NFS4ERR_EXPIRED:
case -NFS4ERR_ADMIN_REVOKED:
case -NFS4ERR_DELEG_REVOKED:
- /* Ack the revoked state to the server */
- nfs41_free_stateid(server, stateid, cred);
- case -NFS4ERR_BAD_STATEID:
+ break;
+ default:
return status;
}
- return NFS_OK;
+out_free:
+ /* Ack the revoked state to the server */
+ nfs41_free_stateid(server, stateid, cred);
+ return -NFS4ERR_EXPIRED;
}
static void nfs41_check_delegation_stateid(struct nfs4_state *state)
rcu_read_unlock();
status = nfs41_test_and_free_expired_stateid(server, &stateid, cred);
trace_nfs4_test_delegation_stateid(state, NULL, status);
- if (status != NFS_OK)
+ if (status == -NFS4ERR_EXPIRED || status == -NFS4ERR_BAD_STATEID)
nfs_finish_clear_delegation_stateid(state, &stateid);
put_rpccred(cred);
status = nfs41_test_and_free_expired_stateid(server, stateid, cred);
trace_nfs4_test_open_stateid(state, NULL, status);
- if (status != NFS_OK) {
+ if (status == -NFS4ERR_EXPIRED || status == -NFS4ERR_BAD_STATEID) {
clear_bit(NFS_O_RDONLY_STATE, &state->flags);
clear_bit(NFS_O_WRONLY_STATE, &state->flags);
clear_bit(NFS_O_RDWR_STATE, &state->flags);
*/
static int nfs41_check_expired_locks(struct nfs4_state *state)
{
- int status, ret = -NFS4ERR_BAD_STATEID;
+ int status, ret = NFS_OK;
struct nfs4_lock_state *lsp;
struct nfs_server *server = NFS_SERVER(state->inode);
&lsp->ls_stateid,
cred);
trace_nfs4_test_lock_stateid(state, lsp, status);
- if (status != NFS_OK) {
+ if (status == -NFS4ERR_EXPIRED ||
+ status == -NFS4ERR_BAD_STATEID)
clear_bit(NFS_LOCK_INITIALIZED, &lsp->ls_flags);
+ else if (status != NFS_OK) {
ret = status;
+ break;
}
}
};