Commit ad1e46c9 authored by Chuck Lever's avatar Chuck Lever

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: default avatarChuck Lever <chuck.lever@oracle.com>
parent 3b7bf593
...@@ -1763,29 +1763,31 @@ static void cleanup_async_copy(struct nfsd4_copy *copy) ...@@ -1763,29 +1763,31 @@ static void cleanup_async_copy(struct nfsd4_copy *copy)
nfs4_put_copy(copy); nfs4_put_copy(copy);
} }
/**
* nfsd4_do_async_copy - kthread function for background server-side COPY
* @data: arguments for COPY operation
*
* Return values:
* %0: Copy operation is done.
*/
static int nfsd4_do_async_copy(void *data) static int nfsd4_do_async_copy(void *data)
{ {
struct nfsd4_copy *copy = (struct nfsd4_copy *)data; struct nfsd4_copy *copy = (struct nfsd4_copy *)data;
struct nfsd4_copy *cb_copy; struct nfsd4_copy *cb_copy;
if (nfsd4_ssc_is_inter(copy)) { if (nfsd4_ssc_is_inter(copy)) {
copy->nf_src = kzalloc(sizeof(struct nfsd_file), GFP_KERNEL); struct file *filp;
if (!copy->nf_src) {
copy->nfserr = nfserr_serverfault; filp = nfs42_ssc_open(copy->ss_mnt, &copy->c_fh,
nfsd4_interssc_disconnect(copy->ss_mnt); &copy->stateid);
goto do_callback; if (IS_ERR(filp)) {
}
copy->nf_src->nf_file = nfs42_ssc_open(copy->ss_mnt, &copy->c_fh,
&copy->stateid);
if (IS_ERR(copy->nf_src->nf_file)) {
copy->nfserr = nfserr_offload_denied; copy->nfserr = nfserr_offload_denied;
nfsd4_interssc_disconnect(copy->ss_mnt); nfsd4_interssc_disconnect(copy->ss_mnt);
goto do_callback; goto do_callback;
} }
copy->nfserr = nfsd4_do_copy(copy, copy->nf_src->nf_file, copy->nfserr = nfsd4_do_copy(copy, filp,
copy->nf_dst->nf_file, false); copy->nf_dst->nf_file, false);
nfsd4_cleanup_inter_ssc(copy->ss_mnt, copy->nf_src->nf_file, nfsd4_cleanup_inter_ssc(copy->ss_mnt, filp, copy->nf_dst);
copy->nf_dst);
} else { } else {
copy->nfserr = nfsd4_do_copy(copy, copy->nf_src->nf_file, copy->nfserr = nfsd4_do_copy(copy, copy->nf_src->nf_file,
copy->nf_dst->nf_file, false); copy->nf_dst->nf_file, false);
...@@ -1807,8 +1809,6 @@ static int nfsd4_do_async_copy(void *data) ...@@ -1807,8 +1809,6 @@ static int nfsd4_do_async_copy(void *data)
&copy->fh, copy->cp_count, copy->nfserr); &copy->fh, copy->cp_count, copy->nfserr);
nfsd4_run_cb(&cb_copy->cp_cb); nfsd4_run_cb(&cb_copy->cp_cb);
out: out:
if (nfsd4_ssc_is_inter(copy))
kfree(copy->nf_src);
cleanup_async_copy(copy); cleanup_async_copy(copy);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment