From: Jeff Layton <jlayton@kernel.org>
To: Chuck Lever <cel@kernel.org>, linux-nfs@vger.kernel.org
Subject: Re: [PATCH 2 03/14] NFSD: Reschedule CB operations when backchannel rpc_clnt is shut down
Date: Fri, 26 Jan 2024 14:10:25 -0500 [thread overview]
Message-ID: <69d2f87b79a31d322316b421fa24f98ab547041f.camel@kernel.org> (raw)
In-Reply-To: <170629112969.20612.8526400738389878628.stgit@manet.1015granger.net>
On Fri, 2024-01-26 at 12:45 -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 | 32 +++++++++++++++++++++++---------
> 1 file changed, 23 insertions(+), 9 deletions(-)
>
> diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c
> index 1ed2512b3648..389d05985c52 100644
> --- a/fs/nfsd/nfs4callback.c
> +++ b/fs/nfsd/nfs4callback.c
> @@ -890,6 +890,13 @@ static bool nfsd4_queue_cb(struct nfsd4_callback *cb)
> return queue_delayed_work(callback_wq, &cb->cb_work, 0);
> }
>
> +static void nfsd4_queue_cb_delayed(struct nfsd4_callback *cb,
> + unsigned long msecs)
> +{
> + queue_delayed_work(callback_wq, &cb->cb_work,
> + msecs_to_jiffies(msecs));
> +}
> +
> static void nfsd41_cb_inflight_begin(struct nfs4_client *clp)
> {
> atomic_inc(&clp->cl_cb_inflight);
> @@ -1375,20 +1382,21 @@ 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 could wait for the client to
> + * reconnect, but I haven't figured out how
> + * to do that yet.
> + */
> + nfsd4_queue_cb_delayed(cb, 25);
> + }
> return;
> }
>
> @@ -1401,6 +1409,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,
>
>
>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
next prev parent reply other threads:[~2024-01-26 19:10 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-26 17:45 [PATCH 2 00/14] NFSD backchannel fixes Chuck Lever
2024-01-26 17:45 ` [PATCH 2 01/14] NFSD: Reset cb_seq_status after NFS4ERR_DELAY Chuck Lever
2024-01-26 17:45 ` [PATCH 2 02/14] NFSD: Convert the callback workqueue to use delayed_work Chuck Lever
2024-01-26 19:09 ` Jeff Layton
2024-01-26 17:45 ` [PATCH 2 03/14] NFSD: Reschedule CB operations when backchannel rpc_clnt is shut down Chuck Lever
2024-01-26 19:10 ` Jeff Layton [this message]
2024-01-26 17:45 ` [PATCH 2 04/14] NFSD: Retransmit callbacks after client reconnects Chuck Lever
2024-01-26 17:45 ` [PATCH 2 05/14] NFSD: Add nfsd_seq4_status trace event Chuck Lever
2024-01-26 17:45 ` [PATCH 2 06/14] NFSD: Replace dprintks in nfsd4_cb_sequence_done() Chuck Lever
2024-01-26 17:45 ` [PATCH 2 07/14] NFSD: Rename nfsd_cb_state trace point Chuck Lever
2024-01-26 17:46 ` [PATCH 2 08/14] NFSD: Add callback operation lifetime trace points Chuck Lever
2024-01-26 17:46 ` [PATCH 2 09/14] SUNRPC: Remove EXPORT_SYMBOL_GPL for svc_process_bc() Chuck Lever
2024-01-26 17:46 ` [PATCH 2 10/14] NFSD: Remove unused @reason argument Chuck Lever
2024-01-26 17:46 ` [PATCH 2 11/14] NFSD: Replace comment with lockdep assertion Chuck Lever
2024-01-26 17:46 ` [PATCH 2 12/14] NFSD: Remove BUG_ON in nfsd4_process_cb_update() Chuck Lever
2024-01-26 17:46 ` [PATCH 2 13/14] SUNRPC: Remove stale comments Chuck Lever
2024-01-26 17:46 ` [PATCH 2 14/14] NFSD: Remove redundant cb_seq_status initialization Chuck Lever
2024-01-26 20:10 ` [PATCH 2 00/14] NFSD backchannel fixes 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=69d2f87b79a31d322316b421fa24f98ab547041f.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