Search the list for the asynchronous copy based on the stateid, then lookup the number of bytes copied so far. Signed-off-by: Olga Kornievskaia <kolga@xxxxxxxxxx> --- fs/nfsd/nfs4proc.c | 44 ++++++++++++++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index 3d190b3..57d0daa 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -1291,28 +1291,36 @@ static int nfsd4_do_async_copy(void *data) goto out; } -static __be32 -nfsd4_offload_cancel(struct svc_rqst *rqstp, - struct nfsd4_compound_state *cstate, - union nfsd4_op_u *u) +static struct nfsd4_copy * +find_async_copy(struct nfs4_client *clp, struct nfsd4_offload_status *os) { - struct nfsd4_offload_status *os = &u->offload_status; - __be32 status = 0; struct nfsd4_copy *copy; - bool found = false; - struct nfs4_client *clp = cstate->clp; spin_lock(&clp->async_lock); list_for_each_entry(copy, &clp->async_copies, copies) { if (memcmp(©->cps->cp_stateid, &os->stateid, NFS4_STATEID_SIZE)) continue; - found = true; refcount_inc(©->refcount); - break; + spin_unlock(&clp->async_lock); + return copy; } spin_unlock(&clp->async_lock); - if (found) { + return NULL; +} + +static __be32 +nfsd4_offload_cancel(struct svc_rqst *rqstp, + struct nfsd4_compound_state *cstate, + union nfsd4_op_u *u) +{ + struct nfsd4_offload_status *os = &u->offload_status; + __be32 status = 0; + struct nfsd4_copy *copy; + struct nfs4_client *clp = cstate->clp; + + copy = find_async_copy(clp, os); + if (copy) { set_tsk_thread_flag(copy->copy_task, TIF_SIGPENDING); kthread_stop(copy->copy_task); nfs4_put_copy(copy); @@ -1349,7 +1357,19 @@ static int nfsd4_do_async_copy(void *data) struct nfsd4_compound_state *cstate, union nfsd4_op_u *u) { - return nfserr_notsupp; + struct nfsd4_offload_status *os = &u->offload_status; + __be32 status = 0; + struct nfsd4_copy *copy; + struct nfs4_client *clp = cstate->clp; + + copy = find_async_copy(clp, os); + if (copy) { + os->count = copy->cp_res.wr_bytes_written; + nfs4_put_copy(copy); + } else + status = nfserr_bad_stateid; + + return status; } static __be32 -- 1.8.3.1 -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html