Skip to content

Commit 9ed666e

Browse files
committed
NFSD: Async COPY result needs to return a write verifier
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 <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
1 parent 15392c8 commit 9ed666e

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

fs/nfsd/nfs4proc.c

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -752,15 +752,6 @@ nfsd4_access(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
752752
&access->ac_supported);
753753
}
754754

755-
static void gen_boot_verifier(nfs4_verifier *verifier, struct net *net)
756-
{
757-
__be32 *verf = (__be32 *)verifier->data;
758-
759-
BUILD_BUG_ON(2*sizeof(*verf) != sizeof(verifier->data));
760-
761-
nfsd_copy_write_verifier(verf, net_generic(net, nfsd_net_id));
762-
}
763-
764755
static __be32
765756
nfsd4_commit(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
766757
union nfsd4_op_u *u)
@@ -1632,7 +1623,6 @@ static void nfsd4_init_copy_res(struct nfsd4_copy *copy, bool sync)
16321623
test_bit(NFSD4_COPY_F_COMMITTED, &copy->cp_flags) ?
16331624
NFS_FILE_SYNC : NFS_UNSTABLE;
16341625
nfsd4_copy_set_sync(copy, sync);
1635-
gen_boot_verifier(&copy->cp_res.wr_verifier, copy->cp_clp->net);
16361626
}
16371627

16381628
static ssize_t _nfsd_copy_file_range(struct nfsd4_copy *copy,
@@ -1805,9 +1795,11 @@ static __be32
18051795
nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
18061796
union nfsd4_op_u *u)
18071797
{
1798+
struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id);
1799+
struct nfsd4_copy *async_copy = NULL;
18081800
struct nfsd4_copy *copy = &u->copy;
1801+
struct nfsd42_write_res *result;
18091802
__be32 status;
1810-
struct nfsd4_copy *async_copy = NULL;
18111803

18121804
/*
18131805
* Currently, async COPY is not reliable. Force all COPY
@@ -1816,6 +1808,9 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
18161808
*/
18171809
nfsd4_copy_set_sync(copy, true);
18181810

1811+
result = &copy->cp_res;
1812+
nfsd_copy_write_verifier((__be32 *)&result->wr_verifier.data, nn);
1813+
18191814
copy->cp_clp = cstate->clp;
18201815
if (nfsd4_ssc_is_inter(copy)) {
18211816
trace_nfsd_copy_inter(copy);
@@ -1840,8 +1835,6 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
18401835
memcpy(&copy->fh, &cstate->current_fh.fh_handle,
18411836
sizeof(struct knfsd_fh));
18421837
if (nfsd4_copy_is_async(copy)) {
1843-
struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id);
1844-
18451838
status = nfserrno(-ENOMEM);
18461839
async_copy = kzalloc(sizeof(struct nfsd4_copy), GFP_KERNEL);
18471840
if (!async_copy)
@@ -1853,8 +1846,8 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
18531846
goto out_err;
18541847
if (!nfs4_init_copy_state(nn, copy))
18551848
goto out_err;
1856-
memcpy(&copy->cp_res.cb_stateid, &copy->cp_stateid.cs_stid,
1857-
sizeof(copy->cp_res.cb_stateid));
1849+
memcpy(&result->cb_stateid, &copy->cp_stateid.cs_stid,
1850+
sizeof(result->cb_stateid));
18581851
dup_copy_fields(copy, async_copy);
18591852
async_copy->copy_task = kthread_create(nfsd4_do_async_copy,
18601853
async_copy, "%s", "copy thread");

0 commit comments

Comments
 (0)