From a6886dba0ed8a622c9831cd33d310d933492c72d Mon Sep 17 00:00:00 2001 From: Mikhail Pershin Date: Tue, 6 Feb 2024 12:36:40 +0300 Subject: [PATCH] LU-17379 ptlrpc: fix check for callback discard In ptlrpc_unregister_reply() decision about need to discard request-out callback is done too early, before LNetMDUnlink() invokes reply callback. Therefore at the monent of discard check rq_reply_unlinked is not set yet and discard is skipped always. Patch removes discard check from __ptlrpc_cli_wait_unlink() and does that after LNetMDUnlink() call right inside ptlrpc_unregister_reply(). That makes __ptlrpc_cli_wait_unlink() unused, so it was removed and only ptlrpc_cli_wait_unlink() remains Fixes: babf0232273 ("LU-13368 lnet: discard the callback") Signed-off-by: Mikhail Pershin Change-Id: I6448cafa8a0b81d7ba0172ad1709e75e592d4924 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/53937 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Serguei Smirnov Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin --- lustre/include/lustre_net.h | 13 +------------ lustre/ptlrpc/client.c | 8 ++++++-- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/lustre/include/lustre_net.h b/lustre/include/lustre_net.h index 279a41b..1a72add 100644 --- a/lustre/include/lustre_net.h +++ b/lustre/include/lustre_net.h @@ -2476,10 +2476,8 @@ ptlrpc_client_recv(struct ptlrpc_request *req) return req->rq_receiving_reply; } -#define ptlrpc_cli_wait_unlink(req) __ptlrpc_cli_wait_unlink(req, NULL) - static inline int -__ptlrpc_cli_wait_unlink(struct ptlrpc_request *req, bool *discard) +ptlrpc_cli_wait_unlink(struct ptlrpc_request *req) { int rc; @@ -2493,15 +2491,6 @@ __ptlrpc_cli_wait_unlink(struct ptlrpc_request *req, bool *discard) return 1; } - if (discard) { - *discard = false; - if (req->rq_reply_unlinked && req->rq_req_unlinked == 0) { - *discard = true; - spin_unlock(&req->rq_lock); - return 1; /* Should call again after LNetMDUnlink */ - } - } - rc = !req->rq_req_unlinked || !req->rq_reply_unlinked || req->rq_receiving_reply; spin_unlock(&req->rq_lock); diff --git a/lustre/ptlrpc/client.c b/lustre/ptlrpc/client.c index a157a50..4c63dfd 100644 --- a/lustre/ptlrpc/client.c +++ b/lustre/ptlrpc/client.c @@ -2800,7 +2800,7 @@ EXPORT_SYMBOL(ptlrpc_req_xid); */ static int ptlrpc_unregister_reply(struct ptlrpc_request *request, int async) { - bool discard = false; + bool discard; /* * Might sleep. */ @@ -2815,11 +2815,15 @@ static int ptlrpc_unregister_reply(struct ptlrpc_request *request, int async) /* * Nothing left to do. */ - if (!__ptlrpc_cli_wait_unlink(request, &discard)) + if (!ptlrpc_cli_wait_unlink(request)) RETURN(1); LNetMDUnlink(request->rq_reply_md_h); + spin_lock(&request->rq_lock); + discard = request->rq_reply_unlinked && !request->rq_req_unlinked; + spin_unlock(&request->rq_lock); + if (discard) /* Discard the request-out callback */ __LNetMDUnlink(request->rq_req_md_h, discard); -- 1.8.3.1