From: Ronnie Sahlberg Date: Thu, 19 Sep 2024 02:38:43 +0000 (-0400) Subject: LU-18231 obd: change obd_attach into ODBF_ATTACH X-Git-Tag: 2.16.51~105 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=d32597c73da5485d236bd076271af8b03e0b9973;p=fs%2Flustre-release.git LU-18231 obd: change obd_attach into ODBF_ATTACH Change the use of the odb_attach 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: I2f360f6074e2078fa20b770b5dc2abc173766c9f Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/56413 Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Reviewed-by: Timothy Day Tested-by: jenkins Tested-by: Maloo --- diff --git a/lustre/include/obd.h b/lustre/include/obd.h index d12a0ae..63500c0 100644 --- a/lustre/include/obd.h +++ b/lustre/include/obd.h @@ -595,7 +595,8 @@ struct obd_llog_group { /* Obd flag bits */ enum { - OBDF_NUM_FLAGS, + OBDF_ATTACHED, /* finished attach */ + OBDF_NUM_FLAGS, }; /* corresponds to one of the obd's */ @@ -614,7 +615,6 @@ struct obd_device { /* bitfield modification is protected by obd_dev_lock */ DECLARE_BITMAP(obd_flags, OBDF_NUM_FLAGS); unsigned long - obd_attached:1, /* finished attach */ obd_set_up:1, /* finished setup */ obd_recovering:1, /* there are recoverable clients */ obd_abort_recovery:1, /* abort client and MDT recovery */ diff --git a/lustre/kunit/llog_test.c b/lustre/kunit/llog_test.c index da7e3df..8d143df 100644 --- a/lustre/kunit/llog_test.c +++ b/lustre/kunit/llog_test.c @@ -2280,7 +2280,7 @@ static int llog_test_setup(struct obd_device *obd, struct lustre_cfg *lcfg) /* disk obd */ tgt = class_name2obd(lustre_cfg_string(lcfg, 1)); - if (!tgt || !tgt->obd_attached || !tgt->obd_set_up) { + if (!tgt || !test_bit(OBDF_ATTACHED, tgt->obd_flags) || !tgt->obd_set_up) { CERROR("target device not attached or not set up (%s)\n", lustre_cfg_string(lcfg, 1)); RETURN(-EINVAL); diff --git a/lustre/obdclass/class_obd.c b/lustre/obdclass/class_obd.c index 28cbfda..19ed996 100644 --- a/lustre/obdclass/class_obd.c +++ b/lustre/obdclass/class_obd.c @@ -463,7 +463,7 @@ int class_handle_ioctl(unsigned int cmd, void __user *uarg) status = "IN"; else if (obd->obd_set_up) status = "UP"; - else if (obd->obd_attached) + else if (test_bit(OBDF_ATTACHED, obd->obd_flags)) status = "AT"; else status = "--"; diff --git a/lustre/obdclass/genops.c b/lustre/obdclass/genops.c index d819b30..94ff971 100644 --- a/lustre/obdclass/genops.c +++ b/lustre/obdclass/genops.c @@ -492,7 +492,7 @@ static int class_name2dev_nolock(const char *name) * out any references */ LASSERT(obd->obd_magic == OBD_DEVICE_MAGIC); - if (obd->obd_attached) { + if (test_bit(OBDF_ATTACHED, obd->obd_flags)) { ret = obd->obd_minor; return ret; } @@ -596,7 +596,7 @@ struct obd_device *class_name2obd(const char *name) * out any references */ LASSERT(obd->obd_magic == OBD_DEVICE_MAGIC); - if (obd->obd_attached) + if (test_bit(OBDF_ATTACHED, obd->obd_flags)) break; } } @@ -688,7 +688,7 @@ struct obd_device *class_str2obd(const char *str) * out any references */ LASSERT(obd->obd_magic == OBD_DEVICE_MAGIC); - if (obd->obd_attached) { + if (test_bit(OBDF_ATTACHED, obd->obd_flags)) { class_incref(obd, "find", current); break; } diff --git a/lustre/obdclass/kernelcomm.c b/lustre/obdclass/kernelcomm.c index f130d0f..dfd1332 100644 --- a/lustre/obdclass/kernelcomm.c +++ b/lustre/obdclass/kernelcomm.c @@ -231,7 +231,7 @@ static int lustre_device_list_dump(struct sk_buff *msg, status = "IN"; else if (obd->obd_set_up) status = "UP"; - else if (obd->obd_attached) + else if (test_bit(OBDF_ATTACHED, obd->obd_flags)) status = "AT"; else status = "--"; diff --git a/lustre/obdclass/obd_config.c b/lustre/obdclass/obd_config.c index 780d3ca..f22b353 100644 --- a/lustre/obdclass/obd_config.c +++ b/lustre/obdclass/obd_config.c @@ -666,7 +666,7 @@ int class_attach(struct lustre_cfg *lcfg) RETURN(rc); } - obd->obd_attached = 1; + set_bit(OBDF_ATTACHED, obd->obd_flags); CDEBUG(D_IOCTL, "OBD: dev %d attached type %s with refcount %d\n", obd->obd_minor, typename, kref_read(&obd->obd_refcount)); @@ -693,7 +693,7 @@ int class_setup(struct obd_device *obd, struct lustre_cfg *lcfg) obd, obd->obd_magic, OBD_DEVICE_MAGIC); /* have we attached a type to this device? */ - if (!obd->obd_attached) { + if (!test_bit(OBDF_ATTACHED, obd->obd_flags)) { CERROR("Device %d not attached\n", obd->obd_minor); RETURN(-ENODEV); } @@ -813,12 +813,12 @@ int class_detach(struct obd_device *obd, struct lustre_cfg *lcfg) } spin_lock(&obd->obd_dev_lock); - if (!obd->obd_attached) { + if (!test_bit(OBDF_ATTACHED, obd->obd_flags)) { spin_unlock(&obd->obd_dev_lock); CERROR("OBD device %d not attached\n", obd->obd_minor); RETURN(-ENODEV); } - obd->obd_attached = 0; + clear_bit(OBDF_ATTACHED, obd->obd_flags); /* cleanup in progress. we don't like to find this device after now */ class_unregister_device(obd); @@ -950,7 +950,7 @@ static void class_decref_free(struct kref *kref) struct obd_export *exp; obd = container_of(kref, struct obd_device, obd_refcount); - LASSERT(!obd->obd_attached); + LASSERT(!test_bit(OBDF_ATTACHED, obd->obd_flags)); /* * All exports have been destroyed; there should * be no more in-progress ops by this point. diff --git a/lustre/obdclass/obd_sysfs.c b/lustre/obdclass/obd_sysfs.c index 790423e..1ae1bf7a 100644 --- a/lustre/obdclass/obd_sysfs.c +++ b/lustre/obdclass/obd_sysfs.c @@ -197,7 +197,7 @@ static ssize_t no_transno_store(struct kobject *kobj, return rc; obd = class_num2obd(idx); - if (!obd || !obd->obd_attached) { + if (!obd || !test_bit(OBDF_ATTACHED, obd->obd_flags)) { if (obd) CERROR("%s: not attached\n", obd->obd_name); return -ENODEV; @@ -248,7 +248,7 @@ health_check_show(struct kobject *kobj, struct attribute *attr, char *buf) return sprintf(buf, "LBUG\n"); obd_device_lock(); - obd_device_for_each_cond(dev_no, obd, obd->obd_attached && + obd_device_for_each_cond(dev_no, obd, test_bit(OBDF_ATTACHED, obd->obd_flags) && obd->obd_set_up && !obd->obd_stopping && !obd->obd_read_only) { LASSERT(obd->obd_magic == OBD_DEVICE_MAGIC); @@ -588,7 +588,7 @@ static int obd_device_list_seq_show(struct seq_file *p, void *v) status = "IN"; else if (obd->obd_set_up) status = "UP"; - else if (obd->obd_attached) + else if (test_bit(OBDF_ATTACHED, obd->obd_flags)) status = "AT"; else status = "--"; @@ -693,7 +693,7 @@ health_check_seq_show(struct seq_file *m, void *unused) unsigned long dev_no = 0; obd_device_lock(); - obd_device_for_each_cond(dev_no, obd, obd->obd_attached && + obd_device_for_each_cond(dev_no, obd, test_bit(OBDF_ATTACHED, obd->obd_flags) && obd->obd_set_up && !obd->obd_stopping) { LASSERT(obd->obd_magic == OBD_DEVICE_MAGIC); diff --git a/lustre/obdecho/echo_client.c b/lustre/obdecho/echo_client.c index a957934..e6080df 100644 --- a/lustre/obdecho/echo_client.c +++ b/lustre/obdecho/echo_client.c @@ -2446,7 +2446,7 @@ static int echo_client_setup(const struct lu_env *env, } tgt = class_name2obd(lustre_cfg_string(lcfg, 1)); - if (!tgt || !tgt->obd_attached || !tgt->obd_set_up) { + if (!tgt || !test_bit(OBDF_ATTACHED, tgt->obd_flags) || !tgt->obd_set_up) { CERROR("device not attached or not set up (%s)\n", lustre_cfg_string(lcfg, 1)); RETURN(-EINVAL);