Whamcloud - gitweb
LU-18231 obd: change obd_attach into ODBF_ATTACH 13/56413/5
authorRonnie Sahlberg <rsahlberg@whamcloud.com>
Thu, 19 Sep 2024 02:38:43 +0000 (22:38 -0400)
committerOleg Drokin <green@whamcloud.com>
Mon, 9 Dec 2024 06:10:59 +0000 (06:10 +0000)
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 <rsahlberg@whamcloud.com>
Change-Id: I2f360f6074e2078fa20b770b5dc2abc173766c9f
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/56413
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Reviewed-by: Timothy Day <timday@amazon.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
lustre/include/obd.h
lustre/kunit/llog_test.c
lustre/obdclass/class_obd.c
lustre/obdclass/genops.c
lustre/obdclass/kernelcomm.c
lustre/obdclass/obd_config.c
lustre/obdclass/obd_sysfs.c
lustre/obdecho/echo_client.c

index d12a0ae..63500c0 100644 (file)
@@ -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 */
index da7e3df..8d143df 100644 (file)
@@ -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);
index 28cbfda..19ed996 100644 (file)
@@ -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 = "--";
index d819b30..94ff971 100644 (file)
@@ -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;
                        }
index f130d0f..dfd1332 100644 (file)
@@ -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 = "--";
index 780d3ca..f22b353 100644 (file)
@@ -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.
index 790423e..1ae1bf7 100644 (file)
@@ -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);
 
index a957934..e6080df 100644 (file)
@@ -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);