Whamcloud - gitweb
LU-6142 obd: change lmd flags to bitmap 12/49912/9
authorJames Simmons <jsimmons@infradead.org>
Sun, 30 Apr 2023 13:06:44 +0000 (09:06 -0400)
committerOleg Drokin <green@whamcloud.com>
Fri, 19 May 2023 07:00:41 +0000 (07:00 +0000)
Change lmd flags to an enum that is accessible with the Linux
bitmap API. This lays the foundation for creating a match table
for the server options for mounting.

Change-Id: If7906a9a3ba177b67d0cfbaa276a00a6ba9b7b6d
Signed-off-by: James Simmons <jsimmons@infradead.org>
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/49912
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Neil Brown <neilb@suse.de>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
libcfs/autoconf/lustre-libcfs.m4
libcfs/include/libcfs/linux/linux-misc.h
libcfs/libcfs/linux/linux-prim.c
lustre/include/lustre_disk.h
lustre/mdt/mdt_handler.c
lustre/mgc/mgc_request.c
lustre/obdclass/obd_mount.c
lustre/ofd/ofd_dev.c
lustre/osd-ldiskfs/osd_handler.c
lustre/osd-zfs/osd_handler.c
lustre/target/tgt_mount.c

index 19bc8ae..4d3dba8 100644 (file)
@@ -1383,6 +1383,28 @@ AC_DEFUN([LIBCFS_LOCKDEP_IS_HELD], [
 ]) # LIBCFS_LOCKDEP_IS_HELD
 
 #
+# LIBCFS_BITMAP_TO_ARR32
+#
+# Kernel commit v4.15-10794-gc724f19 introduced
+# bitmap_{from,to}_arr32, which are handy functions, to move
+# data back and forth between a bitmap and a u32 array
+#
+AC_DEFUN([LIBCFS_SRC_BITMAP_TO_ARR32], [
+       LB2_LINUX_TEST_SRC([bitmap_to_arr32], [
+               #include <linux/bitmap.h>
+       ],[
+               bitmap_to_arr32(NULL, NULL, 0);
+       ],[-Werror])
+])
+AC_DEFUN([LIBCFS_BITMAP_TO_ARR32], [
+       AC_MSG_CHECKING([if 'bitmap_to_arr32()' exist])
+       LB2_LINUX_TEST_RESULT([bitmap_to_arr32], [
+               AC_DEFINE(HAVE_BITMAP_TO_ARR32, 1,
+                       [bitmap_to_arr32() exist])
+       ])
+]) # LIBCFS_BITMAP_TO_ARR32
+
+#
 # LIBCFS_TIMER_SETUP
 #
 # Kernel version 4.15 commit e99e88a9d2b067465adaa9c111ada99a041bef9a
