From d0fc84cfa677c1b1cc93b0dd5c593c82d6efb304 Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Wed, 18 Sep 2024 23:56:03 -0400 Subject: [PATCH] LU-18231 obd: change obd_abort_recovery into OBDF_ABORT_RECOVERY Change the use of the odb_abort_recovery bitfield into a bit in the ofd_flags bitmap and use atomic bit set/clear/test operations on it. No logical changes to the code and no changes to locking. Test-Parameters: trivial Signed-off-by: Ronnie Sahlberg Change-Id: I1ff7f890a7ea67d2609ac3cb887a874e7ae6377b Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/56416 Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Reviewed-by: Timothy Day Tested-by: jenkins Tested-by: Maloo --- lustre/include/obd.h | 6 +++--- lustre/include/obd_class.h | 2 +- lustre/ldlm/ldlm_lib.c | 22 ++++++++++++---------- lustre/mdt/mdt_handler.c | 2 +- lustre/ofd/ofd_obd.c | 2 +- 5 files changed, 18 insertions(+), 16 deletions(-) diff --git a/lustre/include/obd.h b/lustre/include/obd.h index 569d809..0aba68e 100644 --- a/lustre/include/obd.h +++ b/lustre/include/obd.h @@ -598,6 +598,7 @@ enum { OBDF_ATTACHED, /* finished attach */ OBDF_SET_UP, /* finished setup */ OBDF_RECOVERING, /* there are recoverable clients */ + OBDF_ABORT_RECOVERY, /* abort client and MDT recovery */ OBDF_NUM_FLAGS, }; @@ -617,7 +618,6 @@ struct obd_device { /* bitfield modification is protected by obd_dev_lock */ DECLARE_BITMAP(obd_flags, OBDF_NUM_FLAGS); unsigned long - obd_abort_recovery:1, /* abort client and MDT recovery */ obd_abort_mdt_recovery:1, /* abort recovery between MDTs */ obd_version_recov:1, /* obd uses version checking */ obd_replayable:1, /* recovery enabled; inform clients */ @@ -804,13 +804,13 @@ void obd_nid_del(struct obd_device *obd, struct obd_export *exp); /* both client and MDT recovery are aborted, or MDT is stopping */ static inline bool obd_recovery_abort(struct obd_device *obd) { - return obd->obd_stopping || obd->obd_abort_recovery; + return obd->obd_stopping || test_bit(OBDF_ABORT_RECOVERY, obd->obd_flags); } /* MDT recovery is aborted, or MDT is stopping */ static inline bool obd_mdt_recovery_abort(struct obd_device *obd) { - return obd->obd_stopping || obd->obd_abort_recovery || + return obd->obd_stopping || test_bit(OBDF_ABORT_RECOVERY, obd->obd_flags) || obd->obd_abort_mdt_recovery; } #endif diff --git a/lustre/include/obd_class.h b/lustre/include/obd_class.h index 06a4e6d..c6ea0e4 100644 --- a/lustre/include/obd_class.h +++ b/lustre/include/obd_class.h @@ -420,7 +420,7 @@ static inline enum obd_option exp_flags_from_obd(struct obd_device *obd) { return ((obd->obd_fail ? OBD_OPT_FAILOVER : 0) | (obd->obd_force ? OBD_OPT_FORCE : 0) | - (obd->obd_abort_recovery ? OBD_OPT_ABORT_RECOV : 0) | + (test_bit(OBDF_ABORT_RECOVERY, obd->obd_flags) ? OBD_OPT_ABORT_RECOV : 0) | 0); } diff --git a/lustre/ldlm/ldlm_lib.c b/lustre/ldlm/ldlm_lib.c index 32e28ee..c68f1ab 100644 --- a/lustre/ldlm/ldlm_lib.c +++ b/lustre/ldlm/ldlm_lib.c @@ -826,7 +826,7 @@ static inline int target_check_recovery_timer(struct obd_device *target) spin_lock(&target->obd_dev_lock); if (test_bit(OBDF_RECOVERING, target->obd_flags)) { CERROR("%s: Aborting recovery\n", target->obd_name); - target->obd_abort_recovery = 1; + set_bit(OBDF_ABORT_RECOVERY, target->obd_flags); wake_up(&target->obd_next_transno_waitq); } spin_unlock(&target->obd_dev_lock); @@ -1848,7 +1848,7 @@ void target_cleanup_recovery(struct obd_device *obd) return; } clear_bit(OBDF_RECOVERING, obd->obd_flags); - obd->obd_abort_recovery = 0; + clear_bit(OBDF_ABORT_RECOVERY, obd->obd_flags); obd->obd_abort_mdt_recovery = 0; spin_unlock(&obd->obd_dev_lock); @@ -1892,7 +1892,8 @@ static void target_start_recovery_timer(struct obd_device *obd) return; spin_lock(&obd->obd_dev_lock); - if (!test_bit(OBDF_RECOVERING, obd->obd_flags) || obd->obd_abort_recovery) { + if (!test_bit(OBDF_RECOVERING, obd->obd_flags) || + test_bit(OBDF_ABORT_RECOVERY, obd->obd_flags)) { spin_unlock(&obd->obd_dev_lock); return; } @@ -1936,7 +1937,8 @@ static void extend_recovery_timer(struct obd_device *obd, timeout_t dr_timeout, timeout_t left; spin_lock(&obd->obd_dev_lock); - if (!test_bit(OBDF_RECOVERING, obd->obd_flags) || obd->obd_abort_recovery || + if (!test_bit(OBDF_RECOVERING, obd->obd_flags) || + test_bit(OBDF_ABORT_RECOVERY, obd->obd_flags) || obd->obd_stopping) { spin_unlock(&obd->obd_dev_lock); return; @@ -2167,7 +2169,7 @@ static int check_for_next_lock(struct lu_target *lut) } else if (atomic_read(&obd->obd_lock_replay_clients) == 0) { CDEBUG(D_HA, "waking for completed lock replay\n"); wake_up = 1; - } else if (obd->obd_abort_recovery) { + } else if (test_bit(OBDF_ABORT_RECOVERY, obd->obd_flags)) { CDEBUG(D_HA, "waking for aborted recovery\n"); wake_up = 1; } else if (obd->obd_recovery_expired) { @@ -2270,7 +2272,7 @@ repeat: "%s: there are still update replay (%#llx)in the queue.\n", obd->obd_name, next_update_transno); } else { - obd->obd_abort_recovery = 1; + set_bit(OBDF_ABORT_RECOVERY, obd->obd_flags); spin_unlock(&obd->obd_recovery_task_lock); CWARN("%s recovery is aborted by hard timeout\n", obd->obd_name); @@ -2446,7 +2448,7 @@ static int check_for_recovery_ready(struct lu_target *lut) "connected %d stale %d max_recoverable_clients %d abort %d expired %d\n", clnts, obd->obd_stale_clients, atomic_read(&obd->obd_max_recoverable_clients), - obd->obd_abort_recovery, obd->obd_recovery_expired); + test_bit(OBDF_ABORT_RECOVERY, obd->obd_flags), obd->obd_recovery_expired); if (!obd_recovery_abort(obd) && !obd->obd_recovery_expired) { LASSERT(clnts <= @@ -2808,7 +2810,7 @@ static int target_recovery_thread(void *arg) tgt_boot_epoch_update(lut); /* cancel update llogs upon recovery abort */ - if (obd->obd_abort_recovery || obd->obd_abort_mdt_recovery) + if (test_bit(OBDF_ABORT_RECOVERY, obd->obd_flags) || obd->obd_abort_mdt_recovery) obd->obd_type->typ_dt_ops->o_iocontrol(OBD_IOC_LLOG_CANCEL, obd->obd_self_export, 0, trd, NULL); @@ -2828,7 +2830,7 @@ static int target_recovery_thread(void *arg) */ spin_lock(&obd->obd_dev_lock); clear_bit(OBDF_RECOVERING, obd->obd_flags); - obd->obd_abort_recovery = 0; + clear_bit(OBDF_ABORT_RECOVERY, obd->obd_flags); obd->obd_abort_mdt_recovery = 0; spin_unlock(&obd->obd_dev_lock); spin_lock(&obd->obd_recovery_task_lock); @@ -2901,7 +2903,7 @@ void target_stop_recovery_thread(struct obd_device *obd) spin_lock(&obd->obd_dev_lock); if (test_bit(OBDF_RECOVERING, obd->obd_flags)) { CERROR("%s: Aborting recovery\n", obd->obd_name); - obd->obd_abort_recovery = 1; + set_bit(OBDF_ABORT_RECOVERY, obd->obd_flags); wake_up(&obd->obd_next_transno_waitq); } spin_unlock(&obd->obd_dev_lock); diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index 75a3d88..e1e2fe6 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -8004,7 +8004,7 @@ static int mdt_iocontrol(unsigned int cmd, struct obd_export *exp, int len, /* lctl didn't set OBD_FLG_ABORT_RECOV_OST < 2.13.57 */ LCONSOLE_WARN("%s: Aborting client recovery\n", obd->obd_name); - obd->obd_abort_recovery = 1; + set_bit(OBDF_ABORT_RECOVERY, obd->obd_flags); target_stop_recovery_thread(obd); } rc = 0; diff --git a/lustre/ofd/ofd_obd.c b/lustre/ofd/ofd_obd.c index 0597946..5e88cbd 100644 --- a/lustre/ofd/ofd_obd.c +++ b/lustre/ofd/ofd_obd.c @@ -1268,7 +1268,7 @@ static int ofd_iocontrol(unsigned int cmd, struct obd_export *exp, int len, switch (cmd) { case OBD_IOC_ABORT_RECOVERY: LCONSOLE_WARN("%s: Aborting recovery\n", obd->obd_name); - obd->obd_abort_recovery = 1; + set_bit(OBDF_ABORT_RECOVERY, obd->obd_flags); target_stop_recovery_thread(obd); GOTO(out, rc); case OBD_IOC_SYNC: -- 1.8.3.1