Linux NFS development
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@kernel.org>
To: Chuck Lever <cel@kernel.org>, linux-nfs@vger.kernel.org
Subject: Re: [PATCH RFC 02/13] NFSD: Reschedule CB operations when backchannel rpc_clnt is shut down
Date: Thu, 25 Jan 2024 15:19:41 -0500	[thread overview]
Message-ID: <736b0c878f228e28e0ae18974efbddca17c1919f.camel@kernel.org> (raw)
In-Reply-To: <170620013252.2833.10156142379669175540.stgit@manet.1015granger.net>

On Thu, 2024-01-25 at 11:28 -0500, Chuck Lever wrote:
> From: Chuck Lever <chuck.lever@oracle.com>
> 
> As part of managing a client disconnect, NFSD closes down and
> replaces the backchannel rpc_clnt.
> 
> If a callback operation is pending when the backchannel rpc_clnt is
> shut down, currently nfsd4_run_cb_work() just discards that
> callback. But there are multiple cases to deal with here:
> 
>  o The client's lease is getting destroyed. Throw the CB away.
> 
>  o The client disconnected. It might be forcing a retransmit of
>    CB operations, or it could have disconnected for other reasons.
>    Reschedule the CB so it is retransmitted when the client
>    reconnects.
> 
> Since callback operations can now be rescheduled, ensure that
> cb_ops->prepare can be called only once by moving the
> cb_ops->prepare paragraph down to just before the rpc_call_async()
> call.
> 
> Fixes: 2bbfed98a4d8 ("nfsd: Fix races between nfsd4_cb_release() and nfsd4_shutdown_callback()")
> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
> ---
>  fs/nfsd/nfs4callback.c |   26 +++++++++++++++++---------
>  1 file changed, 17 insertions(+), 9 deletions(-)
> 
> diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c
> index 43b0a34a5d5b..b2844abcb51f 100644
> --- a/fs/nfsd/nfs4callback.c
> +++ b/fs/nfsd/nfs4callback.c
> @@ -1375,20 +1375,22 @@ nfsd4_run_cb_work(struct work_struct *work)
>  	struct rpc_clnt *clnt;
>  	int flags;
>  
> -	if (cb->cb_need_restart) {
> -		cb->cb_need_restart = false;
> -	} else {
> -		if (cb->cb_ops && cb->cb_ops->prepare)
> -			cb->cb_ops->prepare(cb);
> -	}
> -
>  	if (clp->cl_flags & NFSD4_CLIENT_CB_FLAG_MASK)
>  		nfsd4_process_cb_update(cb);
>  
>  	clnt = clp->cl_cb_client;
>  	if (!clnt) {
> -		/* Callback channel broken, or client killed; give up: */
> -		nfsd41_destroy_cb(cb);
> +		if (test_bit(NFSD4_CLIENT_CB_KILL, &clp->cl_flags))
> +			nfsd41_destroy_cb(cb);
> +		else {
> +			/*
> +			 * XXX: Ideally, we would wait for the client to
> +			 *	reconnect, but I haven't figured out how
> +			 *	to do that yet.
> +			 */
> +			msleep(30);
> +			nfsd4_queue_cb(cb);

It would probably be better to just queue the cb as delayed_work here,
so you don't squat on the workqueue thread. That'll mean changing
cb_work to struct delayed_work, but that should be NBD.

> +		}
>  		return;
>  	}
>  
> @@ -1401,6 +1403,12 @@ nfsd4_run_cb_work(struct work_struct *work)
>  		return;
>  	}
>  
> +	if (cb->cb_need_restart) {
> +		cb->cb_need_restart = false;
> +	} else {
> +		if (cb->cb_ops && cb->cb_ops->prepare)
> +			cb->cb_ops->prepare(cb);
> +	}
>  	cb->cb_msg.rpc_cred = clp->cl_cb_cred;
>  	flags = clp->cl_minorversion ? RPC_TASK_NOCONNECT : RPC_TASK_SOFTCONN;
>  	rpc_call_async(clnt, &cb->cb_msg, RPC_TASK_SOFT | flags,
> 
> 
> 

-- 
Jeff Layton <jlayton@kernel.org>

  reply	other threads:[~2024-01-25 20:19 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-25 16:28 [PATCH RFC 00/13] NFSD backchannel fixes Chuck Lever
2024-01-25 16:28 ` [PATCH RFC 01/13] NFSD: Reset cb_seq_status after NFS4ERR_DELAY Chuck Lever
2024-01-25 20:07   ` Jeff Layton
2024-01-25 16:28 ` [PATCH RFC 02/13] NFSD: Reschedule CB operations when backchannel rpc_clnt is shut down Chuck Lever
2024-01-25 20:19   ` Jeff Layton [this message]
2024-01-25 20:29     ` Chuck Lever
2024-01-25 16:28 ` [PATCH RFC 03/13] NFSD: Retransmit callbacks after client reconnects Chuck Lever
2024-01-25 20:24   ` Jeff Layton
2024-01-25 16:29 ` [PATCH RFC 04/13] NFSD: Add nfsd_seq4_status trace event Chuck Lever
2024-01-25 16:29 ` [PATCH RFC 05/13] NFSD: Replace dprintks in nfsd4_cb_sequence_done() Chuck Lever
2024-01-25 16:29 ` [PATCH RFC 06/13] NFSD: Rename nfsd_cb_state trace point Chuck Lever
2024-01-25 16:29 ` [PATCH RFC 07/13] NFSD: Add callback operation lifetime trace points Chuck Lever
2024-01-25 21:49   ` Benjamin Coddington
2024-01-26 14:12     ` Chuck Lever
2024-01-26 14:27       ` Benjamin Coddington
2024-01-25 16:29 ` [PATCH RFC 08/13] SUNRPC: Remove EXPORT_SYMBOL_GPL for svc_process_bc() Chuck Lever
2024-01-25 16:29 ` [PATCH RFC 09/13] NFSD: Remove unused @reason argument Chuck Lever
2024-01-25 16:29 ` [PATCH RFC 10/13] NFSD: Replace comment with lockdep assertion Chuck Lever
2024-01-25 16:29 ` [PATCH RFC 11/13] NFSD: Remove BUG_ON in nfsd4_process_cb_update() Chuck Lever
2024-01-25 16:29 ` [PATCH RFC 12/13] SUNRPC: Remove stale comments Chuck Lever
2024-01-25 16:30 ` [PATCH RFC 13/13] NFSD: Remove redundant cb_seq_status initialization Chuck Lever
2024-01-25 20:41 ` [PATCH RFC 00/13] NFSD backchannel fixes Jeff Layton
2024-01-25 22:09 ` Benjamin Coddington
2024-01-26 13:56   ` Chuck Lever III

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=736b0c878f228e28e0ae18974efbddca17c1919f.camel@kernel.org \
    --to=jlayton@kernel.org \
    --cc=cel@kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    /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