Whamcloud - gitweb
Branch b1_4_mountconf
authornathan <nathan>
Tue, 31 Jan 2006 19:03:42 +0000 (19:03 +0000)
committernathan <nathan>
Tue, 31 Jan 2006 19:03:42 +0000 (19:03 +0000)
b=9860
interop with 1.4.6
- add "optional" lcfg command flag
- add ldd feature compat flags
- add old client connect hack

lustre/include/linux/lustre_cfg.h
lustre/include/linux/lustre_disk.h
lustre/ldlm/ldlm_lib.c
lustre/mgc/mgc_request.c
lustre/mgs/mgs_handler.c
lustre/mgs/mgs_llog.c
lustre/obdclass/llog_lvfs.c
lustre/obdclass/obd_config.c
lustre/obdclass/obd_mount.c
lustre/utils/mkfs_lustre.c

index 86f3b2b..971f2f1 100644 (file)
@@ -33,6 +33,9 @@
 #define LCFG_HDR_SIZE(count) \
     size_round(offsetof (struct lustre_cfg, lcfg_buflens[(count)]))
 
+/* If not LCFG_REQUIRED, we can ignore this cmd and go on. */
+#define LCFG_REQUIRED         0x0001000
+
 enum lcfg_command_type {
         LCFG_ATTACH         = 0x00cf001,
         LCFG_DETACH         = 0x00cf002,
@@ -48,10 +51,10 @@ enum lcfg_command_type {
         LCFG_DEL_CONN       = 0x00cf00c,
         LCFG_LOV_ADD_OBD    = 0x00cf00d,
         LCFG_LOV_DEL_OBD    = 0x00cf00e,
-        LCFG_PARAM          = 0x00cf00f,
-        LCFG_MARKER         = 0x00cf010,
-        LCFG_LOG_START      = 0x00cf011,
-        LCFG_LOG_END        = 0x00cf012,
+        LCFG_PARAM          = 0x00ce00f,
+        LCFG_MARKER         = 0x00ce010,
+        LCFG_LOG_START      = 0x00ce011,
+        LCFG_LOG_END        = 0x00ce012,
 };
 
 struct lustre_cfg_bufs {
index 6934c00..d751c6b 100644 (file)
@@ -38,7 +38,7 @@
 #define MOUNT_DATA_FILE   MOUNT_CONFIGS_DIR"/mountdata"
 #define MDT_LOGS_DIR      "LOGS"  /* COMPAT_146 */
 
-#define LDD_MAGIC 0xbabb0001
+#define LDD_MAGIC 0x1dd00001
 
 #define LDD_F_SV_TYPE_MDT   0x0001
 #define LDD_F_SV_TYPE_OST   0x0002
@@ -72,9 +72,17 @@ static inline char *mt_str(enum ldd_mount_type mt)
 #define MTI_NIDS_MAX 10
 #endif
 
+#define LDD_INCOMPAT_SUPP 0
+#define LDD_ROCOMPAT_SUPP 0
+
+/* FIXME does on-disk ldd have to be a fixed endianness? (like last_rcvd) */
 struct lustre_disk_data {
         __u32      ldd_magic;
-        __u32      ldd_config_ver;      /* not used? */
+        __u32      ldd_feature_compat;  /* compatible feature flags */
+        __u32      ldd_feature_rocompat;/* read-only compatible feature flags */
+        __u32      ldd_feature_incompat;/* incompatible feature flags */
+        
+        __u32      ldd_config_ver;      /* config rewrite count - not used */
         __u32      ldd_flags;           /* LDD_SV_TYPE */
         enum ldd_mount_type ldd_mount_type;  /* target fs type LDD_MT_* */
         char       ldd_fsname[64];      /* filesystem this server is part of */
@@ -84,7 +92,7 @@ struct lustre_disk_data {
         __u16      ldd_mgsnid_count;
         __u16      ldd_failnid_count;   /* server failover nid count */
         lnet_nid_t ldd_mgsnid[MTI_NIDS_MAX];  /* mgmt nid list; lmd can 
-                                                     override */
+                                                 override */
         lnet_nid_t ldd_failnid[MTI_NIDS_MAX]; /* server failover nids */
         char       ldd_mount_opts[2048]; /* target fs mount opts */
         
index 4462487..a81742b 100644 (file)
@@ -537,9 +537,18 @@ int target_handle_connect(struct ptlrpc_request *req, svc_handler_t handler)
 
         obd_str2uuid (&tgtuuid, str);
         target = class_uuid2obd(&tgtuuid);
+        /* COMPAT_146 */
         if (!target) {
                 target = class_name2obd(str);
         }
+        /* old (pre 1.6) lustre_process_log tries to connect to mdsname
+           (eg. mdsA) instead of uuid.  Since 1.6 changes names, the above
+           hack fails. */
+        if (!target) {
+                snprintf((char *)tgtuuid.uuid, sizeof(tgtuuid), "%s_UUID", str);
+                target = class_uuid2obd(&tgtuuid);
+        }
+        /* end COMPAT_146 */
 
         if (!target || target->obd_stopping || !target->obd_set_up) {
                 DEBUG_REQ(D_ERROR, req, "UUID '%s' is not available "
index f5bd637..30a2282 100644 (file)
@@ -848,7 +848,9 @@ static int mgc_process_config(struct obd_device *obd, obd_count len, void *buf)
         }
         case LCFG_LOV_DEL_OBD: 
                 /* Unimplemented */
-                LASSERT(0);
+                CERROR("lov_del_obd unimplemented\n");
+                rc = -ENOSYS;
+                break;
         case LCFG_LOG_START: {
                 struct config_llog_data *cld;
                 struct config_llog_instance *cfg;
index 88fafd6..0f2ff3d 100644 (file)
@@ -325,6 +325,7 @@ static int mgs_handle_target_add(struct ptlrpc_request *req)
                                lockrc);
         }
 
+        /* COMPAT_146 */
         if (mti->mti_flags & LDD_F_UPGRADE14) {
                 CDEBUG(D_MGS, "upgrading fs %s from pre-1.6\n", 
                        mti->mti_fsname); 
@@ -339,6 +340,7 @@ static int mgs_handle_target_add(struct ptlrpc_request *req)
 
                 mti->mti_flags &= ~LDD_F_UPGRADE14;
         }
+        /* end COMPAT_146 */
 
         if (mti->mti_flags & LDD_F_NEED_REGISTER) {
                 CDEBUG(D_MGS, "adding %s, index=%d\n", mti->mti_svname, 
index 2be2cb1..52e262f 100644 (file)
@@ -985,6 +985,8 @@ int mgs_write_log_target(struct obd_device *obd,
         return rc;
 }
 
+
+/* COMPAT_146 */
 /***************** upgrade pre-mountconf logs to mountconf *****************/
 
 int mgs_upgrade_logs_14(struct obd_device *obd, struct fs_db *db, 
@@ -1118,6 +1120,7 @@ int mgs_upgrade_sv_14(struct obd_device *obd, struct mgs_target_info *mti)
 
         RETURN(rc);
 }
+/* end COMPAT_146 */
 
 /******************** unused *********************/
 
index 40a82e3..bcde8e7 100644 (file)
@@ -578,7 +578,7 @@ static int llog_lvfs_create(struct llog_ctxt *ctxt, struct llog_handle **res,
 
         } else if (name) {
                 /* COMPAT_146 */
-                if (obd->obd_type->typ_name == LUSTRE_MDS_NAME) {
+                if (strcmp(obd->obd_type->typ_name, LUSTRE_MDS_NAME) == 0) {
                         handle->lgh_file = llog_filp_open(MDT_LOGS_DIR, name, 
                                                           open_flags, 0644);
                 } else {
@@ -659,7 +659,7 @@ static int llog_lvfs_destroy(struct llog_handle *handle)
         ENTRY;
 
         /* COMPAT_146 */
-        if (obd->obd_type->typ_name == LUSTRE_MDS_NAME)
+        if (strcmp(obd->obd_type->typ_name, LUSTRE_MDS_NAME) == 0)
                 dir = MDT_LOGS_DIR;
         else
                 /* end COMPAT_146 */
index 5c5c3fe..c8c039d 100644 (file)
@@ -700,6 +700,11 @@ int class_process_config(struct lustre_cfg *lcfg)
         }
         }
 out:
+        if ((err == -ENOSYS || err == -EINVAL) && 
+            !(lcfg->lcfg_command & LCFG_REQUIRED)) {
+                CWARN("Skipping optional command %#x\n", lcfg->lcfg_command);
+                err = 0;
+        }
         return err;
 }
 
index 86127d5..aa734af 100644 (file)
@@ -297,6 +297,7 @@ static int ldd_parse(struct lvfs_run_ctxt *mount_ctxt,
                        MOUNT_DATA_FILE, rc, len);
                 GOTO(out_close, rc = -EINVAL);
         }
+        rc = 0;
 
         if (ldd->ldd_magic != LDD_MAGIC) {
                 CERROR("Bad magic in %s: %x!=%x\n", MOUNT_DATA_FILE, 
@@ -304,7 +305,20 @@ static int ldd_parse(struct lvfs_run_ctxt *mount_ctxt,
                 GOTO(out_close, rc = -EINVAL);
         }
         
-        rc = 0;
+        if (ldd->ldd_feature_incompat & ~LDD_INCOMPAT_SUPP) {
+                CERROR("%s: unsupported incompat filesystem feature(s) %x\n",
+                       ldd->ldd_svname, 
+                       ldd->ldd_feature_incompat & ~LDD_INCOMPAT_SUPP);
+                GOTO(out_close, rc = -EINVAL);
+        }
+        if (ldd->ldd_feature_rocompat & ~LDD_ROCOMPAT_SUPP) {
+                CERROR("%s: unsupported read-only filesystem feature(s) %x\n",
+                       ldd->ldd_svname,  
+                       ldd->ldd_feature_rocompat & ~LDD_ROCOMPAT_SUPP);
+                /* Do something like remount filesystem read-only */
+                GOTO(out_close, rc = -EINVAL);
+        }
+
         ldd_print(ldd);
 
 out_close:
index f520fc7..a02199e 100644 (file)
@@ -91,6 +91,8 @@ void usage(FILE *out)
 #ifndef TUNEFS
                 "\t\t--mkfsoptions=<opts> : format options\n"
                 "\t\t--reformat: overwrite an existing disk\n"
+#else
+                "\t\t--nomgs: turn off MGS service on this MDT\n"
 #endif
                 "\t\t--print: just report what we would do; don't write to "
                 "disk\n"
@@ -610,12 +612,14 @@ int write_local_files(struct mkfs_opts *mop)
         fwrite(&mop->mo_ldd, sizeof(mop->mo_ldd), 1, filep);
         fclose(filep);
         
+        /* COMPAT_146 */
 #ifdef TUNEFS
         /* Check for upgrade */
         if ((mop->mo_ldd.ldd_flags & (LDD_F_UPGRADE14 | LDD_F_SV_TYPE_MGS)) 
             == (LDD_F_UPGRADE14 | LDD_F_SV_TYPE_MGS)) {
-                /* Copy the old logs to fsname-client, fsname-mdt */
+                char *term;
                 vprint("Copying old logs\n");
+                /* Copy the old logs to fsname-client, fsname-mdt */
                 sprintf(filepnm, "%s/%s/%s-client", 
                         mntpt, MOUNT_CONFIGS_DIR, mop->mo_ldd.ldd_fsname);
                 sprintf(cmd, "cp %s/%s/client %s", mntpt, MDT_LOGS_DIR,
@@ -633,16 +637,39 @@ int write_local_files(struct mkfs_opts *mop)
                                 mop->mo_device, 
                                 mop->mo_ldd.ldd_fsname, MOUNT_CONFIGS_DIR,
                                 mop->mo_ldd.ldd_fsname);
-                        ret = 1;
                         goto out_umnt;
                 }
-                /* copy the mdt log as well - name from mdt_UUID 
+                /* Copy the mdt log as well - name from mdt_UUID 
                    to fsname-MDT0000 */
-                /* FIXME Yuk - parse the client log to find mdt name? */
-                //filep = fopen(filepnm, "r");
-
+                ret = 1;
+                strcpy(filepnm, mop->mo_ldd.ldd_uuid);
+                term = strstr(filepnm, "_UUID");
+                if (term) {
+                        *term = '\0';
+                        sprintf(cmd, "cp %s/%s/%s %s/%s/%s",
+                                mntpt, MDT_LOGS_DIR, filepnm, 
+                                mntpt, MOUNT_CONFIGS_DIR,
+                                mop->mo_ldd.ldd_svname);
+                        if (verbose > 1) 
+                                printf("cmd: %s\n", cmd);
+                        ret = system(cmd);
+                }
+                if (ret) {
+                        fprintf(stderr, "%s: Can't copy 1.4 config %s/%s "
+                                "(%d)\n", progname, MDT_LOGS_DIR, filepnm, ret);
+                        fprintf(stderr, "mount -t ext3 %s somewhere, "
+                                "find the MDT log for fs %s and "
+                                "copy it manually into %s/%s, "
+                                "then umount.\n",
+                                mop->mo_device, 
+                                mop->mo_ldd.ldd_fsname, MOUNT_CONFIGS_DIR,
+                                mop->mo_ldd.ldd_svname);
+                        goto out_umnt;
+                }
         }
 #endif
+        /* end COMPAT_146 */
+
 
 out_umnt:
         vprint("unmounting backing device\n");
@@ -679,17 +706,13 @@ int read_local_files(struct mkfs_opts *mop)
                 goto out_rmdir;
         }
 
-
         sprintf(filepnm, "%s/%s", mntpt, MOUNT_DATA_FILE);
         filep = fopen(filepnm, "r");
         if (filep) {
                 vprint("Reading %s\n", MOUNT_DATA_FILE);
                 fread(&mop->mo_ldd, sizeof(mop->mo_ldd), 1, filep);
-                /* drop FL_MGS from old config if FL_MDT is set --
-                   will re-set based on --mgsnode/--mgs */
-                if (mop->mo_ldd.ldd_flags & LDD_F_SV_TYPE_MDT)
-                        mop->mo_ldd.ldd_flags &= ~LDD_F_SV_TYPE_MGS;
         } else {
+                /* COMPAT_146 */
                 /* Try to read pre-1.6 config from last_rcvd */
                 struct lr_server_data lsd;
                 fprintf(stderr, "%s: Unable to read %s, trying last_rcvd\n",
@@ -722,15 +745,18 @@ int read_local_files(struct mkfs_opts *mop)
                                 mop->mo_ldd.ldd_flags = LDD_F_SV_TYPE_OST;
                                 mop->mo_ldd.ldd_svindex = lsd.lsd_ost_index;
                         } else {
-                                if ((ret = access(filepnm, F_OK)) == 0) 
+                                if ((ret = access(filepnm, F_OK)) == 0) {
                                         mop->mo_ldd.ldd_flags =
                                         LDD_F_SV_TYPE_MDT | 
                                         LDD_F_SV_TYPE_MGS;
-                                else
+                                        /* Old MDT's are always index 0 
+                                           (pre CMD) */
+                                        mop->mo_ldd.ldd_svindex = 0;
+                                } else {
+                                        /* The index won't be correct */
                                         mop->mo_ldd.ldd_flags =
-                                        LDD_F_SV_TYPE_OST;
-                                /* The index won't be correct */
-                                mop->mo_ldd.ldd_flags |= LDD_F_NEED_INDEX;
+                                        LDD_F_SV_TYPE_OST | LDD_F_NEED_INDEX;
+                                }
                         }
                 }
 
@@ -738,6 +764,7 @@ int read_local_files(struct mkfs_opts *mop)
                        sizeof(mop->mo_ldd.ldd_uuid));
                 mop->mo_ldd.ldd_flags |= LDD_F_UPGRADE14;
         }
+        /* end COMPAT_146 */
         fclose(filep);
         
 out_umnt:
@@ -789,6 +816,7 @@ int parse_opts(int argc, char *const argv[], struct mkfs_opts *mop,
                 {"mgsnid", 1, 0, 'm'},
                 {"mkfsoptions", 1, 0, 'k'},
                 {"mountfsoptions", 1, 0, 'o'},
+                {"nomgs", 0, 0, 'N'},
                 {"ost", 0, 0, 'O'},
                 {"print", 0, 0, 'p'},
                 {"quiet", 0, 0, 'q'},
@@ -802,7 +830,7 @@ int parse_opts(int argc, char *const argv[], struct mkfs_opts *mop,
                 {"verbose", 0, 0, 'v'},
                 {0, 0, 0, 0}
         };
-        char *optstring = "b:C:d:n:f:hI:MGm:k:o:Opqrw:c:s:i:t:v";
+        char *optstring = "b:C:d:n:f:hI:MGm:k:No:Opqrw:c:s:i:t:v";
         char opt;
         int longidx;
 
@@ -919,6 +947,9 @@ int parse_opts(int argc, char *const argv[], struct mkfs_opts *mop,
                                 strncpy(mop->mo_ldd.ldd_fsname, optarg, 
                                         sizeof(mop->mo_ldd.ldd_fsname) - 1);
                         break;
+                case 'N':
+                        mop->mo_ldd.ldd_flags &= ~LDD_F_SV_TYPE_MGS;
+                        break;
                 case 'o':
                         mountopts = optarg;
                         break;