From 71760113e7207772bbd60a5372a6f2483d9e24b2 Mon Sep 17 00:00:00 2001 From: Arshad Hussain Date: Tue, 24 Oct 2023 17:14:15 +0530 Subject: [PATCH] LU-16796 mgc: Change config_llog_data to use refcount_t This patch changes struct config_llog_data to use refcount_t instead of atomic_t Signed-off-by: Arshad Hussain Change-Id: Ieec4de5d957b8dfa82c8cdef80f3a9f73aa55126 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/52813 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: James Simmons Reviewed-by: Oleg Drokin Reviewed-by: Neil Brown --- lustre/include/obd_class.h | 2 +- lustre/mgc/mgc_request.c | 19 ++++++------------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/lustre/include/obd_class.h b/lustre/include/obd_class.h index 8f76738..40e4354 100644 --- a/lustre/include/obd_class.h +++ b/lustre/include/obd_class.h @@ -267,7 +267,7 @@ struct config_llog_data { struct lustre_handle cld_lockh; struct config_llog_instance cld_cfg; struct list_head cld_list_chain;/* on config_llog_list */ - atomic_t cld_refcount; + refcount_t cld_refcount; struct config_llog_data *cld_sptlrpc;/* depended sptlrpc log */ struct config_llog_data *cld_params; /* common parameters log */ struct config_llog_data *cld_recover;/* imperative recover log */ diff --git a/lustre/mgc/mgc_request.c b/lustre/mgc/mgc_request.c index 8722dda..d957f9e 100644 --- a/lustre/mgc/mgc_request.c +++ b/lustre/mgc/mgc_request.c @@ -124,9 +124,9 @@ static DEFINE_SPINLOCK(config_list_lock); /* protects config_llog_list */ static int config_log_get(struct config_llog_data *cld) { ENTRY; - atomic_inc(&cld->cld_refcount); + refcount_inc(&cld->cld_refcount); CDEBUG(D_INFO, "log %s (%p) refs %d\n", cld->cld_logname, cld, - atomic_read(&cld->cld_refcount)); + refcount_read(&cld->cld_refcount)); RETURN(0); } @@ -140,11 +140,10 @@ static void config_log_put(struct config_llog_data *cld) RETURN_EXIT; CDEBUG(D_INFO, "log %s(%p) refs %d\n", cld->cld_logname, cld, - atomic_read(&cld->cld_refcount)); - LASSERT(atomic_read(&cld->cld_refcount) > 0); + refcount_read(&cld->cld_refcount)); /* spinlock to make sure no item with 0 refcount in the list */ - if (atomic_dec_and_lock(&cld->cld_refcount, &config_list_lock)) { + if (refcount_dec_and_lock(&cld->cld_refcount, &config_list_lock)) { list_del(&cld->cld_list_chain); spin_unlock(&config_list_lock); @@ -233,7 +232,7 @@ struct config_llog_data *do_config_log_add(struct obd_device *obd, cld->cld_cfg.cfg_flags = 0; cld->cld_cfg.cfg_sb = sb; cld->cld_type = type; - atomic_set(&cld->cld_refcount, 1); + refcount_set(&cld->cld_refcount, 1); /* Keep the mgc around until we are done */ cld->cld_mgcexp = class_export_get(obd->obd_self_export); @@ -606,8 +605,6 @@ static void do_requeue(struct config_llog_data *cld) int rc = 0; ENTRY; - LASSERT(atomic_read(&cld->cld_refcount) > 0); - /* * Do not run mgc_process_log on a disconnected export or an * export which is being disconnected. Take the client @@ -723,9 +720,8 @@ static void mgc_requeue_add(struct config_llog_data *cld) ENTRY; CDEBUG(D_INFO, "log %s: requeue (r=%d sp=%d st=%x)\n", - cld->cld_logname, atomic_read(&cld->cld_refcount), + cld->cld_logname, refcount_read(&cld->cld_refcount), cld->cld_stopping, rq_state); - LASSERT(atomic_read(&cld->cld_refcount) > 0); /* lets cancel an existent lock to mark cld as "lostlock" */ CDEBUG(D_INFO, "lockh %#llx\n", cld->cld_lockh.cookie); @@ -917,9 +913,6 @@ static int mgc_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc, break; } - /* held at mgc_process_log(). */ - LASSERT(atomic_read(&cld->cld_refcount) > 0); - lock->l_ast_data = NULL; cld->cld_lockh.cookie = 0; /* Are we done with this log? */ -- 1.8.3.1