Linux-NFS Archive mirror
 help / color / mirror / Atom feed
From: Dai Ngo <dai.ngo@oracle.com>
To: chuck.lever@oracle.com, jlayton@kernel.org
Cc: linux-nfs@vger.kernel.org
Subject: [PATCH 1/1] NFSD: cancel CB_RECALL_ANY call when nfs4_client is about to be destroyed
Date: Tue, 26 Mar 2024 11:13:29 -0700	[thread overview]
Message-ID: <1711476809-26248-1-git-send-email-dai.ngo@oracle.com> (raw)

Currently when a nfs4_client is destroyed we wait for the cb_recall_any
callback to complete before proceed. This adds unnecessary delay to the
__destroy_client call if there is problem communicating with the client.

This patch addresses this issue by cancelling the CB_RECALL_ANY call from
the workqueue when the nfs4_client is about to be destroyed.

Signed-off-by: Dai Ngo <dai.ngo@oracle.com>
---
 fs/nfsd/nfs4callback.c | 10 ++++++++++
 fs/nfsd/nfs4state.c    | 10 +++++++++-
 fs/nfsd/state.h        |  1 +
 3 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c
index 87c9547989f6..e5b50c96be6a 100644
--- a/fs/nfsd/nfs4callback.c
+++ b/fs/nfsd/nfs4callback.c
@@ -1568,3 +1568,13 @@ bool nfsd4_run_cb(struct nfsd4_callback *cb)
 		nfsd41_cb_inflight_end(clp);
 	return queued;
 }
+
+void nfsd41_cb_recall_any_cancel(struct nfs4_client *clp)
+{
+	if (test_bit(NFSD4_CLIENT_CB_RECALL_ANY, &clp->cl_flags) &&
+			cancel_delayed_work(&clp->cl_ra->ra_cb.cb_work)) {
+		clear_bit(NFSD4_CLIENT_CB_RECALL_ANY, &clp->cl_flags);
+		atomic_add_unless(&clp->cl_rpc_users, -1, 0);
+		nfsd41_cb_inflight_end(clp);
+	}
+}
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 1a93c7fcf76c..0e1db57c9a19 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -2402,6 +2402,7 @@ __destroy_client(struct nfs4_client *clp)
 	}
 	nfsd4_return_all_client_layouts(clp);
 	nfsd4_shutdown_copy(clp);
+	nfsd41_cb_recall_any_cancel(clp);
 	nfsd4_shutdown_callback(clp);
 	if (clp->cl_cb_conn.cb_xprt)
 		svc_xprt_put(clp->cl_cb_conn.cb_xprt);
@@ -2980,6 +2981,12 @@ static void force_expire_client(struct nfs4_client *clp)
 	clp->cl_time = 0;
 	spin_unlock(&nn->client_lock);
 
+	/*
+	 * no need to send and wait for CB_RECALL_ANY
+	 * when client is about to be destroyed
+	 */
+	nfsd41_cb_recall_any_cancel(clp);
+
 	wait_event(expiry_wq, atomic_read(&clp->cl_rpc_users) == 0);
 	spin_lock(&nn->client_lock);
 	already_expired = list_empty(&clp->cl_lru);
@@ -6617,7 +6624,8 @@ deleg_reaper(struct nfsd_net *nn)
 		clp->cl_ra->ra_bmval[0] = BIT(RCA4_TYPE_MASK_RDATA_DLG) |
 						BIT(RCA4_TYPE_MASK_WDATA_DLG);
 		trace_nfsd_cb_recall_any(clp->cl_ra);
-		nfsd4_run_cb(&clp->cl_ra->ra_cb);
+		if (!nfsd4_run_cb(&clp->cl_ra->ra_cb))
+			clear_bit(NFSD4_CLIENT_CB_RECALL_ANY, &clp->cl_flags);
 	}
 }
 
diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h
index 01c6f3445646..259b4af7d226 100644
--- a/fs/nfsd/state.h
+++ b/fs/nfsd/state.h
@@ -735,6 +735,7 @@ extern void nfsd4_change_callback(struct nfs4_client *clp, struct nfs4_cb_conn *
 extern void nfsd4_init_cb(struct nfsd4_callback *cb, struct nfs4_client *clp,
 		const struct nfsd4_callback_ops *ops, enum nfsd4_cb_op op);
 extern bool nfsd4_run_cb(struct nfsd4_callback *cb);
+extern void nfsd41_cb_recall_any_cancel(struct nfs4_client *clp);
 extern int nfsd4_create_callback_queue(void);
 extern void nfsd4_destroy_callback_queue(void);
 extern void nfsd4_shutdown_callback(struct nfs4_client *);
-- 
2.39.3


             reply	other threads:[~2024-03-26 18:13 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-26 18:13 Dai Ngo [this message]
2024-03-26 18:27 ` [PATCH 1/1] NFSD: cancel CB_RECALL_ANY call when nfs4_client is about to be destroyed Chuck Lever
2024-03-28  1:09   ` Dai Ngo
2024-03-28 14:08     ` Chuck Lever
2024-03-28 18:14       ` Dai Ngo
2024-03-29  0:31         ` Dai Ngo
2024-03-29 14:55           ` Chuck Lever
2024-03-29 17:57             ` Dai Ngo
2024-03-29 23:42               ` Chuck Lever
2024-03-30 17:46                 ` Dai Ngo
2024-03-30 18:28                   ` Chuck Lever
2024-03-30 23:30                     ` Dai Ngo
2024-04-01 12:49                       ` Jeff Layton
2024-04-01 13:34                         ` Chuck Lever
2024-04-01 16:00                           ` Dai Ngo
2024-04-01 16:46                             ` Dai Ngo
2024-04-01 17:49                               ` Chuck Lever
2024-04-01 19:55                                 ` Dai Ngo
2024-04-01 20:17                                   ` Dai Ngo
2024-04-02 13:58                                   ` Chuck Lever
2024-04-02 14:29                                     ` Dai Ngo
2024-04-01 16:11                           ` Jeff Layton

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=1711476809-26248-1-git-send-email-dai.ngo@oracle.com \
    --to=dai.ngo@oracle.com \
    --cc=chuck.lever@oracle.com \
    --cc=jlayton@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).