Whamcloud - gitweb
b=22458 consolidate fs_db flags.
authorEric Mei <eric.mei@oracle.com>
Thu, 10 Jun 2010 02:15:37 +0000 (20:15 -0600)
committerRobert Read <robert.read@oracle.com>
Thu, 10 Jun 2010 04:29:36 +0000 (21:29 -0700)
i=rread
i=adilger

lustre/mgs/lproc_mgs.c
lustre/mgs/mgs_handler.c
lustre/mgs/mgs_internal.h
lustre/mgs/mgs_llog.c

index 2d93e54..1801c04 100644 (file)
@@ -196,7 +196,7 @@ static int mgs_live_seq_show(struct seq_file *seq, void *v)
         cfs_down(&fsdb->fsdb_sem);
 
         seq_printf(seq, "fsname: %s\n", fsdb->fsdb_name);
-        seq_printf(seq, "flags: %#x     gen: %d\n",
+        seq_printf(seq, "flags: %#lx     gen: %d\n",
                    fsdb->fsdb_flags, fsdb->fsdb_gen);
         for (i = 0; i < INDEX_MAP_SIZE * 8; i++)
                  if (cfs_test_bit(i, fsdb->fsdb_mdt_index_map))
index fbbea81..76859e4 100644 (file)
@@ -357,10 +357,10 @@ void mgs_revoke_lock(struct obd_device *obd, struct fs_db *fsdb)
 
         LASSERT(fsdb->fsdb_name[0] != '\0');
 
-        if (cfs_test_and_set_bit(1, &fsdb->fsdb_revoking_lock) == 0) {
+        if (cfs_test_and_set_bit(FSDB_REVOKING_LOCK, &fsdb->fsdb_flags) == 0) {
                 lockrc = mgs_get_cfg_lock(obd, fsdb->fsdb_name, &lockh);
                 /* clear the bit before lock put */
-                cfs_clear_bit(1, &fsdb->fsdb_revoking_lock);
+                cfs_clear_bit(FSDB_REVOKING_LOCK, &fsdb->fsdb_flags);
 
                 if (lockrc != ELDLM_OK)
                         CERROR("lock error %d for fs %s\n",
index 314610e..2cb320a 100644 (file)
@@ -61,8 +61,13 @@ struct mgs_tgt_srpc_conf {
 };
 
 #define INDEX_MAP_SIZE  8192     /* covers indicies to FFFF */
-#define FSDB_LOG_EMPTY  0x0001  /* missing client log */
-#define FSDB_OLDLOG14   0x0002  /* log starts in old (1.4) style */
+
+#define FSDB_LOG_EMPTY          (0)  /* missing client log */
+#define FSDB_OLDLOG14           (1)  /* log starts in old (1.4) style */
+#define FSDB_REVOKING_LOCK      (2)  /* DLM lock is being revoked */
+#define FSDB_MGS_SELF           (3)  /* for '_mgs', used by sptlrpc */
+#define FSDB_OSCNAME18          (4)  /* old 1.8 style OSC naming */
+#define FSDB_UDESC              (5)  /* sptlrpc user desc, will be obsolete */
 
 
 struct fs_db {
@@ -79,17 +84,12 @@ struct fs_db {
         char             *fsdb_mdtlmv;
         char             *fsdb_mdc;          /* COMPAT_146 mdc name */
         /* end COMPAT_146 */
-        __u32             fsdb_flags;
+        unsigned long     fsdb_flags;
         __u32             fsdb_gen;
 
-        __u8              fsdb_revoking_lock;  /* lock is being revoked */
-
         /* in-memory copy of the srpc rules, guarded by fsdb_sem */
         struct sptlrpc_rule_set   fsdb_srpc_gen;
         struct mgs_tgt_srpc_conf *fsdb_srpc_tgt;
-        unsigned int              fsdb_fl_udesc:1,
-                                  fsdb_fl_mgsself:1,
-                                  fsdb_fl_oscname_18:1;
 };
 
 int mgs_init_fsdb_list(struct obd_device *obd);
index 150766e..1310334 100644 (file)
@@ -201,7 +201,7 @@ static int mgs_fsdb_handler(struct llog_handle *llh, struct llog_rec_hdr *rec,
         /* #01 L attach 0:lov_mdsA 1:lov 2:cdbe9_lov_mdsA_dc8cf7f3bb */
         if ((fsdb->fsdb_gen == 0) && (lcfg->lcfg_command == LCFG_ATTACH) &&
             (strcmp(lustre_cfg_string(lcfg, 1), LUSTRE_LOV_NAME) == 0)) {
-                fsdb->fsdb_flags |= FSDB_OLDLOG14;
+                cfs_set_bit(FSDB_OLDLOG14, &fsdb->fsdb_flags);
                 name_destroy(&fsdb->fsdb_clilov);
                 rc = name_create(&fsdb->fsdb_clilov,
                                  lustre_cfg_string(lcfg, 0), "");
@@ -214,7 +214,7 @@ static int mgs_fsdb_handler(struct llog_handle *llh, struct llog_rec_hdr *rec,
         if ((fsdb->fsdb_gen == 0) && (lcfg->lcfg_command == LCFG_SETUP) &&
             (strncmp(lustre_cfg_string(lcfg, 0), "MDC_", 4) == 0)) {
                 char *ptr;
-                fsdb->fsdb_flags |= FSDB_OLDLOG14;
+                cfs_set_bit(FSDB_OLDLOG14, &fsdb->fsdb_flags);
                 ptr = strstr(lustre_cfg_string(lcfg, 1), "_UUID");
                 if (!ptr) {
                         CERROR("Can't parse MDT uuid %s\n",
@@ -239,13 +239,13 @@ static int mgs_fsdb_handler(struct llog_handle *llh, struct llog_rec_hdr *rec,
         /*
          * compat to 1.8, check osc name used by MDT0 to OSTs, bz18548.
          */
-        if (fsdb->fsdb_fl_oscname_18 == 0 &&
+        if (!cfs_test_bit(FSDB_OSCNAME18, &fsdb->fsdb_flags) &&
             lcfg->lcfg_command == LCFG_ATTACH &&
             strcmp(lustre_cfg_string(lcfg, 1), LUSTRE_OSC_NAME) == 0) {
                 if (OBD_OCD_VERSION_MAJOR(d->ver) == 1 &&
                     OBD_OCD_VERSION_MINOR(d->ver) <= 8) {
                         CWARN("MDT using 1.8 OSC name scheme\n");
-                        fsdb->fsdb_fl_oscname_18 = 1;
+                        cfs_set_bit(FSDB_OSCNAME18, &fsdb->fsdb_flags);
                 }
         }
 
@@ -287,7 +287,7 @@ static int mgs_get_fsdb_from_llog(struct obd_device *obd, struct fs_db *fsdb)
                 GOTO(out_close, rc);
 
         if (llog_get_size(loghandle) <= 1)
-                fsdb->fsdb_flags |= FSDB_LOG_EMPTY;
+                cfs_set_bit(FSDB_LOG_EMPTY, &fsdb->fsdb_flags);
 
         rc = llog_process(loghandle, mgs_fsdb_handler, (void *) &d, NULL);
         CDEBUG(D_INFO, "get_db = %d\n", rc);
@@ -357,10 +357,10 @@ static struct fs_db *mgs_new_fsdb(struct obd_device *obd, char *fsname)
 
         strcpy(fsdb->fsdb_name, fsname);
         cfs_sema_init(&fsdb->fsdb_sem, 1);
-        fsdb->fsdb_fl_udesc = 1;
+        cfs_set_bit(FSDB_UDESC, &fsdb->fsdb_flags);
 
         if (strcmp(fsname, MGSSELF_NAME) == 0) {
-                fsdb->fsdb_fl_mgsself = 1;
+                cfs_set_bit(FSDB_MGS_SELF, &fsdb->fsdb_flags);
         } else {
                 OBD_ALLOC(fsdb->fsdb_ost_index_map, INDEX_MAP_SIZE);
                 OBD_ALLOC(fsdb->fsdb_mdt_index_map, INDEX_MAP_SIZE);
@@ -462,7 +462,7 @@ int mgs_find_or_make_fsdb(struct obd_device *obd, char *name,
         if (!fsdb)
                 return -ENOMEM;
 
-        if (!fsdb->fsdb_fl_mgsself) {
+        if (!cfs_test_bit(FSDB_MGS_SELF, &fsdb->fsdb_flags)) {
                 /* populate the db from the client llog */
                 rc = mgs_get_fsdb_from_llog(obd, fsdb);
                 if (rc) {
@@ -503,7 +503,7 @@ int mgs_check_index(struct obd_device *obd, struct mgs_target_info *mti)
                 RETURN(rc);
         }
 
-        if (fsdb->fsdb_flags & FSDB_LOG_EMPTY)
+        if (cfs_test_bit(FSDB_LOG_EMPTY, &fsdb->fsdb_flags))
                 RETURN(-1);
 
         if (mti->mti_flags & LDD_F_SV_TYPE_OST)
@@ -593,7 +593,7 @@ static int mgs_set_index(struct obd_device *obd, struct mgs_target_info *mti)
         }
 
         cfs_set_bit(mti->mti_stripe_index, imap);
-        fsdb->fsdb_flags &= ~FSDB_LOG_EMPTY;
+        cfs_clear_bit(FSDB_LOG_EMPTY, &fsdb->fsdb_flags);
         server_make_name(mti->mti_flags, mti->mti_stripe_index,
                          mti->mti_fsname, mti->mti_svname);
 
@@ -1531,7 +1531,7 @@ static void name_create_mdt_and_lov(char **logname, char **lovname,
 {
         name_create_mdt(logname, fsdb->fsdb_name, i);
         /* COMPAT_180 */
-        if (i == 0 && fsdb->fsdb_fl_oscname_18)
+        if (i == 0 && cfs_test_bit(FSDB_OSCNAME18, &fsdb->fsdb_flags))
                 name_create(lovname, fsdb->fsdb_name, "-mdtlov");
         else
                 name_create(lovname, *logname, "-mdtlov");
@@ -1542,7 +1542,7 @@ static inline void name_create_mdt_osc(char **oscname, char *ostname,
 {
         char suffix[16];
 
-        if (i == 0 && fsdb->fsdb_fl_oscname_18)
+        if (i == 0 && cfs_test_bit(FSDB_OSCNAME18, &fsdb->fsdb_flags))
                 sprintf(suffix, "-osc");
         else
                 sprintf(suffix, "-osc-MDT%04x", i);
@@ -1785,7 +1785,7 @@ static int mgs_write_log_ost(struct obd_device *obd, struct fs_db *fsdb,
         /* We also have to update the other logs where this osc is part of
            the lov */
 
-        if (fsdb->fsdb_flags & FSDB_OLDLOG14) {
+        if (cfs_test_bit(FSDB_OLDLOG14, &fsdb->fsdb_flags)) {
                 /* If we're upgrading, the old mdt log already has our
                    entry. Let's do a fake one for fun. */
                 /* Note that we can't add any new failnids, since we don't
@@ -2086,10 +2086,10 @@ static int mgs_srpc_set_param_udesc_mem(struct fs_db *fsdb,
                 goto error_out;
 
         if (strcmp(ptr, "yes") == 0) {
-                fsdb->fsdb_fl_udesc = 1;
+                cfs_set_bit(FSDB_UDESC, &fsdb->fsdb_flags);
                 CWARN("Enable user descriptor shipping from client to MDT\n");
         } else if (strcmp(ptr, "no") == 0) {
-                fsdb->fsdb_fl_udesc = 0;
+                cfs_clear_bit(FSDB_UDESC, &fsdb->fsdb_flags);
                 CWARN("Disable user descriptor shipping from client to MDT\n");
         } else {
                 *(ptr - 1) = '=';
@@ -2133,7 +2133,7 @@ static int mgs_srpc_set_param_mem(struct fs_db *fsdb,
                 RETURN(rc);
 
         /* mgs rules implies must be mgc->mgs */
-        if (fsdb->fsdb_fl_mgsself) {
+        if (cfs_test_bit(FSDB_MGS_SELF, &fsdb->fsdb_flags)) {
                 if ((rule.sr_from != LUSTRE_SP_MGC &&
                      rule.sr_from != LUSTRE_SP_ANY) ||
                     (rule.sr_to != LUSTRE_SP_MGS &&
@@ -2219,7 +2219,7 @@ static int mgs_srpc_set_param(struct obd_device *obd,
         if (rc)
                 goto out_free;
 
-        if (fsdb->fsdb_fl_mgsself) {
+        if (cfs_test_bit(FSDB_MGS_SELF, &fsdb->fsdb_flags)) {
                 /*
                  * for mgs rules, make them effective immediately.
                  */
@@ -2451,7 +2451,7 @@ static int mgs_write_log_param(struct obd_device *obd, struct fs_db *fsdb,
                                            "changes were made to the "
                                            "config log.\n",
                                            mti->mti_svname, rc);
-                        if (fsdb->fsdb_flags & FSDB_OLDLOG14)
+                        if (cfs_test_bit(FSDB_OLDLOG14, &fsdb->fsdb_flags))
                                 LCONSOLE_ERROR_MSG(0x146, "This may be"
                                                    " because the log"
                                                    "is in the old 1.4"
@@ -2517,7 +2517,7 @@ static int mgs_write_log_param(struct obd_device *obd, struct fs_db *fsdb,
                                             "-mdc");
                 } else if (mti->mti_flags & LDD_F_SV_TYPE_OST) {
                         /* COMPAT_146 */
-                        if (fsdb->fsdb_flags & FSDB_OLDLOG14) {
+                        if (cfs_test_bit(FSDB_OLDLOG14, &fsdb->fsdb_flags)) {
                                 LCONSOLE_ERROR_MSG(0x148, "Upgraded "
                                                    "client logs for %s"
                                                    " cannot be "
@@ -2781,7 +2781,7 @@ int mgs_upgrade_sv_14(struct obd_device *obd, struct mgs_target_info *mti,
         LCONSOLE_INFO("upgrading server %s from pre-1.6\n", mti->mti_svname);
         server_mti_print("upgrade", mti);
 
-        if (fsdb->fsdb_flags & FSDB_LOG_EMPTY) {
+        if (cfs_test_bit(FSDB_LOG_EMPTY, &fsdb->fsdb_flags)) {
                 LCONSOLE_ERROR_MSG(0x14a, "The old client log %s-client is "
                                    "missing.  Was tunefs.lustre successful?\n",
                                    mti->mti_fsname);
@@ -2814,7 +2814,7 @@ int mgs_upgrade_sv_14(struct obd_device *obd, struct mgs_target_info *mti,
                 }
         }
 
-        if (!(fsdb->fsdb_flags & FSDB_OLDLOG14)) {
+        if (!cfs_test_bit(FSDB_OLDLOG14, &fsdb->fsdb_flags)) {
                 LCONSOLE_ERROR_MSG(0x14c, "%s-client is supposedly an old "
                                    "log, but no old LOV or MDT was found. "
                                    "Consider updating the configuration with"
@@ -2973,7 +2973,8 @@ int mgs_setparam(struct obd_device *obd, struct lustre_cfg *lcfg, char *fsname)
         rc = mgs_find_or_make_fsdb(obd, fsname, &fsdb);
         if (rc)
                 RETURN(rc);
-        if (!fsdb->fsdb_fl_mgsself && fsdb->fsdb_flags & FSDB_LOG_EMPTY) {
+        if (!cfs_test_bit(FSDB_MGS_SELF, &fsdb->fsdb_flags) &&
+            cfs_test_bit(FSDB_LOG_EMPTY, &fsdb->fsdb_flags)) {
                 CERROR("No filesystem targets for %s.  cfg_device from lctl "
                        "is '%s'\n", fsname, devname);
                 mgs_free_fsdb(obd, fsdb);
@@ -3052,7 +3053,7 @@ int mgs_pool_cmd(struct obd_device *obd, enum lcfg_command_type cmd,
                 CERROR("Can't get db for %s\n", fsname);
                 RETURN(rc);
         }
-        if (fsdb->fsdb_flags & FSDB_LOG_EMPTY) {
+        if (cfs_test_bit(FSDB_LOG_EMPTY, &fsdb->fsdb_flags)) {
                 CERROR("%s is not defined\n", fsname);
                 mgs_free_fsdb(obd, fsdb);
                 RETURN(-EINVAL);