@@ -2381,6 +2403,7 @@ AC_DEFUN([LIBCFS_PROG_LINUX_SRC], [
        LIBCFS_SRC_NEW_KERNEL_READ
        # 4.15
        LIBCFS_SRC_LOCKDEP_IS_HELD
+       LIBCFS_SRC_BITMAP_TO_ARR32
        LIBCFS_SRC_TIMER_SETUP
        # 4.16
        LIBCFS_SRC_HAVE_NS_TO_TIMESPEC64
@@ -2525,6 +2548,7 @@ AC_DEFUN([LIBCFS_PROG_LINUX_RESULTS], [
        LIBCFS_NEW_KERNEL_READ
        # 4.15
        LIBCFS_LOCKDEP_IS_HELD
+       LIBCFS_BITMAP_TO_ARR32
        LIBCFS_TIMER_SETUP
        # 4.16
        LIBCFS_HAVE_NS_TO_TIMESPEC64
index e6c7e96..2f3b305 100644 (file)
@@ -192,6 +192,10 @@ static inline void *cfs_kallsyms_lookup_name(const char *name)
 #define strscpy(s1, s2, sz)    strlcpy((s1), (s2), (sz))
 #endif
 
+#ifndef HAVE_BITMAP_TO_ARR32
+void bitmap_to_arr32(u32 *buf, const unsigned long *bitmap, unsigned int nbits);
+#endif
+
 #ifndef HAVE_KOBJ_TYPE_DEFAULT_GROUPS
 #define default_groups                 default_attrs
 #define KOBJ_ATTR_GROUPS(_name)                _name##_attrs
index 5f2f6ae..bf5712a 100644 (file)
@@ -240,6 +240,31 @@ bool match_wildcard(const char *pattern, const char *str)
 EXPORT_SYMBOL(match_wildcard);
 #endif /* !HAVE_MATCH_WILDCARD */
 
+#ifndef HAVE_BITMAP_TO_ARR32
+/**
+ * bitmap_to_arr32 - copy the contents of bitmap to a u32 array of bits
+ *     @buf: array of u32 (in host byte order), the dest bitmap
+ *     @bitmap: array of unsigned longs, the source bitmap
+ *     @nbits: number of bits in @bitmap
+ */
+void bitmap_to_arr32(u32 *buf, const unsigned long *bitmap, unsigned int nbits)
+{
+       unsigned int i, halfwords;
+
+       halfwords = DIV_ROUND_UP(nbits, 32);
+       for (i = 0; i < halfwords; i++) {
+               buf[i] = (u32) (bitmap[i/2] & UINT_MAX);
+               if (++i < halfwords)
+                       buf[i] = (u32) (bitmap[i/2] >> 32);
+       }
+
+       /* Clear tail bits in last element of array beyond nbits. */
+       if (nbits % BITS_PER_LONG)
+               buf[halfwords - 1] &= (u32) (UINT_MAX >> ((-nbits) & 31));
+}
+EXPORT_SYMBOL(bitmap_to_arr32);
+#endif /* !HAVE_BITMAP_TO_ARR32 */
+
 #ifndef HAVE_KSTRTOBOOL_FROM_USER
 int kstrtobool_from_user(const char __user *s, size_t count, bool *res)
 {
index 544cec2..d17b859 100644 (file)
 #define LMD_MAGIC              0xbdacbd03
 #define LMD_PARAMS_MAXLEN      4096
 
+enum lmd_flags {
+       LMD_FLG_SERVER          = 0,    /* Mounting a server */
+       LMD_FLG_CLIENT,                 /* Mounting a client */
+       LMD_FLG_SKIP_LFSCK,             /* NOT auto resume LFSCK when mount */
+       LMD_FLG_ABORT_RECOV,            /* Abort recovery */
+       LMD_FLG_NOSVC,                  /* Only start MGS/MGC for servers,
+                                        * no other services
+                                        */
+       LMD_FLG_NOMGS,                  /* Only start target for servers,
+                                        * reusing existing MGS services
+                                        */
+       LMD_FLG_WRITECONF,              /* Rewrite config log */
+       LMD_FLG_NOIR,                   /* NO imperative recovery */
+       LMD_FLG_NOSCRUB,                        /* Do not trigger scrub automatically */
+       LMD_FLG_MGS,                    /* Also start MGS along with server */
+       LMD_FLG_IAM,                    /* IAM dir */
+       LMD_FLG_NO_PRIMNODE,            /* all nodes are service nodes */
+       LMD_FLG_VIRGIN,                 /* the service registers first time */
+       LMD_FLG_UPDATE,                 /* update parameters */
+       LMD_FLG_HSM,                    /* Start coordinator */
+       LMD_FLG_DEV_RDONLY,             /* discard modification quitely */
+       LMD_FLG_NO_PRECREATE,           /* do not allow OST object creation */
+       LMD_FLG_LOCAL_RECOV,            /* force recovery for local clients */
+       LMD_FLG_ABORT_RECOV_MDT,        /* Abort recovery between MDTs */
+       LMD_FLG_NO_LOCAL_LOGS,          /* Use config logs from MGS */
+       LMD_FLG_NUM_FLAGS
+};
+
 /* gleaned from the mount command - no persistent info here */
 struct lustre_mount_data {
        u32     lmd_magic;
-       u32     lmd_flags;      /* lustre mount flags */
+       DECLARE_BITMAP(lmd_flags, LMD_FLG_NUM_FLAGS); /* lustre mount flags */
        int     lmd_mgs_failnodes; /* mgs failover node count */
        int     lmd_exclude_count;
        int     lmd_recovery_time_soft;
@@ -103,30 +131,7 @@ struct lustre_mount_data {
        char   *lmd_nidnet;     /* network to restrict this client to */
 };
 
-#define LMD_FLG_SERVER         0x0001  /* Mounting a server */
-#define LMD_FLG_CLIENT         0x0002  /* Mounting a client */
-#define LMD_FLG_SKIP_LFSCK     0x0004  /* NOT auto resume LFSCK when mount */
-#define LMD_FLG_ABORT_RECOV    0x0008  /* Abort recovery */
-#define LMD_FLG_NOSVC          0x0010  /* Only start MGS/MGC for servers,
-                                          no other services */
-#define LMD_FLG_NOMGS          0x0020  /* Only start target for servers, reusing
-                                          existing MGS services */
-#define LMD_FLG_WRITECONF      0x0040  /* Rewrite config log */
-#define LMD_FLG_NOIR           0x0080  /* NO imperative recovery */
-#define LMD_FLG_NOSCRUB                0x0100  /* Do not trigger scrub automatically */
-#define LMD_FLG_MGS            0x0200  /* Also start MGS along with server */
-#define LMD_FLG_IAM            0x0400  /* IAM dir */
-#define LMD_FLG_NO_PRIMNODE    0x0800  /* all nodes are service nodes */
-#define LMD_FLG_VIRGIN         0x1000  /* the service registers first time */
-#define LMD_FLG_UPDATE         0x2000  /* update parameters */
-#define LMD_FLG_HSM            0x4000  /* Start coordinator */
-#define LMD_FLG_DEV_RDONLY     0x8000  /* discard modification quitely */
-#define LMD_FLG_NO_PRECREATE   0x10000 /* do not allow OST object creation */
-#define LMD_FLG_LOCAL_RECOV    0x20000 /* force recovery for local clients */
-#define LMD_FLG_ABORT_RECOV_MDT        0x40000 /* Abort recovery between MDTs */
-#define LMD_FLG_NO_LOCAL_LOGS  0x80000 /* Use config logs from MGS */
-
-#define lmd_is_client(x) ((x)->lmd_flags & LMD_FLG_CLIENT)
+#define lmd_is_client(x) (test_bit(LMD_FLG_CLIENT, (x)->lmd_flags))
 
 /****************** superblock additional info *********************/
 struct ll_sb_info;
index 9121352..782ddef 100644 (file)
@@ -6166,7 +6166,7 @@ static int mdt_init0(const struct lu_env *env, struct mdt_device *m,
                        RETURN(rc);
 
                obd_obt_init(obd);
-               if (lsi->lsi_lmd->lmd_flags & LMD_FLG_SKIP_LFSCK)
+               if (test_bit(LMD_FLG_SKIP_LFSCK, lsi->lsi_lmd->lmd_flags))
                        m->mdt_skip_lfsck = 1;
        }
 
@@ -6356,7 +6356,7 @@ static int mdt_init0(const struct lu_env *env, struct mdt_device *m,
        if (ldlm_timeout == LDLM_TIMEOUT_DEFAULT)
                ldlm_timeout = MDS_LDLM_TIMEOUT_DEFAULT;
 
-       if ((lsi->lsi_lmd->lmd_flags & LMD_FLG_LOCAL_RECOV))
+       if (test_bit(LMD_FLG_LOCAL_RECOV, lsi->lsi_lmd->lmd_flags))
                m->mdt_lut.lut_local_recovery = 1;
 
        rc = mdt_restriper_start(m);
index 5863144..3d676fc 100644 (file)
@@ -408,7 +408,7 @@ config_log_add(struct obd_device *obd, char *logname,
        }
 
        LASSERT(lsi->lsi_lmd);
-       if (!(lsi->lsi_lmd->lmd_flags & LMD_FLG_NOIR) &&
+       if (!test_bit(LMD_FLG_NOIR, lsi->lsi_lmd->lmd_flags) &&
            cfg->cfg_sub_clds & CONFIG_SUB_RECOVER) {
                struct config_llog_data *recover_cld;
 
index 3fc205d..e692180 100644 (file)
@@ -304,22 +304,25 @@ int lustre_start_mgc(struct super_block *sb)
                if (lmd_is_client(lsi->lsi_lmd)) {
                        int has_ir;
                        int vallen = sizeof(*data);
-                       __u32 *flags = &lsi->lsi_lmd->lmd_flags;
 
                        rc = obd_get_info(NULL, obd->obd_self_export,
                                          strlen(KEY_CONN_DATA), KEY_CONN_DATA,
                                          &vallen, data);
                        LASSERT(rc == 0);
                        has_ir = OCD_HAS_FLAG(data, IMP_RECOV);
-                       if (has_ir ^ !(*flags & LMD_FLG_NOIR)) {
+                       if (has_ir ^ !test_bit(LMD_FLG_NOIR,
+                                              lsi->lsi_lmd->lmd_flags)) {
                                /* LMD_FLG_NOIR is for test purpose only */
                                LCONSOLE_WARN(
                                              "Mounting client with IR setting not compatible with current MGC. Using MGC setting that is IR %s",
                                              has_ir ? "enabled" : "disabled");
-                               if (has_ir)
-                                       *flags &= ~LMD_FLG_NOIR;
-                               else
-                                       *flags |= LMD_FLG_NOIR;
+                               if (has_ir) {
+                                       clear_bit(LMD_FLG_NOIR,
+                                                 lsi->lsi_lmd->lmd_flags);
+                               } else {
+                                       set_bit(LMD_FLG_NOIR,
+                                               lsi->lsi_lmd->lmd_flags);
+                               }
                        }
                }
 
@@ -479,7 +482,7 @@ int lustre_start_mgc(struct super_block *sb)
        data->ocd_connect_flags2 = OBD_CONNECT2_REP_MBITS;
 
        if (lmd_is_client(lsi->lsi_lmd) &&
-           lsi->lsi_lmd->lmd_flags & LMD_FLG_NOIR)
+           test_bit(LMD_FLG_NOIR, lsi->lsi_lmd->lmd_flags))
                data->ocd_connect_flags &= ~OBD_CONNECT_IMP_RECOV;
        data->ocd_version = LUSTRE_VERSION_CODE;
        rc = obd_connect(NULL, &exp, obd, uuid, data, NULL);
@@ -968,7 +971,6 @@ static void lmd_print(struct lustre_mount_data *lmd)
        if (lmd_is_client(lmd))
                PRINT_CMD(D_MOUNT, "profile: %s\n", lmd->lmd_profile);
        PRINT_CMD(D_MOUNT, "device:  %s\n", lmd->lmd_dev);
-       PRINT_CMD(D_MOUNT, "flags:   %x\n", lmd->lmd_flags);
 
        if (lmd->lmd_opts)
                PRINT_CMD(D_MOUNT, "options: %s\n", lmd->lmd_opts);
@@ -1351,10 +1353,10 @@ int lmd_parse(char *options, struct lustre_mount_data *lmd)
                 */
                if (!strncmp(s1, "abort_recov_mdt", 15) ||
                    !strncmp(s1, "abort_recovery_mdt", 18)) {
-                       lmd->lmd_flags |= LMD_FLG_ABORT_RECOV_MDT;
+                       set_bit(LMD_FLG_ABORT_RECOV_MDT, lmd->lmd_flags);
                        clear++;
                } else if (strncmp(s1, "abort_recov", 11) == 0) {
-                       lmd->lmd_flags |= LMD_FLG_ABORT_RECOV;
+                       set_bit(LMD_FLG_ABORT_RECOV, lmd->lmd_flags);
                        clear++;
                } else if (strncmp(s1, "recovery_time_soft=", 19) == 0) {
                        lmd->lmd_recovery_time_soft =
@@ -1367,25 +1369,25 @@ int lmd_parse(char *options, struct lustre_mount_data *lmd)
                                      time_min);
                        clear++;
                } else if (strncmp(s1, "no_precreate", 12) == 0) {
-                       lmd->lmd_flags |= LMD_FLG_NO_PRECREATE;
+                       set_bit(LMD_FLG_NO_PRECREATE, lmd->lmd_flags);
                        clear++;
-               } else if (strncmp(s1, "noir", 4) == 0) {
-                       lmd->lmd_flags |= LMD_FLG_NOIR; /* test purpose only. */
+               } else if (strncmp(s1, "noir", 4) == 0) { /* test case only */
+                       set_bit(LMD_FLG_NOIR, lmd->lmd_flags);
                        clear++;
                } else if (strncmp(s1, "nosvc", 5) == 0) {
-                       lmd->lmd_flags |= LMD_FLG_NOSVC;
+                       set_bit(LMD_FLG_NOSVC, lmd->lmd_flags);
                        clear++;
                } else if (strncmp(s1, "nomgs", 5) == 0) {
-                       lmd->lmd_flags |= LMD_FLG_NOMGS;
+                       set_bit(LMD_FLG_NOMGS, lmd->lmd_flags);
                        clear++;
                } else if (strncmp(s1, "noscrub", 7) == 0) {
-                       lmd->lmd_flags |= LMD_FLG_NOSCRUB;
+                       set_bit(LMD_FLG_NOSCRUB, lmd->lmd_flags);
                        clear++;
                } else if (strncmp(s1, "skip_lfsck", 10) == 0) {
-                       lmd->lmd_flags |= LMD_FLG_SKIP_LFSCK;
+                       set_bit(LMD_FLG_SKIP_LFSCK, lmd->lmd_flags);
                        clear++;
                } else if (strncmp(s1, "rdonly_dev", 10) == 0) {
-                       lmd->lmd_flags |= LMD_FLG_DEV_RDONLY;
+                       set_bit(LMD_FLG_DEV_RDONLY, lmd->lmd_flags);
                        clear++;
                } else if (strncmp(s1, PARAM_MGSNODE,
                                   sizeof(PARAM_MGSNODE) - 1) == 0) {
@@ -1400,19 +1402,19 @@ int lmd_parse(char *options, struct lustre_mount_data *lmd)
                        s3 = s2;
                        clear++;
                } else if (strncmp(s1, "writeconf", 9) == 0) {
-                       lmd->lmd_flags |= LMD_FLG_WRITECONF;
+                       set_bit(LMD_FLG_WRITECONF, lmd->lmd_flags);
                        clear++;
                } else if (strncmp(s1, "nolocallogs", 11) == 0) {
-                       lmd->lmd_flags |= LMD_FLG_NO_LOCAL_LOGS;
+                       set_bit(LMD_FLG_NO_LOCAL_LOGS, lmd->lmd_flags);
                        clear++;
                } else if (strncmp(s1, "update", 6) == 0) {
-                       lmd->lmd_flags |= LMD_FLG_UPDATE;
+                       set_bit(LMD_FLG_UPDATE, lmd->lmd_flags);
                        clear++;
                } else if (strncmp(s1, "virgin", 6) == 0) {
-                       lmd->lmd_flags |= LMD_FLG_VIRGIN;
+                       set_bit(LMD_FLG_VIRGIN, lmd->lmd_flags);
                        clear++;
                } else if (strncmp(s1, "noprimnode", 10) == 0) {
-                       lmd->lmd_flags |= LMD_FLG_NO_PRIMNODE;
+                       set_bit(LMD_FLG_NO_PRIMNODE, lmd->lmd_flags);
                        clear++;
                } else if (strncmp(s1, "mgssec=", 7) == 0) {
                        rc = lmd_parse_mgssec(lmd, s1 + 7);
@@ -1427,7 +1429,7 @@ int lmd_parse(char *options, struct lustre_mount_data *lmd)
                        clear++;
                } else if (strncmp(s1, "mgs", 3) == 0) {
                        /* We are an MGS */
-                       lmd->lmd_flags |= LMD_FLG_MGS;
+                       set_bit(LMD_FLG_MGS, lmd->lmd_flags);
                        clear++;
                } else if (strncmp(s1, "svname=", 7) == 0) {
                        rc = lmd_parse_string(&lmd->lmd_profile, s1 + 7);
@@ -1460,7 +1462,7 @@ int lmd_parse(char *options, struct lustre_mount_data *lmd)
                        s3 = s1 + 6 + length;
                        clear++;
                } else if (strncmp(s1, "localrecov", 10) == 0) {
-                       lmd->lmd_flags |= LMD_FLG_LOCAL_RECOV;
+                       set_bit(LMD_FLG_LOCAL_RECOV, lmd->lmd_flags);
                        clear++;
                } else if (strncmp(s1, "osd=", 4) == 0) {
                        rc = lmd_parse_string(&lmd->lmd_osd_type, s1 + 4);
@@ -1519,7 +1521,7 @@ int lmd_parse(char *options, struct lustre_mount_data *lmd)
        s1 = strstr(devname, ":/");
        if (s1) {
                ++s1;
-               lmd->lmd_flags |= LMD_FLG_CLIENT;
+               set_bit(LMD_FLG_CLIENT, lmd->lmd_flags);
                /* Remove leading /s from fsname */
                while (*++s1 == '/')
                        ;
@@ -1583,7 +1585,6 @@ int lmd_parse(char *options, struct lustre_mount_data *lmd)
        }
 
        lmd_print(lmd);
-       lmd->lmd_magic = LMD_MAGIC;
 
        RETURN(rc);
 
index 10f2ebc..0c600d4 100644 (file)
@@ -162,7 +162,7 @@ out:
  */
 static int ofd_stack_init(const struct lu_env *env,
                          struct ofd_device *m, struct lustre_cfg *cfg,
-                         u32 *lmd_flags)
+                         unsigned long *lmd_flags)
 {
        const char              *dev = lustre_cfg_string(cfg, 0);
        struct lu_device        *d;
@@ -182,11 +182,11 @@ static int ofd_stack_init(const struct lu_env *env,
 
        lmd = s2lsi(lmi->lmi_sb)->lsi_lmd;
        if (lmd) {
-               if (lmd->lmd_flags & LMD_FLG_SKIP_LFSCK)
+               if (test_bit(LMD_FLG_SKIP_LFSCK, lmd->lmd_flags))
                        m->ofd_skip_lfsck = 1;
-               if (lmd->lmd_flags & LMD_FLG_NO_PRECREATE)
+               if (test_bit(LMD_FLG_NO_PRECREATE, lmd->lmd_flags))
                        m->ofd_no_precreate = 1;
-               *lmd_flags = lmd->lmd_flags;
+               bitmap_copy(lmd_flags, lmd->lmd_flags, LMD_FLG_NUM_FLAGS);
        }
 
        /* find bottom osd */
@@ -2939,10 +2939,10 @@ static int ofd_init0(const struct lu_env *env, struct ofd_device *m,
        struct ofd_thread_info *info = NULL;
        struct obd_device *obd;
        struct tg_grants_data *tgd = &m->ofd_lut.lut_tgd;
+       DECLARE_BITMAP(lmd_flags, LMD_FLG_NUM_FLAGS);
        struct lu_fid fid;
        struct nm_config_file *nodemap_config;
        struct obd_device_target *obt;
-       u32 lmd_flags = 0;
        int rc;
 
        ENTRY;
@@ -2997,7 +2997,7 @@ static int ofd_init0(const struct lu_env *env, struct ofd_device *m,
        if (info == NULL)
                RETURN(-EFAULT);
 
-       rc = ofd_stack_init(env, m, cfg, &lmd_flags);
+       rc = ofd_stack_init(env, m, cfg, lmd_flags);
        if (rc) {
                CERROR("%s: can't init device stack, rc %d\n",
                       obd->obd_name, rc);
@@ -3032,9 +3032,9 @@ static int ofd_init0(const struct lu_env *env, struct ofd_device *m,
        if (rc)
                GOTO(err_free_ns, rc);
 
-       if (lmd_flags & LMD_FLG_SKIP_LFSCK)
+       if (test_bit(LMD_FLG_SKIP_LFSCK, lmd_flags))
                m->ofd_skip_lfsck = 1;
-       if (lmd_flags & LMD_FLG_LOCAL_RECOV)
+       if (test_bit(LMD_FLG_LOCAL_RECOV, lmd_flags))
                m->ofd_lut.lut_local_recovery = 1;
 
        rc = ofd_tunables_init(m);
index 8a82f6a..2e5be01 100644 (file)
@@ -8215,7 +8215,7 @@ static int osd_mount(const struct lu_env *env,
                GOTO(out_mnt, rc = -EINVAL);
        }
 
-       if (lmd_flags & LMD_FLG_DEV_RDONLY) {
+       if (test_bit(LMD_FLG_DEV_RDONLY, &lmd_flags)) {
                LCONSOLE_WARN("%s: not support dev_rdonly on this device\n",
                              name);
 
@@ -8263,7 +8263,7 @@ static int osd_mount(const struct lu_env *env,
                }
        }
 
-       if (lmd_flags & LMD_FLG_NOSCRUB)
+       if (test_bit(LMD_FLG_NOSCRUB, &lmd_flags))
                o->od_scrub.os_scrub.os_auto_scrub_interval = AS_NEVER;
 
        if (blk_queue_nonrot(bdev_get_queue(osd_sb(o)->s_bdev))) {
index 7d1b579..2730788 100644 (file)
@@ -1128,13 +1128,13 @@ static int osd_mount(const struct lu_env *env,
                if (rc)
                        RETURN(-EINVAL);
 
-               if (flags & LMD_FLG_DEV_RDONLY) {
+               if (test_bit(LMD_FLG_DEV_RDONLY, &flags)) {
                        o->od_dt_dev.dd_rdonly = 1;
                        LCONSOLE_WARN("%s: set dev_rdonly on this device\n",
                                      svname);
                }
 
-               if (flags & LMD_FLG_NOSCRUB)
+               if (test_bit(LMD_FLG_NOSCRUB, &flags))
                        interval = AS_NEVER;
        }
 
index 54106c8..ca48aa4 100644 (file)
@@ -1177,7 +1177,7 @@ static int server_lsi2mti(struct lustre_sb_info *lsi,
                /* server use --servicenode param, only allow specified
                 * nids be registered
                 */
-               if ((lsi->lsi_lmd->lmd_flags & LMD_FLG_NO_PRIMNODE) != 0 &&
+               if (test_bit(LMD_FLG_NO_PRIMNODE, lsi->lsi_lmd->lmd_flags) &&
                    class_match_nid(lsi->lsi_lmd->lmd_params,
                                    PARAM_FAILNODE, &id.nid) < 1)
                        continue;
@@ -1497,12 +1497,15 @@ static int server_start_targets(struct super_block *sb)
        /* abort recovery only on the complete stack:
         * many devices can be involved
         */
-       if ((lsi->lsi_lmd->lmd_flags &
-            (LMD_FLG_ABORT_RECOV | LMD_FLG_ABORT_RECOV_MDT)) &&
+       if ((test_bit(LMD_FLG_ABORT_RECOV, lsi->lsi_lmd->lmd_flags) ||
+           (test_bit(LMD_FLG_ABORT_RECOV_MDT, lsi->lsi_lmd->lmd_flags))) &&
            (OBP(obd, iocontrol))) {
-               struct obd_ioctl_data karg = {
-                       .ioc_type = lsi->lsi_lmd->lmd_flags,
-               };
+               struct obd_ioctl_data karg;
+
+               if (test_bit(LMD_FLG_ABORT_RECOV, lsi->lsi_lmd->lmd_flags))
+                       karg.ioc_type = OBD_FLG_ABORT_RECOV_OST;
+               else
+                       karg.ioc_type = OBD_FLG_ABORT_RECOV_MDT;
 
                obd_iocontrol(OBD_IOC_ABORT_RECOVERY, obd->obd_self_export, 0,
                              &karg, NULL);
@@ -1563,10 +1566,10 @@ static int lsi_prepare(struct lustre_sb_info *lsi)
        /* Determine server type */
        rc = server_name2index(lsi->lsi_svname, &index, NULL);
        if (rc < 0) {
-               if (lsi->lsi_lmd->lmd_flags & LMD_FLG_MGS) {
+               if (test_bit(LMD_FLG_MGS, lsi->lsi_lmd->lmd_flags)) {
                        /* Assume we're a bare MGS */
                        rc = 0;
-                       lsi->lsi_lmd->lmd_flags |= LMD_FLG_NOSVC;
+                       set_bit(LMD_FLG_NOSVC, lsi->lsi_lmd->lmd_flags);
                } else {
                        LCONSOLE_ERROR("Can't determine server type of '%s'\n",
                                       lsi->lsi_svname);
@@ -1578,18 +1581,18 @@ static int lsi_prepare(struct lustre_sb_info *lsi)
        /* Add mount line flags that used to be in ldd:
         * writeconf, mgs, anything else?
         */
-       lsi->lsi_flags |= (lsi->lsi_lmd->lmd_flags & LMD_FLG_WRITECONF) ?
-               LDD_F_WRITECONF : 0;
-       lsi->lsi_flags |= (lsi->lsi_lmd->lmd_flags & LMD_FLG_NO_LOCAL_LOGS) ?
-               LDD_F_NO_LOCAL_LOGS : 0;
-       lsi->lsi_flags |= (lsi->lsi_lmd->lmd_flags & LMD_FLG_VIRGIN) ?
-               LDD_F_VIRGIN : 0;
-       lsi->lsi_flags |= (lsi->lsi_lmd->lmd_flags & LMD_FLG_UPDATE) ?
-               LDD_F_UPDATE : 0;
-       lsi->lsi_flags |= (lsi->lsi_lmd->lmd_flags & LMD_FLG_MGS) ?
-               LDD_F_SV_TYPE_MGS : 0;
-       lsi->lsi_flags |= (lsi->lsi_lmd->lmd_flags & LMD_FLG_NO_PRIMNODE) ?
-               LDD_F_NO_PRIMNODE : 0;
+       lsi->lsi_flags |= test_bit(LMD_FLG_WRITECONF, lsi->lsi_lmd->lmd_flags) ?
+                         LDD_F_WRITECONF : 0;
+       lsi->lsi_flags |= test_bit(LMD_FLG_NO_LOCAL_LOGS, lsi->lsi_lmd->lmd_flags) ?
+                         LDD_F_NO_LOCAL_LOGS : 0;
+       lsi->lsi_flags |= test_bit(LMD_FLG_VIRGIN, lsi->lsi_lmd->lmd_flags) ?
+                         LDD_F_VIRGIN : 0;
+       lsi->lsi_flags |= test_bit(LMD_FLG_UPDATE, lsi->lsi_lmd->lmd_flags) ?
+                         LDD_F_UPDATE : 0;
+       lsi->lsi_flags |= test_bit(LMD_FLG_MGS, lsi->lsi_lmd->lmd_flags) ?
+                         LDD_F_SV_TYPE_MGS : 0;
+       lsi->lsi_flags |= test_bit(LMD_FLG_NO_PRIMNODE, lsi->lsi_lmd->lmd_flags) ?
+                         LDD_F_NO_PRIMNODE : 0;
 
        RETURN(0);
 }
@@ -1614,7 +1617,7 @@ static void server_put_super(struct super_block *sb)
        OBD_ALLOC(tmpname, tmpname_sz);
        memcpy(tmpname, lsi->lsi_svname, tmpname_sz);
        CDEBUG(D_MOUNT, "server put_super %s\n", tmpname);
-       if (IS_MDT(lsi) && (lsi->lsi_lmd->lmd_flags & LMD_FLG_NOSVC))
+       if (IS_MDT(lsi) && test_bit(LMD_FLG_NOSVC, lsi->lsi_lmd->lmd_flags))
                snprintf(tmpname, tmpname_sz, "MGS");
 
        /* disconnect the lwp first to drain off the inflight request */
@@ -1629,7 +1632,7 @@ static void server_put_super(struct super_block *sb)
        }
 
        /* Stop the target */
-       if (!(lsi->lsi_lmd->lmd_flags & LMD_FLG_NOSVC) &&
+       if (!test_bit(LMD_FLG_NOSVC, lsi->lsi_lmd->lmd_flags) &&
            (IS_MDT(lsi) || IS_OST(lsi))) {
                struct lustre_profile *lprof = NULL;
 
@@ -1680,7 +1683,7 @@ static void server_put_super(struct super_block *sb)
        lustre_stop_mgc(sb);
        if (IS_MGS(lsi)) {
                /* if MDS start with --nomgs, don't stop MGS then */
-               if (!(lsi->lsi_lmd->lmd_flags & LMD_FLG_NOMGS))
+               if (!test_bit(LMD_FLG_NOMGS, lsi->lsi_lmd->lmd_flags))
                        server_stop_mgs(sb);
        }
 
@@ -1791,8 +1794,7 @@ int server_show_options(struct seq_file *seq, struct dentry *dentry)
                         * Also, if server is mounted with "rdonly_dev"
                         * (LMD_FLG_DEV_RDONLY) then force flag to be 'ro'
                         */
-
-                       if (!(lmd->lmd_flags & LMD_FLG_DEV_RDONLY) &&
+                       if (!test_bit(LMD_FLG_DEV_RDONLY, lmd->lmd_flags) &&
                            !(osfs.os_state & OS_STATFS_READONLY))
                                sb->s_flags &= ~SB_RDONLY;
                }
@@ -1800,27 +1802,28 @@ int server_show_options(struct seq_file *seq, struct dentry *dentry)
 
        seq_printf(seq, ",svname=%s", lmd->lmd_profile);
 
-       if  (lmd->lmd_flags & LMD_FLG_ABORT_RECOV)
+       if (test_bit(LMD_FLG_ABORT_RECOV, lmd->lmd_flags))
                seq_puts(seq, ",abort_recov");
 
-       if (lmd->lmd_flags & LMD_FLG_NOIR)
+       if (test_bit(LMD_FLG_NOIR, lmd->lmd_flags))
                seq_puts(seq, ",noir");
 
-       if (lmd->lmd_flags & LMD_FLG_NOSVC)
+       if (test_bit(LMD_FLG_NOSVC, lmd->lmd_flags))
                seq_puts(seq, ",nosvc");
 
-       if (lmd->lmd_flags & LMD_FLG_NOMGS)
+       if (test_bit(LMD_FLG_NOMGS, lmd->lmd_flags))
                seq_puts(seq, ",nomgs");
 
-       if (lmd->lmd_flags & LMD_FLG_NOSCRUB)
+       if (test_bit(LMD_FLG_NOSCRUB, lmd->lmd_flags))
                seq_puts(seq, ",noscrub");
-       if (lmd->lmd_flags & LMD_FLG_SKIP_LFSCK)
+
+       if (test_bit(LMD_FLG_SKIP_LFSCK, lmd->lmd_flags))
                seq_puts(seq, ",skip_lfsck");
 
-       if (lmd->lmd_flags & LMD_FLG_DEV_RDONLY)
+       if (test_bit(LMD_FLG_DEV_RDONLY, lmd->lmd_flags))
                seq_puts(seq, ",rdonly_dev");
 
-       if (lmd->lmd_flags & LMD_FLG_MGS)
+       if (test_bit(LMD_FLG_MGS, lmd->lmd_flags))
                seq_puts(seq, ",mgs");
 
        if (lmd->lmd_mgs)
@@ -1965,6 +1968,7 @@ static int osd_start(struct lustre_sb_info *lsi, unsigned long mflags)
        struct obd_device *obd;
        struct dt_device_param p;
        char flagstr[20 + 1 + 10 + 1];
+       u32 lmd_flags;
        int rc;
 
        ENTRY;
@@ -1975,7 +1979,8 @@ static int osd_start(struct lustre_sb_info *lsi, unsigned long mflags)
        sprintf(lsi->lsi_osd_obdname, "%s-osd", lsi->lsi_svname);
        strcpy(lsi->lsi_osd_uuid, lsi->lsi_osd_obdname);
        strcat(lsi->lsi_osd_uuid, "_UUID");
-       snprintf(flagstr, sizeof(flagstr), "%lu:%u", mflags, lmd->lmd_flags);
+       bitmap_to_arr32(&lmd_flags, lmd->lmd_flags, LMD_FLG_NUM_FLAGS);
+       snprintf(flagstr, sizeof(flagstr), "%lu:%u", mflags, lmd_flags);
 
        obd = class_name2obd(lsi->lsi_osd_obdname);
        if (!obd) {
@@ -1993,10 +1998,10 @@ static int osd_start(struct lustre_sb_info *lsi, unsigned long mflags)
                /* but continue setup to allow special case of MDT and internal
                 * MGT being started separately.
                 */
-               if (!((IS_MGS(lsi) && (lsi->lsi_lmd->lmd_flags &
-                                     LMD_FLG_NOMGS)) ||
-                    (IS_MDT(lsi) && (lsi->lsi_lmd->lmd_flags &
-                                     LMD_FLG_NOSVC))))
+               if (!((IS_MGS(lsi) &&
+                      test_bit(LMD_FLG_NOMGS, lsi->lsi_lmd->lmd_flags)) ||
+                    (IS_MDT(lsi) &&
+                     test_bit(LMD_FLG_NOSVC, lsi->lsi_lmd->lmd_flags))))
                        RETURN(-EALREADY);
        }
 
@@ -2065,7 +2070,7 @@ int server_fill_super(struct super_block *sb)
        }
 
        /* Start MGS before MGC */
-       if (IS_MGS(lsi) && !(lsi->lsi_lmd->lmd_flags & LMD_FLG_NOMGS)) {
+       if (IS_MGS(lsi) && !test_bit(LMD_FLG_NOMGS, lsi->lsi_lmd->lmd_flags)) {
                rc = server_start_mgs(sb);
                if (rc < 0)
                        GOTO(out_mnt, rc);
@@ -2077,7 +2082,7 @@ int server_fill_super(struct super_block *sb)
                GOTO(out_mnt, rc);
 
        /* Set up all obd devices for service */
-       if (!(lsi->lsi_lmd->lmd_flags & LMD_FLG_NOSVC) &&
+       if (!test_bit(LMD_FLG_NOSVC, lsi->lsi_lmd->lmd_flags) &&
            (IS_OST(lsi) || IS_MDT(lsi))) {
                rc = server_start_targets(sb);
                if (rc < 0) {
@@ -2131,7 +2136,7 @@ void server_calc_timeout(struct lustre_sb_info *lsi, struct obd_device *obd)
        if (lmd) {
                soft   = lmd->lmd_recovery_time_soft;
                hard   = lmd->lmd_recovery_time_hard;
-               has_ir = has_ir && !(lmd->lmd_flags & LMD_FLG_NOIR);
+               has_ir = has_ir && !test_bit(LMD_FLG_NOIR, lmd->lmd_flags);
                obd->obd_no_ir = !has_ir;
        }