@@ -156,7 +156,7 @@ static int handle_async_copy(struct nfs42_copy_res *res,
struct file *src,
struct file *dst,
nfs4_stateid *src_stateid,
- uint64_t *ret_count)
+ uint64_t *ret_count, uint64_t count)
{
struct nfs4_copy_state *copy;
int status = NFS4_OK;
@@ -190,6 +190,24 @@ static int handle_async_copy(struct nfs42_copy_res *res,
list_add_tail(©->copies, &server->ss_copies);
spin_unlock(&server->nfs_client->cl_lock);
+ for (;;) {
+ struct nfs42_offload_status_res res = {
+ .osr_status = 0,
+ };
+
+ status = nfs42_proc_offload_status(dst, ©->stateid, &res);
+ if (status || res.osr_status) {
+ printk("AGLO: status=%d osr_status=%d\n", status, res.osr_status);
+ break;
+ }
+ if (res.osr_count == count) {
+ printk("AGLO: received all the bytes=%lld\n", count);
+ break;
+ } else {
+ printk("AGLO: bytes=%lld going to sleep for 100ms\n", res.osr_count);
+ msleep(100);
+ }
+ }
status = wait_for_completion_interruptible(©->completion);
spin_lock(&server->nfs_client->cl_lock);
list_del_init(©->copies);
@@ -310,7 +328,7 @@ static ssize_t _nfs42_proc_copy(struct file *src,
if (!res->synchronous) {
status = handle_async_copy(res, server, src, dst,
- &args->src_stateid, &res->write_res.count);
+ &args->src_stateid, &res->write_res.count, args->count);
if (status)
return status;
}