Search the list for the asynchronous copy based on the stateid, then query the inode for the file size. 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 6757387..78e25db 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -1297,28 +1297,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; atomic_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); @@ -1355,7 +1363,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 = i_size_read(file_inode(copy->fh_dst)); + 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