Commit 203a8c8e authored by J. Bruce Fields's avatar J. Bruce Fields

nfsd4: separate delegreturn case from preprocess_stateid_op

Delegreturn is enough a special case for preprocess_stateid_op to
warrant just open-coding it in delegreturn.

There should be no change in behavior here; we're just reshuffling code.

Thanks to Yang Hongyang for catching a critical typo.
Reviewed-by: default avatarYang Hongyang <yanghy@cn.fujitsu.com>
Signed-off-by: default avatarJ. Bruce Fields <bfields@citi.umich.edu>
parent 3e633079
...@@ -2000,10 +2000,7 @@ out: ...@@ -2000,10 +2000,7 @@ out:
static inline __be32 static inline __be32
check_special_stateids(svc_fh *current_fh, stateid_t *stateid, int flags) check_special_stateids(svc_fh *current_fh, stateid_t *stateid, int flags)
{ {
/* Trying to call delegreturn with a special stateid? Yuch: */ if (ONE_STATEID(stateid) && (flags & RD_STATE))
if (!(flags & (RD_STATE | WR_STATE)))
return nfserr_bad_stateid;
else if (ONE_STATEID(stateid) && (flags & RD_STATE))
return nfs_ok; return nfs_ok;
else if (locks_in_grace()) { else if (locks_in_grace()) {
/* Answer in remaining cases depends on existance of /* Answer in remaining cases depends on existance of
...@@ -2024,8 +2021,7 @@ check_special_stateids(svc_fh *current_fh, stateid_t *stateid, int flags) ...@@ -2024,8 +2021,7 @@ check_special_stateids(svc_fh *current_fh, stateid_t *stateid, int flags)
static inline int static inline int
io_during_grace_disallowed(struct inode *inode, int flags) io_during_grace_disallowed(struct inode *inode, int flags)
{ {
return locks_in_grace() && (flags & (RD_STATE | WR_STATE)) return locks_in_grace() && mandatory_lock(inode);
&& mandatory_lock(inode);
} }
static int check_stateid_generation(stateid_t *in, stateid_t *ref) static int check_stateid_generation(stateid_t *in, stateid_t *ref)
...@@ -2089,8 +2085,6 @@ nfs4_preprocess_stateid_op(struct svc_fh *current_fh, stateid_t *stateid, int fl ...@@ -2089,8 +2085,6 @@ nfs4_preprocess_stateid_op(struct svc_fh *current_fh, stateid_t *stateid, int fl
if (status) if (status)
goto out; goto out;
renew_client(dp->dl_client); renew_client(dp->dl_client);
if (flags & DELEG_RET)
unhash_delegation(dp);
if (filpp) if (filpp)
*filpp = dp->dl_vfs_file; *filpp = dp->dl_vfs_file;
} else { /* open or lock stateid */ } else { /* open or lock stateid */
...@@ -2408,16 +2402,38 @@ __be32 ...@@ -2408,16 +2402,38 @@ __be32
nfsd4_delegreturn(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, nfsd4_delegreturn(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
struct nfsd4_delegreturn *dr) struct nfsd4_delegreturn *dr)
{ {
struct nfs4_delegation *dp;
stateid_t *stateid = &dr->dr_stateid;
struct inode *inode;
__be32 status; __be32 status;
if ((status = fh_verify(rqstp, &cstate->current_fh, S_IFREG, 0))) if ((status = fh_verify(rqstp, &cstate->current_fh, S_IFREG, 0)))
goto out; return status;
inode = cstate->current_fh.fh_dentry->d_inode;
nfs4_lock_state(); nfs4_lock_state();
status = nfs4_preprocess_stateid_op(&cstate->current_fh, status = nfserr_bad_stateid;
&dr->dr_stateid, DELEG_RET, NULL); if (ZERO_STATEID(stateid) || ONE_STATEID(stateid))
nfs4_unlock_state(); goto out;
status = nfserr_stale_stateid;
if (STALE_STATEID(stateid))
goto out;
status = nfs_ok;
if (!is_delegation_stateid(stateid))
goto out;
status = nfserr_bad_stateid;
dp = find_delegation_stateid(inode, stateid);
if (!dp)
goto out;
status = check_stateid_generation(stateid, &dp->dl_stateid);
if (status)
goto out;
renew_client(dp->dl_client);
unhash_delegation(dp);
out: out:
nfs4_unlock_state();
return status; return status;
} }
......
...@@ -263,7 +263,6 @@ struct nfs4_stateid { ...@@ -263,7 +263,6 @@ struct nfs4_stateid {
#define RD_STATE 0x00000010 #define RD_STATE 0x00000010
#define WR_STATE 0x00000020 #define WR_STATE 0x00000020
#define CLOSE_STATE 0x00000040 #define CLOSE_STATE 0x00000040
#define DELEG_RET 0x00000080
#define seqid_mutating_err(err) \ #define seqid_mutating_err(err) \
(((err) != nfserr_stale_clientid) && \ (((err) != nfserr_stale_clientid) && \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment