Skip to content

Commit e72f9bc

Browse files
committed
NFSD: Add nfsd4_send_cb_offload()
Refactor for legibility. Signed-off-by: Chuck Lever <[email protected]>
1 parent ad1e46c commit e72f9bc

File tree

1 file changed

+22
-15
lines changed

1 file changed

+22
-15
lines changed

fs/nfsd/nfs4proc.c

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1763,6 +1763,27 @@ static void cleanup_async_copy(struct nfsd4_copy *copy)
17631763
nfs4_put_copy(copy);
17641764
}
17651765

1766+
static void nfsd4_send_cb_offload(struct nfsd4_copy *copy)
1767+
{
1768+
struct nfsd4_copy *cb_copy;
1769+
1770+
cb_copy = kzalloc(sizeof(struct nfsd4_copy), GFP_KERNEL);
1771+
if (!cb_copy)
1772+
return;
1773+
1774+
refcount_set(&cb_copy->refcount, 1);
1775+
memcpy(&cb_copy->cp_res, &copy->cp_res, sizeof(copy->cp_res));
1776+
cb_copy->cp_clp = copy->cp_clp;
1777+
cb_copy->nfserr = copy->nfserr;
1778+
memcpy(&cb_copy->fh, &copy->fh, sizeof(copy->fh));
1779+
1780+
nfsd4_init_cb(&cb_copy->cp_cb, cb_copy->cp_clp,
1781+
&nfsd4_cb_offload_ops, NFSPROC4_CLNT_CB_OFFLOAD);
1782+
trace_nfsd_cb_offload(copy->cp_clp, &copy->cp_res.cb_stateid,
1783+
&copy->fh, copy->cp_count, copy->nfserr);
1784+
nfsd4_run_cb(&cb_copy->cp_cb);
1785+
}
1786+
17661787
/**
17671788
* nfsd4_do_async_copy - kthread function for background server-side COPY
17681789
* @data: arguments for COPY operation
@@ -1773,7 +1794,6 @@ static void cleanup_async_copy(struct nfsd4_copy *copy)
17731794
static int nfsd4_do_async_copy(void *data)
17741795
{
17751796
struct nfsd4_copy *copy = (struct nfsd4_copy *)data;
1776-
struct nfsd4_copy *cb_copy;
17771797

17781798
if (nfsd4_ssc_is_inter(copy)) {
17791799
struct file *filp;
@@ -1795,20 +1815,7 @@ static int nfsd4_do_async_copy(void *data)
17951815
}
17961816

17971817
do_callback:
1798-
cb_copy = kzalloc(sizeof(struct nfsd4_copy), GFP_KERNEL);
1799-
if (!cb_copy)
1800-
goto out;
1801-
refcount_set(&cb_copy->refcount, 1);
1802-
memcpy(&cb_copy->cp_res, &copy->cp_res, sizeof(copy->cp_res));
1803-
cb_copy->cp_clp = copy->cp_clp;
1804-
cb_copy->nfserr = copy->nfserr;
1805-
memcpy(&cb_copy->fh, &copy->fh, sizeof(copy->fh));
1806-
nfsd4_init_cb(&cb_copy->cp_cb, cb_copy->cp_clp,
1807-
&nfsd4_cb_offload_ops, NFSPROC4_CLNT_CB_OFFLOAD);
1808-
trace_nfsd_cb_offload(copy->cp_clp, &copy->cp_res.cb_stateid,
1809-
&copy->fh, copy->cp_count, copy->nfserr);
1810-
nfsd4_run_cb(&cb_copy->cp_cb);
1811-
out:
1818+
nfsd4_send_cb_offload(copy);
18121819
cleanup_async_copy(copy);
18131820
return 0;
18141821
}

0 commit comments

Comments
 (0)