public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Chuck Lever <chuck.lever@oracle.com>
To: Benjamin Coddington <bcodding@redhat.com>, cel@kernel.org
Cc: Neil Brown <neilb@suse.de>, Jeff Layton <jlayton@kernel.org>,
	Olga Kornievskaia <okorniev@redhat.com>,
	Dai Ngo <dai.ngo@oracle.com>, Tom Talpey <tom@talpey.com>,
	linux-nfs@vger.kernel.org, Olga Kornievskaia <kolga@netapp.com>
Subject: Re: [PATCH v3 6/7] NFS: Use NFSv4.2's OFFLOAD_STATUS operation
Date: Mon, 13 Jan 2025 12:11:50 -0500	[thread overview]
Message-ID: <e13ff082-0cce-4768-bb6a-ddc38bc8211c@oracle.com> (raw)
In-Reply-To: <9D804462-55EC-4D75-A5A8-28C43AA86AAB@redhat.com>

On 1/13/25 11:51 AM, Benjamin Coddington wrote:
> On 13 Jan 2025, at 10:32, cel@kernel.org wrote:
> 
>> From: Chuck Lever <chuck.lever@oracle.com>
>>
>> We've found that there are cases where a transport disconnection
>> results in the loss of callback RPCs. NFS servers typically do not
>> retransmit callback operations after a disconnect.
>>
>> This can be a problem for the Linux NFS client's current
>> implementation of asynchronous COPY, which waits indefinitely for a
>> CB_OFFLOAD callback. If a transport disconnect occurs while an async
>> COPY is running, there's a good chance the client will never get the
>> completing CB_OFFLOAD.
>>
>> Fix this by implementing the OFFLOAD_STATUS operation so that the
>> Linux NFS client can probe the NFS server if it doesn't see a
>> CB_OFFLOAD in a reasonable amount of time.
>>
>> This patch implements a simplistic check. As future work, the client
>> might also be able to detect whether there is no forward progress on
>> the request asynchronous COPY operation, and CANCEL it.
>>
>> Suggested-by: Olga Kornievskaia <kolga@netapp.com>
>> Link: https://bugzilla.kernel.org/show_bug.cgi?id=218735
>> Reviewed-by: Jeff Layton <jlayton@kernel.org>
>> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
>> ---
>>   fs/nfs/nfs42proc.c | 70 ++++++++++++++++++++++++++++++++++++++--------
>>   1 file changed, 59 insertions(+), 11 deletions(-)
>>
>> diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c
>> index 23508669d051..4baa66cd966a 100644
>> --- a/fs/nfs/nfs42proc.c
>> +++ b/fs/nfs/nfs42proc.c
>> @@ -175,6 +175,20 @@ int nfs42_proc_deallocate(struct file *filep, loff_t offset, loff_t len)
>>   	return err;
>>   }
>>
>> +static void nfs4_copy_dequeue_callback(struct nfs_server *dst_server,
>> +				       struct nfs_server *src_server,
>> +				       struct nfs4_copy_state *copy)
>> +{
>> +	spin_lock(&dst_server->nfs_client->cl_lock);
>> +	list_del_init(&copy->copies);
>> +	spin_unlock(&dst_server->nfs_client->cl_lock);
>> +	if (dst_server != src_server) {
>> +		spin_lock(&src_server->nfs_client->cl_lock);
>> +		list_del_init(&copy->src_copies);
>> +		spin_unlock(&src_server->nfs_client->cl_lock);
>> +	}
>> +}
>> +
>>   static int handle_async_copy(struct nfs42_copy_res *res,
>>   			     struct nfs_server *dst_server,
>>   			     struct nfs_server *src_server,
>> @@ -184,9 +198,12 @@ static int handle_async_copy(struct nfs42_copy_res *res,
>>   			     bool *restart)
>>   {
>>   	struct nfs4_copy_state *copy, *tmp_copy = NULL, *iter;
>> -	int status = NFS4_OK;
>>   	struct nfs_open_context *dst_ctx = nfs_file_open_context(dst);
>>   	struct nfs_open_context *src_ctx = nfs_file_open_context(src);
>> +	struct nfs_client *clp = dst_server->nfs_client;
>> +	unsigned long timeout = 3 * HZ;
>> +	int status = NFS4_OK;
>> +	u64 copied;
>>
>>   	copy = kzalloc(sizeof(struct nfs4_copy_state), GFP_KERNEL);
>>   	if (!copy)
>> @@ -224,15 +241,12 @@ static int handle_async_copy(struct nfs42_copy_res *res,
>>   		spin_unlock(&src_server->nfs_client->cl_lock);
>>   	}
>>
>> -	status = wait_for_completion_interruptible(&copy->completion);
>> -	spin_lock(&dst_server->nfs_client->cl_lock);
>> -	list_del_init(&copy->copies);
>> -	spin_unlock(&dst_server->nfs_client->cl_lock);
>> -	if (dst_server != src_server) {
>> -		spin_lock(&src_server->nfs_client->cl_lock);
>> -		list_del_init(&copy->src_copies);
>> -		spin_unlock(&src_server->nfs_client->cl_lock);
>> -	}
>> +wait:
>> +	status = wait_for_completion_interruptible_timeout(&copy->completion,
>> +							   timeout);
>> +	if (!status)
>> +		goto timeout;
>> +	nfs4_copy_dequeue_callback(dst_server, src_server, copy);
>>   	if (status == -ERESTARTSYS) {
>>   		goto out_cancel;
>>   	} else if (copy->flags || copy->error == NFS4ERR_PARTNER_NO_AUTH) {
>> @@ -242,6 +256,7 @@ static int handle_async_copy(struct nfs42_copy_res *res,
>>   	}
>>   out:
>>   	res->write_res.count = copy->count;
>> +	/* Copy out the updated write verifier provided by CB_OFFLOAD. */
>>   	memcpy(&res->write_res.verifier, &copy->verf, sizeof(copy->verf));
>>   	status = -copy->error;
>>
>> @@ -253,6 +268,39 @@ static int handle_async_copy(struct nfs42_copy_res *res,
>>   	if (!nfs42_files_from_same_server(src, dst))
>>   		nfs42_do_offload_cancel_async(src, src_stateid);
>>   	goto out_free;
>> +timeout:
>> +	timeout <<= 1;
>> +	if (timeout > (clp->cl_lease_time >> 1))
>> +		timeout = clp->cl_lease_time >> 1;
>> +	status = nfs42_proc_offload_status(dst, &copy->stateid, &copied);
>> +	if (status == -EINPROGRESS)
>> +		goto wait;
>> +	nfs4_copy_dequeue_callback(dst_server, src_server, copy);
>> +	switch (status) {
>> +	case 0:
>> +		/* The server recognized the copy stateid, so it hasn't
>> +		 * rebooted. Don't overwrite the verifier returned in the
>> +		 * COPY result. */
>> +		res->write_res.count = copied;
>> +		goto out_free;
>> +	case -EREMOTEIO:
>> +		/* COPY operation failed on the server. */
>> +		status = -EOPNOTSUPP;
>> +		res->write_res.count = copied;
> 
> I think "copied" can be the original uninitialized stack var in this path,
> is that a problem?

I think you mean in the rare case when the /server/ returns REMOTEIO?

I changed nfs42_proc_offload_status() so that it now always initializes
@copied.

Thanks for your review!


> Ben
> 
>> +		goto out_free;
>> +	case -EBADF:
>> +		/* Server did not recognize the copy stateid. It has
>> +		 * probably restarted and lost the plot. */
>> +		res->write_res.count = 0;
>> +		status = -EOPNOTSUPP;
>> +		break;
>> +	case -EOPNOTSUPP:
>> +		/* RFC 7862 REQUIREs server to support OFFLOAD_STATUS when
>> +		 * it has signed up for an async COPY, so server is not
>> +		 * spec-compliant. */
>> +		res->write_res.count = 0;
>> +	}
>> +	goto out_free;
>>   }
>>
>>   static int process_copy_commit(struct file *dst, loff_t pos_dst,
>> @@ -643,7 +691,7 @@ _nfs42_proc_offload_status(struct nfs_server *server, struct file *file,
>>    * Other negative errnos indicate the client could not complete the
>>    * request.
>>    */
>> -static int __maybe_unused
>> +static int
>>   nfs42_proc_offload_status(struct file *dst, nfs4_stateid *stateid, u64 *copied)
>>   {
>>   	struct inode *inode = file_inode(dst);
>> -- 
>> 2.47.0
> 


-- 
Chuck Lever

  reply	other threads:[~2025-01-13 17:12 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-13 15:32 [PATCH v3 0/7] Client-side OFFLOAD_STATUS implementation cel
2025-01-13 15:32 ` [PATCH v3 1/7] NFS: CB_OFFLOAD can return NFS4ERR_DELAY cel
2025-01-13 15:32 ` [PATCH v3 2/7] NFS: Fix typo in OFFLOAD_CANCEL comment cel
2025-01-13 15:32 ` [PATCH v3 3/7] NFS: Rename struct nfs4_offloadcancel_data cel
2025-01-13 15:32 ` [PATCH v3 4/7] NFS: Implement NFSv4.2's OFFLOAD_STATUS XDR cel
2025-01-13 15:32 ` [PATCH v3 5/7] NFS: Implement NFSv4.2's OFFLOAD_STATUS operation cel
2025-01-13 15:32 ` [PATCH v3 6/7] NFS: Use " cel
2025-01-13 16:51   ` Benjamin Coddington
2025-01-13 17:11     ` Chuck Lever [this message]
2025-01-13 15:32 ` [PATCH v3 7/7] NFS: Refactor trace_nfs4_offload_cancel cel
2025-01-13 16:52 ` [PATCH v3 0/7] Client-side OFFLOAD_STATUS implementation Benjamin Coddington

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e13ff082-0cce-4768-bb6a-ddc38bc8211c@oracle.com \
    --to=chuck.lever@oracle.com \
    --cc=bcodding@redhat.com \
    --cc=cel@kernel.org \
    --cc=dai.ngo@oracle.com \
    --cc=jlayton@kernel.org \
    --cc=kolga@netapp.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=neilb@suse.de \
    --cc=okorniev@redhat.com \
    --cc=tom@talpey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox