Skip to content

Commit ad1e46c

Browse files
committed
NFSD: Remove kmalloc from nfsd4_do_async_copy()
Instead of manufacturing a phony struct nfsd_file, pass the struct file returned by nfs42_ssc_open() directly to nfsd4_do_copy(). Signed-off-by: Chuck Lever <[email protected]>
1 parent 3b7bf59 commit ad1e46c

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

fs/nfsd/nfs4proc.c

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

1766+
/**
1767+
* nfsd4_do_async_copy - kthread function for background server-side COPY
1768+
* @data: arguments for COPY operation
1769+
*
1770+
* Return values:
1771+
* %0: Copy operation is done.
1772+
*/
17661773
static int nfsd4_do_async_copy(void *data)
17671774
{
17681775
struct nfsd4_copy *copy = (struct nfsd4_copy *)data;
17691776
struct nfsd4_copy *cb_copy;
17701777

17711778
if (nfsd4_ssc_is_inter(copy)) {
1772-
copy->nf_src = kzalloc(sizeof(struct nfsd_file), GFP_KERNEL);
1773-
if (!copy->nf_src) {
1774-
copy->nfserr = nfserr_serverfault;
1775-
nfsd4_interssc_disconnect(copy->ss_mnt);
1776-
goto do_callback;
1777-
}
1778-
copy->nf_src->nf_file = nfs42_ssc_open(copy->ss_mnt, &copy->c_fh,
1779-
&copy->stateid);
1780-
if (IS_ERR(copy->nf_src->nf_file)) {
1779+
struct file *filp;
1780+
1781+
filp = nfs42_ssc_open(copy->ss_mnt, &copy->c_fh,
1782+
&copy->stateid);
1783+
if (IS_ERR(filp)) {
17811784
copy->nfserr = nfserr_offload_denied;
17821785
nfsd4_interssc_disconnect(copy->ss_mnt);
17831786
goto do_callback;
17841787
}
1785-
copy->nfserr = nfsd4_do_copy(copy, copy->nf_src->nf_file,
1788+
copy->nfserr = nfsd4_do_copy(copy, filp,
17861789
copy->nf_dst->nf_file, false);
1787-
nfsd4_cleanup_inter_ssc(copy->ss_mnt, copy->nf_src->nf_file,
1788-
copy->nf_dst);
1790+
nfsd4_cleanup_inter_ssc(copy->ss_mnt, filp, copy->nf_dst);
17891791
} else {
17901792
copy->nfserr = nfsd4_do_copy(copy, copy->nf_src->nf_file,
17911793
copy->nf_dst->nf_file, false);
@@ -1807,8 +1809,6 @@ static int nfsd4_do_async_copy(void *data)
18071809
&copy->fh, copy->cp_count, copy->nfserr);
18081810
nfsd4_run_cb(&cb_copy->cp_cb);
18091811
out:
1810-
if (nfsd4_ssc_is_inter(copy))
1811-
kfree(copy->nf_src);
18121812
cleanup_async_copy(copy);
18131813
return 0;
18141814
}

0 commit comments

Comments
 (0)