提交 f3e42237 编写于 作者: J J. Bruce Fields

nfsd4: centralize handling of replay owners

Set the stateowner associated with a replay in one spot in
nfs4_preprocess_seqid_op() and keep it in cstate.  This allows removing
a few lines of boilerplate from all the nfs4_preprocess_seqid_op()
callers.

Also turn ENCODE_SEQID_OP_TAIL into a function while we're here.
Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
上级 73997dc4
...@@ -3425,12 +3425,15 @@ nfs4_preprocess_seqid_op(struct nfsd4_compound_state *cstate, u32 seqid, ...@@ -3425,12 +3425,15 @@ nfs4_preprocess_seqid_op(struct nfsd4_compound_state *cstate, u32 seqid,
/* It's not stale; let's assume it's expired: */ /* It's not stale; let's assume it's expired: */
if (sop == NULL) if (sop == NULL)
return nfserr_expired; return nfserr_expired;
*sopp = sop; nfs4_get_stateowner(sop);
cstate->replay_owner = sop;
goto check_replay; goto check_replay;
} }
*stpp = stp; *stpp = stp;
*sopp = sop = stp->st_stateowner; *sopp = sop = stp->st_stateowner;
nfs4_get_stateowner(sop);
cstate->replay_owner = sop;
if (nfs4_check_fh(current_fh, stp)) { if (nfs4_check_fh(current_fh, stp)) {
dprintk("NFSD: preprocess_seqid_op: fh-stateid mismatch!\n"); dprintk("NFSD: preprocess_seqid_op: fh-stateid mismatch!\n");
...@@ -3501,10 +3504,6 @@ nfsd4_open_confirm(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, ...@@ -3501,10 +3504,6 @@ nfsd4_open_confirm(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
nfsd4_create_clid_dir(sop->so_client); nfsd4_create_clid_dir(sop->so_client);
out: out:
if (oc->oc_stateowner) {
nfs4_get_stateowner(oc->oc_stateowner);
cstate->replay_owner = oc->oc_stateowner;
}
nfs4_unlock_state(); nfs4_unlock_state();
return status; return status;
} }
...@@ -3574,10 +3573,6 @@ nfsd4_open_downgrade(struct svc_rqst *rqstp, ...@@ -3574,10 +3573,6 @@ nfsd4_open_downgrade(struct svc_rqst *rqstp,
memcpy(&od->od_stateid, &stp->st_stateid, sizeof(stateid_t)); memcpy(&od->od_stateid, &stp->st_stateid, sizeof(stateid_t));
status = nfs_ok; status = nfs_ok;
out: out:
if (od->od_stateowner) {
nfs4_get_stateowner(od->od_stateowner);
cstate->replay_owner = od->od_stateowner;
}
nfs4_unlock_state(); nfs4_unlock_state();
return status; return status;
} }
...@@ -3618,10 +3613,6 @@ nfsd4_close(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, ...@@ -3618,10 +3613,6 @@ nfsd4_close(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
if (list_empty(&close->cl_stateowner->so_stateids)) if (list_empty(&close->cl_stateowner->so_stateids))
move_to_close_lru(close->cl_stateowner); move_to_close_lru(close->cl_stateowner);
out: out:
if (close->cl_stateowner) {
nfs4_get_stateowner(close->cl_stateowner);
cstate->replay_owner = close->cl_stateowner;
}
nfs4_unlock_state(); nfs4_unlock_state();
return status; return status;
} }
...@@ -4086,10 +4077,6 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, ...@@ -4086,10 +4077,6 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
out: out:
if (status && lock->lk_is_new && lock_sop) if (status && lock->lk_is_new && lock_sop)
release_lockowner(lock_sop); release_lockowner(lock_sop);
if (lock->lk_replay_owner) {
nfs4_get_stateowner(lock->lk_replay_owner);
cstate->replay_owner = lock->lk_replay_owner;
}
nfs4_unlock_state(); nfs4_unlock_state();
return status; return status;
} }
...@@ -4244,10 +4231,6 @@ nfsd4_locku(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, ...@@ -4244,10 +4231,6 @@ nfsd4_locku(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
memcpy(&locku->lu_stateid, &stp->st_stateid, sizeof(stateid_t)); memcpy(&locku->lu_stateid, &stp->st_stateid, sizeof(stateid_t));
out: out:
if (locku->lu_stateowner) {
nfs4_get_stateowner(locku->lu_stateowner);
cstate->replay_owner = locku->lu_stateowner;
}
nfs4_unlock_state(); nfs4_unlock_state();
return status; return status;
......
...@@ -1630,15 +1630,19 @@ static void write_cinfo(__be32 **p, struct nfsd4_change_info *c) ...@@ -1630,15 +1630,19 @@ static void write_cinfo(__be32 **p, struct nfsd4_change_info *c)
* we know whether the error to be returned is a sequence id mutating error. * we know whether the error to be returned is a sequence id mutating error.
*/ */
#define ENCODE_SEQID_OP_TAIL(stateowner) do { \ static void encode_seqid_op_tail(struct nfsd4_compoundres *resp, __be32 *save, __be32 nfserr)
if (seqid_mutating_err(ntohl(nfserr)) && stateowner) { \ {
stateowner->so_seqid++; \ struct nfs4_stateowner *stateowner = resp->cstate.replay_owner;
stateowner->so_replay.rp_status = nfserr; \
stateowner->so_replay.rp_buflen = \ if (seqid_mutating_err(ntohl(nfserr)) && stateowner) {
(((char *)(resp)->p - (char *)save)); \ stateowner->so_seqid++;
memcpy(stateowner->so_replay.rp_buf, save, \ stateowner->so_replay.rp_status = nfserr;
stateowner->so_replay.rp_buflen); \ stateowner->so_replay.rp_buflen =
} } while (0); (char *)resp->p - (char *)save;
memcpy(stateowner->so_replay.rp_buf, save,
stateowner->so_replay.rp_buflen);
}
}
/* Encode as an array of strings the string given with components /* Encode as an array of strings the string given with components
* separated @sep. * separated @sep.
...@@ -2495,7 +2499,7 @@ nfsd4_encode_close(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_c ...@@ -2495,7 +2499,7 @@ nfsd4_encode_close(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_c
if (!nfserr) if (!nfserr)
nfsd4_encode_stateid(resp, &close->cl_stateid); nfsd4_encode_stateid(resp, &close->cl_stateid);
ENCODE_SEQID_OP_TAIL(close->cl_stateowner); encode_seqid_op_tail(resp, save, nfserr);
return nfserr; return nfserr;
} }
...@@ -2599,7 +2603,7 @@ nfsd4_encode_lock(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_lo ...@@ -2599,7 +2603,7 @@ nfsd4_encode_lock(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_lo
else if (nfserr == nfserr_denied) else if (nfserr == nfserr_denied)
nfsd4_encode_lock_denied(resp, &lock->lk_denied); nfsd4_encode_lock_denied(resp, &lock->lk_denied);
ENCODE_SEQID_OP_TAIL(lock->lk_replay_owner); encode_seqid_op_tail(resp, save, nfserr);
return nfserr; return nfserr;
} }
...@@ -2619,7 +2623,7 @@ nfsd4_encode_locku(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_l ...@@ -2619,7 +2623,7 @@ nfsd4_encode_locku(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_l
if (!nfserr) if (!nfserr)
nfsd4_encode_stateid(resp, &locku->lu_stateid); nfsd4_encode_stateid(resp, &locku->lu_stateid);
ENCODE_SEQID_OP_TAIL(locku->lu_stateowner); encode_seqid_op_tail(resp, save, nfserr);
return nfserr; return nfserr;
} }
...@@ -2700,7 +2704,7 @@ nfsd4_encode_open(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_op ...@@ -2700,7 +2704,7 @@ nfsd4_encode_open(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_op
} }
/* XXX save filehandle here */ /* XXX save filehandle here */
out: out:
ENCODE_SEQID_OP_TAIL(open->op_stateowner); encode_seqid_op_tail(resp, save, nfserr);
return nfserr; return nfserr;
} }
...@@ -2712,7 +2716,7 @@ nfsd4_encode_open_confirm(struct nfsd4_compoundres *resp, __be32 nfserr, struct ...@@ -2712,7 +2716,7 @@ nfsd4_encode_open_confirm(struct nfsd4_compoundres *resp, __be32 nfserr, struct
if (!nfserr) if (!nfserr)
nfsd4_encode_stateid(resp, &oc->oc_resp_stateid); nfsd4_encode_stateid(resp, &oc->oc_resp_stateid);
ENCODE_SEQID_OP_TAIL(oc->oc_stateowner); encode_seqid_op_tail(resp, save, nfserr);
return nfserr; return nfserr;
} }
...@@ -2724,7 +2728,7 @@ nfsd4_encode_open_downgrade(struct nfsd4_compoundres *resp, __be32 nfserr, struc ...@@ -2724,7 +2728,7 @@ nfsd4_encode_open_downgrade(struct nfsd4_compoundres *resp, __be32 nfserr, struc
if (!nfserr) if (!nfserr)
nfsd4_encode_stateid(resp, &od->od_stateid); nfsd4_encode_stateid(resp, &od->od_stateid);
ENCODE_SEQID_OP_TAIL(od->od_stateowner); encode_seqid_op_tail(resp, save, nfserr);
return nfserr; return nfserr;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册