2024-03-26 18:16:46

by Dai Ngo

[permalink] [raw]
Subject: [PATCH 1/1] NFSD: cancel CB_RECAL call when nfs4_client is about to be destroyed

Currently when a nfs4_client is destroyed we wait for the cb_recall
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 call from
the workqueue when the nfs4_client is about to be destroyed.

Signed-off-by: Dai Ngo <[email protected]>
---
fs/nfsd/nfs4callback.c | 6 ++++++
fs/nfsd/nfs4state.c | 2 ++
fs/nfsd/state.h | 2 ++
3 files changed, 10 insertions(+)

diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c
index e5b50c96be6a..da9211f6fbbb 100644
--- a/fs/nfsd/nfs4callback.c
+++ b/fs/nfsd/nfs4callback.c
@@ -1578,3 +1578,9 @@ void nfsd41_cb_recall_any_cancel(struct nfs4_client *clp)
nfsd41_cb_inflight_end(clp);
}
}
+
+void nfsd4_cb_recall_cancel(struct nfs4_client *clp, struct nfs4_delegation *dp)
+{
+ if (cancel_delayed_work(&dp->dl_recall.cb_work))
+ nfsd41_cb_inflight_end(clp);
+}
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 0e1db57c9a19..f889e3addd71 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -2378,6 +2378,8 @@ __destroy_client(struct nfs4_client *clp)
while (!list_empty(&reaplist)) {
dp = list_entry(reaplist.next, struct nfs4_delegation, dl_recall_lru);
list_del_init(&dp->dl_recall_lru);
+ if (dp->dl_recalled)
+ nfsd4_cb_recall_cancel(clp, dp);
destroy_unhashed_deleg(dp);
}
while (!list_empty(&clp->cl_revoked)) {
diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h
index 259b4af7d226..8b29bd3bbf1d 100644
--- a/fs/nfsd/state.h
+++ b/fs/nfsd/state.h
@@ -736,6 +736,8 @@ 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 void nfsd4_cb_recall_cancel(struct nfs4_client *clp,
+ struct nfs4_delegation *dp);
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