Skip to content

Commit 409d6f5

Browse files
committed
NFSD: Free async copy information in nfsd4_cb_offload_release()
RFC 7862 Section 4.8 states: > A copy offload stateid will be valid until either (A) the client > or server restarts or (B) the client returns the resource by > issuing an OFFLOAD_CANCEL operation or the client replies to a > CB_OFFLOAD operation. Currently, NFSD purges the metadata for an async COPY operation as soon as the CB_OFFLOAD callback has been sent. It does not wait even for the client's CB_OFFLOAD response, as the paragraph above suggests that it should. This makes the OFFLOAD_STATUS operation ineffective during the window between the completion of an asynchronous COPY and the server's receipt of the corresponding CB_OFFLOAD response. This is important if, for example, the client responds with NFS4ERR_DELAY, or the transport is lost before the server receives the response. A client might use OFFLOAD_STATUS to query the server about the still pending asynchronous COPY, but NFSD will respond to OFFLOAD_STATUS as if it had never heard of the presented copy stateid. This patch starts to address this issue by extending the lifetime of struct nfsd4_copy at least until the server has seen the client's CB_OFFLOAD response, or the CB_OFFLOAD has timed out. Reviewed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
1 parent 62a8642 commit 409d6f5

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

fs/nfsd/nfs4proc.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ module_param(inter_copy_offload_enable, bool, 0644);
5757
MODULE_PARM_DESC(inter_copy_offload_enable,
5858
"Enable inter server to server copy offload. Default: false");
5959

60+
static void cleanup_async_copy(struct nfsd4_copy *copy);
61+
6062
#ifdef CONFIG_NFSD_V4_2_INTER_SSC
6163
static int nfsd4_ssc_umount_timeout = 900000; /* default to 15 mins */
6264
module_param(nfsd4_ssc_umount_timeout, int, 0644);
@@ -1602,8 +1604,10 @@ static void nfsd4_cb_offload_release(struct nfsd4_callback *cb)
16021604
{
16031605
struct nfsd4_cb_offload *cbo =
16041606
container_of(cb, struct nfsd4_cb_offload, co_cb);
1607+
struct nfsd4_copy *copy =
1608+
container_of(cbo, struct nfsd4_copy, cp_cb_offload);
16051609

1606-
kfree(cbo);
1610+
cleanup_async_copy(copy);
16071611
}
16081612

16091613
static int nfsd4_cb_offload_done(struct nfsd4_callback *cb,
@@ -1736,11 +1740,7 @@ static void cleanup_async_copy(struct nfsd4_copy *copy)
17361740

17371741
static void nfsd4_send_cb_offload(struct nfsd4_copy *copy)
17381742
{
1739-
struct nfsd4_cb_offload *cbo;
1740-
1741-
cbo = kzalloc(sizeof(*cbo), GFP_KERNEL);
1742-
if (!cbo)
1743-
return;
1743+
struct nfsd4_cb_offload *cbo = &copy->cp_cb_offload;
17441744

17451745
memcpy(&cbo->co_res, &copy->cp_res, sizeof(copy->cp_res));
17461746
memcpy(&cbo->co_fh, &copy->fh, sizeof(copy->fh));
@@ -1790,10 +1790,13 @@ static int nfsd4_do_async_copy(void *data)
17901790
}
17911791

17921792
do_callback:
1793+
/* The kthread exits forthwith. Ensure that a subsequent
1794+
* OFFLOAD_CANCEL won't try to kill it again. */
1795+
set_bit(NFSD4_COPY_F_STOPPED, &copy->cp_flags);
1796+
17931797
set_bit(NFSD4_COPY_F_COMPLETED, &copy->cp_flags);
17941798
trace_nfsd_copy_async_done(copy);
17951799
nfsd4_send_cb_offload(copy);
1796-
cleanup_async_copy(copy);
17971800
return 0;
17981801
}
17991802

fs/nfsd/xdr4.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,9 @@ struct nfsd4_copy {
700700
struct nfsd42_write_res cp_res;
701701
struct knfsd_fh fh;
702702

703+
/* offload callback */
704+
struct nfsd4_cb_offload cp_cb_offload;
705+
703706
struct nfs4_client *cp_clp;
704707

705708
struct nfsd_file *nf_src;

0 commit comments

Comments
 (0)