From 1c25cb7a3e3db17a65a8560915a0b79ada05a351 Mon Sep 17 00:00:00 2001 From: Patrick Farrell Date: Thu, 11 Jan 2024 16:21:11 +0530 Subject: [PATCH] LU-16741 ptlrpc: ptlrpc: rename ptlrpc_req_finished First series of patchs thats renames ptlrpc_req_finished to ptlrpc_req_put Change it as part of a general refactor of the ptlrpc request put/freeing code. Test-Parameters: trivial Signed-off-by: Patrick Farrell Signed-off-by: Arshad Hussain Change-Id: I3f897b74debe383c4efb25c9a0becc1c27faa3d9 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/53648 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Patrick Farrell Reviewed-by: Timothy Day Reviewed-by: Oleg Drokin --- contrib/scripts/spelling.txt | 1 + lustre/include/lustre_net.h | 5 +++-- lustre/ptlrpc/client.c | 32 ++++++++++++++++---------------- lustre/ptlrpc/import.c | 4 ++-- 4 files changed, 22 insertions(+), 20 deletions(-) diff --git a/contrib/scripts/spelling.txt b/contrib/scripts/spelling.txt index eda5ee7..a2e5ddb 100644 --- a/contrib/scripts/spelling.txt +++ b/contrib/scripts/spelling.txt @@ -132,6 +132,7 @@ PAGE_CACHE_SHIFT||PAGE_SHIFT PAGE_CACHE_SIZE||PAGE_SIZE prandom_u32||get_random_u32 prandom_u32_max||get_random_u32_below +ptlrpc_req_finished||ptlrpc_req_put return seq_printf||seq_printf setup_timer||cfs_timer_setup = seq_printf||seq_printf diff --git a/lustre/include/lustre_net.h b/lustre/include/lustre_net.h index 5a52a50..7cdd4c6 100644 --- a/lustre/include/lustre_net.h +++ b/lustre/include/lustre_net.h @@ -2125,8 +2125,9 @@ ptlrpc_request_alloc_pack(struct obd_import *imp, int ptlrpc_request_bufs_pack(struct ptlrpc_request *request, __u32 version, int opcode, char **bufs, struct ptlrpc_cli_ctx *ctx); -void ptlrpc_req_finished(struct ptlrpc_request *request); -void ptlrpc_req_finished_with_imp_lock(struct ptlrpc_request *request); +#define ptlrpc_req_finished(rq) ptlrpc_req_put(rq) +void ptlrpc_req_put(struct ptlrpc_request *request); +void ptlrpc_req_put_with_imp_lock(struct ptlrpc_request *request); struct ptlrpc_request *ptlrpc_request_addref(struct ptlrpc_request *req); struct ptlrpc_bulk_desc *ptlrpc_prep_bulk_imp(struct ptlrpc_request *req, unsigned int nfrags, diff --git a/lustre/ptlrpc/client.c b/lustre/ptlrpc/client.c index 3cfcad6..6a9097d 100644 --- a/lustre/ptlrpc/client.c +++ b/lustre/ptlrpc/client.c @@ -2707,17 +2707,6 @@ static void __ptlrpc_free_req(struct ptlrpc_request *request, int locked) EXIT; } -static int __ptlrpc_req_finished(struct ptlrpc_request *request, int locked); -/** - * Drop one request reference. Must be called with import imp_lock held. - * When reference count drops to zero, request is freed. - */ -void ptlrpc_req_finished_with_imp_lock(struct ptlrpc_request *request) -{ - assert_spin_locked(&request->rq_import->imp_lock); - (void)__ptlrpc_req_finished(request, 1); -} - /** * Helper function * Drops one reference count for request \a request. @@ -2727,7 +2716,7 @@ void ptlrpc_req_finished_with_imp_lock(struct ptlrpc_request *request) * \retval 1 the request is freed * \retval 0 some others still hold references on the request */ -static int __ptlrpc_req_finished(struct ptlrpc_request *request, int locked) +static int __ptlrpc_req_put(struct ptlrpc_request *request, int locked) { int count; @@ -2776,13 +2765,24 @@ static int __ptlrpc_req_finished(struct ptlrpc_request *request, int locked) } /** + * Drop one request reference. Must be called with import imp_lock held. + * When reference count drops to zero, request is freed. + */ +void ptlrpc_req_put_with_imp_lock(struct ptlrpc_request *request) +{ + assert_spin_locked(&request->rq_import->imp_lock); + (void)__ptlrpc_req_put(request, 1); +} + +/** * Drops one reference count for a request. */ -void ptlrpc_req_finished(struct ptlrpc_request *request) +void ptlrpc_req_put(struct ptlrpc_request *request) { - __ptlrpc_req_finished(request, 0); + __ptlrpc_req_put(request, 0); } -EXPORT_SYMBOL(ptlrpc_req_finished); +EXPORT_SYMBOL(ptlrpc_req_put); + /** * Returns xid of a \a request @@ -2888,7 +2888,7 @@ static void ptlrpc_free_request(struct ptlrpc_request *req) req->rq_commit_cb(req); list_del_init(&req->rq_replay_list); - __ptlrpc_req_finished(req, 1); + __ptlrpc_req_put(req, 1); } /** diff --git a/lustre/ptlrpc/import.c b/lustre/ptlrpc/import.c index d89b3c2..4ec502f 100644 --- a/lustre/ptlrpc/import.c +++ b/lustre/ptlrpc/import.c @@ -1740,7 +1740,7 @@ int ptlrpc_disconnect_import(struct obd_import *imp, int noclose) spin_lock(&imp->imp_lock); if (imp->imp_state != LUSTRE_IMP_FULL) { - ptlrpc_req_finished_with_imp_lock(req); + ptlrpc_req_put_with_imp_lock(req); GOTO(out, rc); } import_set_state_nolock(imp, LUSTRE_IMP_CONNECTING); @@ -1875,7 +1875,7 @@ int ptlrpc_disconnect_and_idle_import(struct obd_import *imp) spin_lock(&imp->imp_lock); if (imp->imp_state != LUSTRE_IMP_FULL || !ptlrpc_can_idle(imp)) { - ptlrpc_req_finished_with_imp_lock(req); + ptlrpc_req_put_with_imp_lock(req); spin_unlock(&imp->imp_lock); RETURN(0); } -- 1.8.3.1