Commit 3b7bf593 authored by Chuck Lever's avatar Chuck Lever

NFSD: Refactor nfsd4_do_copy()

Refactor: Now that nfsd4_do_copy() no longer calls the cleanup
helpers, plumb the use of struct file pointers all the way down to
_nfsd_copy_file_range().
Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
parent 478ed7b1
...@@ -1670,10 +1670,10 @@ static void nfsd4_init_copy_res(struct nfsd4_copy *copy, bool sync) ...@@ -1670,10 +1670,10 @@ static void nfsd4_init_copy_res(struct nfsd4_copy *copy, bool sync)
gen_boot_verifier(&copy->cp_res.wr_verifier, copy->cp_clp->net); gen_boot_verifier(&copy->cp_res.wr_verifier, copy->cp_clp->net);
} }
static ssize_t _nfsd_copy_file_range(struct nfsd4_copy *copy) static ssize_t _nfsd_copy_file_range(struct nfsd4_copy *copy,
struct file *dst,
struct file *src)
{ {
struct file *dst = copy->nf_dst->nf_file;
struct file *src = copy->nf_src->nf_file;
errseq_t since; errseq_t since;
ssize_t bytes_copied = 0; ssize_t bytes_copied = 0;
u64 bytes_total = copy->cp_count; u64 bytes_total = copy->cp_count;
...@@ -1709,12 +1709,15 @@ static ssize_t _nfsd_copy_file_range(struct nfsd4_copy *copy) ...@@ -1709,12 +1709,15 @@ static ssize_t _nfsd_copy_file_range(struct nfsd4_copy *copy)
return bytes_copied; return bytes_copied;
} }
static __be32 nfsd4_do_copy(struct nfsd4_copy *copy, bool sync) static __be32 nfsd4_do_copy(struct nfsd4_copy *copy,
struct file *src, struct file *dst,
bool sync)
{ {
__be32 status; __be32 status;
ssize_t bytes; ssize_t bytes;
bytes = _nfsd_copy_file_range(copy); bytes = _nfsd_copy_file_range(copy, dst, src);
/* for async copy, we ignore the error, client can always retry /* for async copy, we ignore the error, client can always retry
* to get the error * to get the error
*/ */
...@@ -1779,11 +1782,13 @@ static int nfsd4_do_async_copy(void *data) ...@@ -1779,11 +1782,13 @@ static int nfsd4_do_async_copy(void *data)
nfsd4_interssc_disconnect(copy->ss_mnt); nfsd4_interssc_disconnect(copy->ss_mnt);
goto do_callback; goto do_callback;
} }
copy->nfserr = nfsd4_do_copy(copy, 0); copy->nfserr = nfsd4_do_copy(copy, copy->nf_src->nf_file,
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, copy->nf_src->nf_file,
copy->nf_dst); copy->nf_dst);
} else { } else {
copy->nfserr = nfsd4_do_copy(copy, 0); copy->nfserr = nfsd4_do_copy(copy, copy->nf_src->nf_file,
copy->nf_dst->nf_file, false);
nfsd4_cleanup_intra_ssc(copy->nf_src, copy->nf_dst); nfsd4_cleanup_intra_ssc(copy->nf_src, copy->nf_dst);
} }
...@@ -1861,7 +1866,8 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, ...@@ -1861,7 +1866,8 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
wake_up_process(async_copy->copy_task); wake_up_process(async_copy->copy_task);
status = nfs_ok; status = nfs_ok;
} else { } else {
status = nfsd4_do_copy(copy, 1); status = nfsd4_do_copy(copy, copy->nf_src->nf_file,
copy->nf_dst->nf_file, true);
nfsd4_cleanup_intra_ssc(copy->nf_src, copy->nf_dst); nfsd4_cleanup_intra_ssc(copy->nf_src, copy->nf_dst);
} }
out: out:
......
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