NFSD: Async COPY result needs to return a write verifier
[ Upstream commit 9ed666eba4e0a2bb8ffaa3739d830b64d4f2aaad ] Currently, when NFSD handles an asynchronous COPY, it returns a zero write verifier, relying on the subsequent CB_OFFLOAD callback to pass the write verifier and a stable_how4 value to the client. However, if the CB_OFFLOAD never arrives at the client (for example, if a network partition occurs just as the server sends the CB_OFFLOAD operation), the client will never receive this verifier. Thus, if the client sends a follow-up COMMIT, there is no way for the client to assess the COMMIT result. The usual recovery for a missing CB_OFFLOAD is for the client to send an OFFLOAD_STATUS operation, but that operation does not carry a write verifier in its result. Neither does it carry a stable_how4 value, so the client /must/ send a COMMIT in this case -- which will always fail because currently there's still no write verifier in the COPY result. Thus the server needs to return a normal write verifier in its COPY result even if the COPY operation is to be performed asynchronously. If the server recognizes the callback stateid in subsequent OFFLOAD_STATUS operations, then obviously it has not restarted, and the write verifier the client received in the COPY result is still valid and can be used to assess a COMMIT of the copied data, if one is needed. Reviewed-by: Jeff Layton <jlayton@kernel.org> [ cel: adjusted to apply to origin/linux-5.10.y ] Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
ea45c08610
commit
bba6e4fa6b
1 changed files with 9 additions and 16 deletions
|
@ -713,15 +713,6 @@ nfsd4_access(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
|
||||||
&access->ac_supported);
|
&access->ac_supported);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gen_boot_verifier(nfs4_verifier *verifier, struct net *net)
|
|
||||||
{
|
|
||||||
__be32 *verf = (__be32 *)verifier->data;
|
|
||||||
|
|
||||||
BUILD_BUG_ON(2*sizeof(*verf) != sizeof(verifier->data));
|
|
||||||
|
|
||||||
nfsd_copy_write_verifier(verf, net_generic(net, nfsd_net_id));
|
|
||||||
}
|
|
||||||
|
|
||||||
static __be32
|
static __be32
|
||||||
nfsd4_commit(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
|
nfsd4_commit(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
|
||||||
union nfsd4_op_u *u)
|
union nfsd4_op_u *u)
|
||||||
|
@ -1590,7 +1581,6 @@ static void nfsd4_init_copy_res(struct nfsd4_copy *copy, bool sync)
|
||||||
test_bit(NFSD4_COPY_F_COMMITTED, ©->cp_flags) ?
|
test_bit(NFSD4_COPY_F_COMMITTED, ©->cp_flags) ?
|
||||||
NFS_FILE_SYNC : NFS_UNSTABLE;
|
NFS_FILE_SYNC : NFS_UNSTABLE;
|
||||||
nfsd4_copy_set_sync(copy, sync);
|
nfsd4_copy_set_sync(copy, sync);
|
||||||
gen_boot_verifier(©->cp_res.wr_verifier, copy->cp_clp->net);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t _nfsd_copy_file_range(struct nfsd4_copy *copy,
|
static ssize_t _nfsd_copy_file_range(struct nfsd4_copy *copy,
|
||||||
|
@ -1761,9 +1751,14 @@ static __be32
|
||||||
nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
|
nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
|
||||||
union nfsd4_op_u *u)
|
union nfsd4_op_u *u)
|
||||||
{
|
{
|
||||||
struct nfsd4_copy *copy = &u->copy;
|
struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id);
|
||||||
__be32 status;
|
|
||||||
struct nfsd4_copy *async_copy = NULL;
|
struct nfsd4_copy *async_copy = NULL;
|
||||||
|
struct nfsd4_copy *copy = &u->copy;
|
||||||
|
struct nfsd42_write_res *result;
|
||||||
|
__be32 status;
|
||||||
|
|
||||||
|
result = ©->cp_res;
|
||||||
|
nfsd_copy_write_verifier((__be32 *)&result->wr_verifier.data, nn);
|
||||||
|
|
||||||
copy->cp_clp = cstate->clp;
|
copy->cp_clp = cstate->clp;
|
||||||
if (nfsd4_ssc_is_inter(copy)) {
|
if (nfsd4_ssc_is_inter(copy)) {
|
||||||
|
@ -1783,8 +1778,6 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
|
||||||
memcpy(©->fh, &cstate->current_fh.fh_handle,
|
memcpy(©->fh, &cstate->current_fh.fh_handle,
|
||||||
sizeof(struct knfsd_fh));
|
sizeof(struct knfsd_fh));
|
||||||
if (nfsd4_copy_is_async(copy)) {
|
if (nfsd4_copy_is_async(copy)) {
|
||||||
struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id);
|
|
||||||
|
|
||||||
status = nfserrno(-ENOMEM);
|
status = nfserrno(-ENOMEM);
|
||||||
async_copy = kzalloc(sizeof(struct nfsd4_copy), GFP_KERNEL);
|
async_copy = kzalloc(sizeof(struct nfsd4_copy), GFP_KERNEL);
|
||||||
if (!async_copy)
|
if (!async_copy)
|
||||||
|
@ -1796,8 +1789,8 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
|
||||||
goto out_err;
|
goto out_err;
|
||||||
if (!nfs4_init_copy_state(nn, copy))
|
if (!nfs4_init_copy_state(nn, copy))
|
||||||
goto out_err;
|
goto out_err;
|
||||||
memcpy(©->cp_res.cb_stateid, ©->cp_stateid.cs_stid,
|
memcpy(&result->cb_stateid, ©->cp_stateid.cs_stid,
|
||||||
sizeof(copy->cp_res.cb_stateid));
|
sizeof(result->cb_stateid));
|
||||||
dup_copy_fields(copy, async_copy);
|
dup_copy_fields(copy, async_copy);
|
||||||
async_copy->copy_task = kthread_create(nfsd4_do_async_copy,
|
async_copy->copy_task = kthread_create(nfsd4_do_async_copy,
|
||||||
async_copy, "%s", "copy thread");
|
async_copy, "%s", "copy thread");
|
||||||
|
|
Loading…
Add table
Reference in a new issue