Whamcloud - gitweb
Branch b1_4_mountconf
authornathan <nathan>
Tue, 31 Jan 2006 00:07:27 +0000 (00:07 +0000)
committernathan <nathan>
Tue, 31 Jan 2006 00:07:27 +0000 (00:07 +0000)
b=9860
interoperability with 1.4.6:
keep old uuids but new server names when ungrading old logs -
names are local, connects all happen through uuids.
(partially hardcoded for now)
- don't change config log magic, header size
- add uuid to disk data
- copy old client and mds log from LOGS to new names under CONFIGS, MGS
  will then modify the logs.
- index number and uuid taken from last_rcvd (1.4.6)
- llog_filp_open must take directory path now (MDT will still serve old
  logs to old client from old LOGS dir.)

19 files changed:
lustre/include/linux/lustre_cfg.h
lustre/include/linux/lustre_disk.h
lustre/include/linux/lustre_idl.h
lustre/include/linux/obd_support.h
lustre/ldlm/ldlm_lib.c
lustre/mds/mds_fs.c
lustre/mgc/mgc_request.c
lustre/mgs/mgs_handler.c
lustre/mgs/mgs_internal.h
lustre/mgs/mgs_llog.c
lustre/obdclass/llog_lvfs.c
lustre/obdclass/llog_swab.c
lustre/obdclass/obd_config.c
lustre/obdclass/obd_mount.c
lustre/ptlrpc/import.c
lustre/ptlrpc/pack_generic.c
lustre/utils/mkfs_lustre.c
lustre/utils/wirecheck.c
lustre/utils/wiretest.c

index 71ec87e..86f3b2b 100644 (file)
@@ -27,8 +27,7 @@
  * 1cf6
  * lcfG
  */
-#define LUSTRE_CFG_MAGIC 0x1cf60001
-#define LUSTRE_CFG_START_VERSION 0x10000001
+#define LUSTRE_CFG_VERSION 0x1cf60001
 #define LUSTRE_CFG_MAX_BUFCOUNT 8
 
 #define LCFG_HDR_SIZE(count) \
@@ -65,7 +64,6 @@ struct lustre_cfg_bufs {
 #define LCFG_FLG_MOUNTCONF 0x400
 
 struct lustre_cfg {
-        uint32_t lcfg_magic;
         uint32_t lcfg_version;
         uint32_t lcfg_command;
 
@@ -155,9 +153,14 @@ static inline char *lustre_cfg_string(struct lustre_cfg *lcfg, int index)
                 return NULL;
 
         /* make sure it's NULL terminated, even if this kills a char
-         * of data
+         * of data.  Try to use the padding first though.
          */
-        s[lcfg->lcfg_buflens[index] - 1] = '\0';
+        if (s[lcfg->lcfg_buflens[index] - 1] != '\0') {
+                int last = min((int)lcfg->lcfg_buflens[index], 
+                               size_round(lcfg->lcfg_buflens[index]) - 1);
+                s[last] = '\0';
+                CWARN("Truncating buf %d to '%s'\n", index, s);
+        }
         return s;
 }
 
@@ -191,8 +194,7 @@ static inline struct lustre_cfg *lustre_cfg_new(int cmd,
         if (!lcfg)
                 RETURN(lcfg);
 
-        lcfg->lcfg_magic = LUSTRE_CFG_MAGIC;
-        lcfg->lcfg_version = LUSTRE_CFG_START_VERSION;
+        lcfg->lcfg_version = LUSTRE_CFG_VERSION;
         lcfg->lcfg_command = cmd;
         lcfg->lcfg_bufcount = bufs->lcfg_bufcount;
 
@@ -226,8 +228,9 @@ static inline int lustre_cfg_sanity_check(void *buf, int len)
         if (len < LCFG_HDR_SIZE(0))
                 RETURN(-EINVAL);
 
-        if (lcfg->lcfg_magic != LUSTRE_CFG_MAGIC)
+        if (lcfg->lcfg_version != LUSTRE_CFG_VERSION)
                 RETURN(-EINVAL);
+        
         if (lcfg->lcfg_bufcount >= LUSTRE_CFG_MAX_BUFCOUNT)
                 RETURN(-EINVAL);
 
index fa03e8a..6934c00 100644 (file)
    Used before the setup llog can be read. */
 #define MOUNT_CONFIGS_DIR "CONFIGS"
 #define MOUNT_DATA_FILE   MOUNT_CONFIGS_DIR"/mountdata"
-#define INDEX_BITMAP_FILE "IB"
+#define MDT_LOGS_DIR      "LOGS"  /* COMPAT_146 */
 
 #define LDD_MAGIC 0xbabb0001
 
 #define LDD_F_SV_TYPE_MDT   0x0001
 #define LDD_F_SV_TYPE_OST   0x0002
-#define LDD_F_SV_TYPE_MGMT  0x0004
+#define LDD_F_SV_TYPE_MG  0x0004
 #define LDD_F_NEED_INDEX    0x0010
 #define LDD_F_NEED_REGISTER 0x0020
+#define LDD_F_UPGRADE14     0x0040 /* COMPAT_14 */
+
 
 enum ldd_mount_type {
         LDD_MT_EXT3 = 0, 
@@ -74,20 +76,21 @@ struct lustre_disk_data {
         __u32      ldd_magic;
         __u32      ldd_config_ver;      /* 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 */
         char       ldd_svname[64];      /* this server's name (lustre-mdt0001)*/
         __u16      ldd_svindex;         /* server index (0001), must match 
                                            svname */
         __u16      ldd_mgsnid_count;
-        lnet_nid_t ldd_mgsnid[MTI_NIDS_MAX]; /* mgmt nid list; lmd can 
-                                                     override */
         __u16      ldd_failnid_count;   /* server failover nid count */
+        lnet_nid_t ldd_mgsnid[MTI_NIDS_MAX];  /* mgmt nid list; lmd can 
+                                                     override */
         lnet_nid_t ldd_failnid[MTI_NIDS_MAX]; /* server failover nids */
-        enum ldd_mount_type ldd_mount_type;  /* target fs type LDD_MT_* */
-        char       ldd_mount_opts[1024]; /* target fs mount opts */
+        char       ldd_mount_opts[2048]; /* target fs mount opts */
         
         /* Below here is required for writing mdt, ost,or client logs,
            and is ignored after that. */
+        __u8  ldd_uuid[40];        /* server UUID */
         int   ldd_stripe_sz;
         int   ldd_stripe_count;
         int   ldd_stripe_pattern;
@@ -97,7 +100,7 @@ struct lustre_disk_data {
         
 #define IS_MDT(data)   ((data)->ldd_flags & LDD_F_SV_TYPE_MDT)
 #define IS_OST(data)   ((data)->ldd_flags & LDD_F_SV_TYPE_OST)
-#define IS_MGMT(data)  ((data)->ldd_flags & LDD_F_SV_TYPE_MGMT)
+#define IS_MGS(data)  ((data)->ldd_flags & LDD_F_SV_TYPE_MGS)
 #define MT_STR(data)   mt_str((data)->ldd_mount_type)
 
 /* Make the mdt/ost server obd name based on the filesystem name */
@@ -107,7 +110,7 @@ static inline int sv_make_name(__u32 flags, __u16 index, char *fs, char *name)
                 sprintf(name, "%.8s-%s%04x", fs,
                         (flags & LDD_F_SV_TYPE_MDT) ? "MDT" : "OST",  
                         index);
-        } else if (flags & LDD_F_SV_TYPE_MGMT) {
+        } else if (flags & LDD_F_SV_TYPE_MGS) {
                 sprintf(name, "MGMT");
         } else {
                 CERROR("unknown server type %#x\n", flags);
@@ -116,17 +119,6 @@ static inline int sv_make_name(__u32 flags, __u16 index, char *fs, char *name)
         return 0;
 }
 
-static inline int sv_name2index(char *svname, int *idx)
-{
-        char *dash = strchr(svname, '-');
-        if (!dash) {
-                CERROR("Can't understand server name %s\n", svname);
-                return(-EINVAL);
-        }
-        *idx = simple_strtol(dash + 4, NULL, 16);
-        return 0;
-}
-
 static inline void ldd_make_sv_name(struct lustre_disk_data *ldd)
 {
         sv_make_name(ldd->ldd_flags, ldd->ldd_svindex,
@@ -224,7 +216,7 @@ struct lr_server_data {
         __u32 lsd_catalog_ogen;    /* recovery catalog inode generation */
         __u8  lsd_peeruuid[40];    /* UUID of MDS associated with this OST */
         __u32 lsd_ost_index;       /* index number of OST in LOV */
-        __u32 lsd_mds_index;       /* index number of MDS in LMV */
+        __u32 lsd_mdt_index;       /* index number of MDT in LMV */
         __u8  lsd_padding[LR_SERVER_SIZE - 148];
 };
 
index e3b82e8..cadfb03 100644 (file)
@@ -243,7 +243,7 @@ static inline void lustre_msg_set_op_flags(struct lustre_msg *msg, int flags)
                                 OBD_CONNECT_REQPORTAL | OBD_CONNECT_VERSION | \
                                 OBD_CONNECT_TRUNCLOCK)
 #define ECHO_CONNECT_SUPPORTED (0)
-#define MGMT_CONNECT_SUPPORTED  (OBD_CONNECT_VERSION)
+#define MGS_CONNECT_SUPPORTED  (OBD_CONNECT_VERSION)
 
 #define OBD_OCD_VERSION(major,minor,patch,fix) (((major)<<24) + ((minor)<<16) +\
                                                 ((patch)<<8) + (fix))
@@ -980,21 +980,22 @@ extern void lustre_swab_ldlm_reply (struct ldlm_reply *r);
  * Opcodes for mountconf (mgs and mgc)
  */
 typedef enum {
-        MGMT_CONNECT = 250,
-        MGMT_DISCONNECT,
-        MGMT_EXCEPTION,         /* node died, etc. */
-        MGMT_TARGET_ADD,
-        MGMT_TARGET_DEL,
-        MGMT_LAST_OPC
+        MGS_CONNECT = 250,
+        MGS_DISCONNECT,
+        MGS_EXCEPTION,         /* node died, etc. */
+        MGS_TARGET_ADD,
+        MGS_TARGET_DEL,
+        MGS_LAST_OPC
 } mgs_cmd_t;
 
 #define MTI_NAME_MAXLEN 64
 #define MTI_UUID_MAXLEN MTI_NAME_MAXLEN + 5
 #define MTI_NIDS_MAX 10 /* match lustre_disk.h */
 
-struct mgmt_target_info {
+struct mgs_target_info {
         char             mti_fsname[MTI_NAME_MAXLEN];
         char             mti_svname[MTI_NAME_MAXLEN];
+        char             mti_uuid[sizeof(struct obd_uuid)];
         lnet_nid_t       mti_nids[MTI_NIDS_MAX];     /* host nids */
         lnet_nid_t       mti_failnids[MTI_NIDS_MAX]; /* partner nids */
         __u64            mti_stripe_size;      
@@ -1008,7 +1009,7 @@ struct mgmt_target_info {
         __u32            mti_flags;
 };
 
-extern void lustre_swab_mgs_target_info(struct mgmt_target_info *oinfo);
+extern void lustre_swab_mgs_target_info(struct mgs_target_info *oinfo);
 
 #define CM_START 0x01
 #define CM_END   0x02
index 4376267..06bd6c3 100644 (file)
@@ -170,12 +170,12 @@ extern wait_queue_head_t obd_race_waitq;
 #define OBD_FAIL_MDC_REVALIDATE_PAUSE    0x800
 
 
-#define OBD_FAIL_MGMT                     0x900
-#define OBD_FAIL_MGMT_FIRST_CONNECT       0x901
-#define OBD_FAIL_MGMT_CONNECT_NET         0x117
-#define OBD_FAIL_MGMT_DISCONNECT_NET      0x11a
-#define OBD_FAIL_MGMT_ALL_REPLY_NET       0x122
-#define OBD_FAIL_MGMT_ALL_REQUEST_NET     0x123
+#define OBD_FAIL_MGS                     0x900
+#define OBD_FAIL_MGS_FIRST_CONNECT       0x901
+#define OBD_FAIL_MGS_CONNECT_NET         0x117
+#define OBD_FAIL_MGS_DISCONNECT_NET      0x11a
+#define OBD_FAIL_MGS_ALL_REPLY_NET       0x122
+#define OBD_FAIL_MGS_ALL_REQUEST_NET     0x123
 
 /* preparation for a more advanced failure testbed (not functional yet) */
 #define OBD_FAIL_MASK_SYS    0x0000FF00
index cf54471..4462487 100644 (file)
@@ -210,7 +210,7 @@ int client_obd_setup(struct obd_device *obddev, obd_count len, void *buf)
         } else if (!strcmp(name, LUSTRE_MGC_NAME)) {
                 rq_portal = MGS_REQUEST_PORTAL;
                 rp_portal = MGC_REPLY_PORTAL;
-                connect_op = MGMT_CONNECT;
+                connect_op = MGS_CONNECT;
         } else {
                 CERROR("unknown client OBD type \"%s\", can't setup\n",
                        name);
index 8b38b25..3fbf06c 100644 (file)
@@ -477,11 +477,11 @@ int mds_fs_setup(struct obd_device *obd, struct vfsmount *mnt)
         }
         mds->mds_pending_dir = dentry;
 
-        dentry = simple_mkdir(current->fs->pwd, MOUNT_CONFIGS_DIR, 0777, 1);
+        dentry = simple_mkdir(current->fs->pwd, MDT_LOGS_DIR, 0777, 1);
         if (IS_ERR(dentry)) {
                 rc = PTR_ERR(dentry);
                 CERROR("cannot create %s directory: rc = %d\n",
-                       MOUNT_CONFIGS_DIR, rc);
+                       MDT_LOGS_DIR, rc);
                 GOTO(err_pending, rc);
         }
         mds->mds_logs_dir = dentry;
index 9ce32a6..f5bd637 100644 (file)
@@ -553,17 +553,17 @@ out:
 #endif
 
 /* Get index and add to config llog, depending on flags */
-int mgc_target_add(struct obd_export *exp, struct mgmt_target_info *mti)
+int mgc_target_add(struct obd_export *exp, struct mgs_target_info *mti)
 {
         struct ptlrpc_request *req;
-        struct mgmt_target_info *req_mti, *rep_mti;
+        struct mgs_target_info *req_mti, *rep_mti;
         int size = sizeof(*req_mti);
         int rep_size = sizeof(*mti);
         int rc;
         ENTRY;
 
         req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MGS_VERSION,
-                              MGMT_TARGET_ADD, 1, &size, NULL);
+                              MGS_TARGET_ADD, 1, &size, NULL);
         if (!req)
                 RETURN(rc = -ENOMEM);
 
@@ -590,16 +590,16 @@ int mgc_target_add(struct obd_export *exp, struct mgmt_target_info *mti)
 }
 
 /* Remove from config llog */
-int mgc_target_del(struct obd_export *exp, struct mgmt_target_info *mti)
+int mgc_target_del(struct obd_export *exp, struct mgs_target_info *mti)
 {
         struct ptlrpc_request *req;
-        struct mgmt_target_info *req_mti, *rep_mti;
+        struct mgs_target_info *req_mti, *rep_mti;
         int size = sizeof(*req_mti);
         int rc;
         ENTRY;
 
         req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MGS_VERSION,
-                              MGMT_TARGET_DEL, 1, &size, NULL);
+                              MGS_TARGET_DEL, 1, &size, NULL);
         if (!req)
                 RETURN(rc = -ENOMEM);
 
@@ -655,10 +655,10 @@ int mgc_set_info(struct obd_export *exp, obd_count keylen,
         /* Hack alert */
         if (keylen == strlen("add_target") &&
             memcmp(key, "add_target", keylen) == 0) {
-                struct mgmt_target_info *mti;
-                if (vallen != sizeof(struct mgmt_target_info))
+                struct mgs_target_info *mti;
+                if (vallen != sizeof(struct mgs_target_info))
                         RETURN(-EINVAL);
-                mti = (struct mgmt_target_info *)val;
+                mti = (struct mgs_target_info *)val;
                 CDEBUG(D_MGC, "add_target %s %#x\n",
                        mti->mti_svname, mti->mti_flags);
                 rc =  mgc_target_add(exp, mti);
@@ -833,20 +833,22 @@ static int mgc_process_config(struct obd_device *obd, obd_count len, void *buf)
         ENTRY;
 
         switch(cmd = lcfg->lcfg_command) {
-        case LCFG_LOV_ADD_OBD:
-        case LCFG_LOV_DEL_OBD: {
-                struct mgmt_target_info *mti;
+        case LCFG_LOV_ADD_OBD: {
+                struct mgs_target_info *mti;
 
                 if (LUSTRE_CFG_BUFLEN(lcfg, 1) != 
-                    sizeof(struct mgmt_target_info))
+                    sizeof(struct mgs_target_info))
                         GOTO(out, rc = -EINVAL);
 
-                mti = (struct mgmt_target_info *)lustre_cfg_buf(lcfg, 1);
+                mti = (struct mgs_target_info *)lustre_cfg_buf(lcfg, 1);
                 CDEBUG(D_MGC, "add_target %s %#x\n",    
                        mti->mti_svname, mti->mti_flags);
                 rc = mgc_target_add(get_mgs_export(obd), mti);
                 break;
         }
+        case LCFG_LOV_DEL_OBD: 
+                /* Unimplemented */
+                LASSERT(0);
         case LCFG_LOG_START: {
                 struct config_llog_data *cld;
                 struct config_llog_instance *cfg;
index 9f0dd4a..88fafd6 100644 (file)
@@ -68,7 +68,7 @@ static int mgs_connect(struct lustre_handle *conn, struct obd_device *obd,
         LASSERT(exp);
 
         if (data != NULL) {
-                data->ocd_connect_flags &= MGMT_CONNECT_SUPPORTED;
+                data->ocd_connect_flags &= MGS_CONNECT_SUPPORTED;
                 data->ocd_ibits_known &= MDS_INODELOCK_FULL;
 
                 /* If no known bits (which should not happen, probably,
@@ -307,7 +307,7 @@ static int mgs_handle_target_add(struct ptlrpc_request *req)
 {    
         struct obd_device *obd = req->rq_export->exp_obd;
         struct lustre_handle lockh;
-        struct mgmt_target_info *mti, *rep_mti;
+        struct mgs_target_info *mti, *rep_mti;
         int rep_size = sizeof(*mti);
         int rc, lockrc;
         ENTRY;
@@ -315,41 +315,52 @@ static int mgs_handle_target_add(struct ptlrpc_request *req)
         mti = lustre_swab_reqbuf(req, 0, sizeof(*mti),
                                  lustre_swab_mgs_target_info);
         
-        CDEBUG(D_MGS, "adding %s, index=%d\n", mti->mti_svname, 
-               mti->mti_stripe_index);
-
-        /* set the new target index if needed */
-        rc = mgs_set_index(obd, mti);
-        if (rc) {
-                CERROR("Can't get index (%d)\n", rc);
-                GOTO(out, rc);
-        }
-
         /* revoke the config lock so everyone will update */
         lockrc = mgs_get_cfg_lock(obd, mti->mti_fsname, &lockh);
         if (lockrc != ELDLM_OK) {
-                LCONSOLE_ERROR("Can't signal other nodes to update their "
-                               "configuration (%d). Updating local logs "
+                LCONSOLE_ERROR("Can't signal other nodes to update "
+                               "their configuration (%d). Updating local logs "
                                "anyhow; you might have to manually restart "
-                               "other servers to get the latest configuration."
-                               "\n", lockrc);
+                               "other nodes to get the latest configuration.\n",
+                               lockrc);
         }
 
-        /* create the log for the new target 
-           and update the client/mdt logs */
-        rc = mgs_write_log_target(obd, mti);
-        
-        /* done with log update */
-        if (lockrc == ELDLM_OK)
-                mgs_put_cfg_lock(&lockh);
+        if (mti->mti_flags & LDD_F_UPGRADE14) {
+                CDEBUG(D_MGS, "upgrading fs %s from pre-1.6\n", 
+                       mti->mti_fsname); 
+                /* nobody else should be running 1.6 yet, since we're going
+                   to rewrite logs.  
+                   FIXME We should set a "must restart" flag in the lock */
+                rc = mgs_upgrade_sv_14(obd, mti);
+                if (rc) {
+                        CERROR("Can't upgrade from 1.4 (%d)\n", rc);
+                        GOTO(out, rc);
+                }
 
-        if (rc) {
-                CERROR("Failed to write %s log (%d)\n", 
-                       mti->mti_svname, rc);
-                GOTO(out, rc);
+                mti->mti_flags &= ~LDD_F_UPGRADE14;
+        }
+
+        if (mti->mti_flags & LDD_F_NEED_REGISTER) {
+                CDEBUG(D_MGS, "adding %s, index=%d\n", mti->mti_svname, 
+                       mti->mti_stripe_index);
+                
+                /* create the log for the new target 
+                   and update the client/mdt logs */
+                rc = mgs_write_log_target(obd, mti);
+                if (rc) {
+                        CERROR("Failed to write %s log (%d)\n", 
+                               mti->mti_svname, rc);
+                        GOTO(out, rc);
+                }
+
+                mti->mti_flags &= ~LDD_F_NEED_REGISTER;
         }
 
 out:
+        /* done with log update */
+        if (lockrc == ELDLM_OK)
+                mgs_put_cfg_lock(&lockh);
+
         CDEBUG(D_MGS, "replying with %s, index=%d, rc=%d\n", mti->mti_svname, 
                mti->mti_stripe_index, rc);
         lustre_pack_reply(req, 1, &rep_size, NULL); 
@@ -361,14 +372,14 @@ out:
 
 int mgs_handle(struct ptlrpc_request *req)
 {
-        int fail = OBD_FAIL_MGMT_ALL_REPLY_NET;
+        int fail = OBD_FAIL_MGS_ALL_REPLY_NET;
         int rc = 0;
         ENTRY;
 
-        OBD_FAIL_RETURN(OBD_FAIL_MGMT_ALL_REQUEST_NET | OBD_FAIL_ONCE, 0);
+        OBD_FAIL_RETURN(OBD_FAIL_MGS_ALL_REQUEST_NET | OBD_FAIL_ONCE, 0);
 
         LASSERT(current->journal_info == NULL);
-        if (req->rq_reqmsg->opc != MGMT_CONNECT) {
+        if (req->rq_reqmsg->opc != MGS_CONNECT) {
                 if (req->rq_export == NULL) {
                         CERROR("lustre_mgs: operation %d on unconnected MGS\n",
                                req->rq_reqmsg->opc);
@@ -378,23 +389,23 @@ int mgs_handle(struct ptlrpc_request *req)
         }
 
         switch (req->rq_reqmsg->opc) {
-        case MGMT_CONNECT:
+        case MGS_CONNECT:
                 DEBUG_REQ(D_MGS, req, "connect");
-                OBD_FAIL_RETURN(OBD_FAIL_MGMT_CONNECT_NET, 0);
+                OBD_FAIL_RETURN(OBD_FAIL_MGS_CONNECT_NET, 0);
                 rc = target_handle_connect(req, mgs_handle);
                 break;
-        case MGMT_DISCONNECT:
+        case MGS_DISCONNECT:
                 DEBUG_REQ(D_MGS, req, "disconnect");
-                OBD_FAIL_RETURN(OBD_FAIL_MGMT_DISCONNECT_NET, 0);
+                OBD_FAIL_RETURN(OBD_FAIL_MGS_DISCONNECT_NET, 0);
                 rc = target_handle_disconnect(req);
                 req->rq_status = rc;            /* superfluous? */
                 break;
 
-        case MGMT_TARGET_ADD:
+        case MGS_TARGET_ADD:
                 DEBUG_REQ(D_MGS, req, "target add\n");
                 rc = mgs_handle_target_add(req);
                 break;
-        case MGMT_TARGET_DEL:
+        case MGS_TARGET_DEL:
                 DEBUG_REQ(D_MGS, req, "target del\n");
                 //rc = mgs_handle_target_del(req);
                 break;
index fad39a2..ac5a890 100644 (file)
@@ -14,7 +14,8 @@ extern struct lvfs_callback_ops mgs_lvfs_ops;
 
 int mgs_init_db_list(struct obd_device *obd);
 int mgs_cleanup_db_list(struct obd_device *obd);
-int mgs_set_index(struct obd_device *obd, struct mgmt_target_info *mti);
-int mgs_write_log_target(struct obd_device *obd, struct mgmt_target_info *mti);
+int mgs_set_index(struct obd_device *obd, struct mgs_target_info *mti);
+int mgs_write_log_target(struct obd_device *obd, struct mgs_target_info *mti);
+int mgs_upgrade_sv_14(struct obd_device *obd, struct mgs_target_info *mti);
 
 #endif
index a2d7df6..2be2cb1 100644 (file)
 #include "mgs_internal.h"
 
 
+static inline int sv_name2index(char *svname, unsigned long *idx)
+{
+        char *dash = strchr(svname, '-');
+        if (!dash) {
+                CERROR("Can't understand server name %s\n", svname);
+                return(-EINVAL);
+        }
+        *idx = simple_strtoul(dash + 4, NULL, 16);
+        return 0;
+}
+
+
 /******************** DB functions *********************/
 
 /* from the (client) config log, figure out:
 */
 /* FIXME is it better to have a separate db file, instead of parsing the info
    out of the client log? */
-static int db_handler(struct llog_handle *llh, struct llog_rec_hdr *rec, 
+static int mgsdb_handler(struct llog_handle *llh, struct llog_rec_hdr *rec, 
                       void *data)
 {
         struct fs_db *db = (struct fs_db *)data;
         int cfg_len = rec->lrh_len;
         char *cfg_buf = (char*) (rec + 1);
         struct lustre_cfg *lcfg;
-        int index, rc = 0;
+        unsigned long index;
+        int rc = 0;
         ENTRY;
 
         if (rec->lrh_type != OBD_CFG_REC) {
@@ -70,8 +83,10 @@ static int db_handler(struct llog_handle *llh, struct llog_rec_hdr *rec,
         }
 
         rc = lustre_cfg_sanity_check(cfg_buf, cfg_len);
-        if (rc)
+        if (rc) {
+                CERROR("Insane cfg\n");
                 RETURN(rc);
+        }
 
         lcfg = (struct lustre_cfg *)cfg_buf;
 
@@ -79,20 +94,29 @@ static int db_handler(struct llog_handle *llh, struct llog_rec_hdr *rec,
                lustre_cfg_string(lcfg, 0), lustre_cfg_string(lcfg, 1));
 
         /* Figure out ost indicies */ 
+        /* lov_modify_tgts add 0:lov1  1:ost1_UUID  2(index):0  3(gen):1 */
         if (lcfg->lcfg_command == LCFG_LOV_ADD_OBD ||
             lcfg->lcfg_command == LCFG_LOV_DEL_OBD) {
-                index = simple_strtol(lustre_cfg_string(lcfg, 2),
-                                      NULL, 10);
+                index = simple_strtoul(lustre_cfg_string(lcfg, 2),
+                                       NULL, 10);
+                CDEBUG(D_MGS, "OST index for %s is %lu (%s)\n",
+                       lustre_cfg_string(lcfg, 1), index, 
+                       lustre_cfg_string(lcfg, 2));
                 set_bit(index, db->fd_ost_index_map);
         }
         
         /* Figure out mdt indicies */
+        /* attach   0:MDC_uml1_mdsA_MNT_client  1:mdc  2:1d834_MNT_client_03f */
         if ((lcfg->lcfg_command == LCFG_ATTACH) &&
             (strcmp(lustre_cfg_string(lcfg, 1), LUSTRE_MDC_NAME) == 0)) {
                 rc = sv_name2index(lustre_cfg_string(lcfg, 0), &index);
-                if (rc) 
-                        RETURN(rc);
-                CDEBUG(D_MGS, "MDT index is %d\n", index);
+                if (rc) {
+                        CWARN("Unparsable MDC name %s, assuming index 0\n",
+                              lustre_cfg_string(lcfg, 0));
+                        index = 0;
+                        rc = 0;
+                }
+                CDEBUG(D_MGS, "MDT index is %lu\n", index);
                 set_bit(index, db->fd_mdt_index_map);
         }
 
@@ -108,8 +132,8 @@ static int db_handler(struct llog_handle *llh, struct llog_rec_hdr *rec,
         RETURN(rc);
 }
 
-static int get_db_from_llog(struct obd_device *obd, char *logname,
-                                   struct fs_db *db)
+static int mgs_get_db_from_llog(struct obd_device *obd, char *logname,
+                                struct fs_db *db)
 {
         struct llog_handle *loghandle;
         struct lvfs_run_ctxt saved;
@@ -126,7 +150,7 @@ static int get_db_from_llog(struct obd_device *obd, char *logname,
         if (rc)
                 GOTO(out_close, rc);
 
-        rc = llog_process(loghandle, db_handler, (void *)db, NULL);
+        rc = llog_process(loghandle, mgsdb_handler, (void *)db, NULL);
         CDEBUG(D_MGS, "get_db = %d\n", rc);
 out_close:
         rc2 = llog_close(loghandle);
@@ -276,7 +300,7 @@ static int mgs_find_or_make_db(struct obd_device *obd, char *name,
 
         /* populate the db from the client llog */
         name_create(name, "-client", &cliname);
-        rc = get_db_from_llog(obd, cliname, db);
+        rc = mgs_get_db_from_llog(obd, cliname, db);
         name_destroy(cliname);
         if (rc) {
                 CERROR("Can't get db from llog %d\n", rc);
@@ -289,7 +313,7 @@ static int mgs_find_or_make_db(struct obd_device *obd, char *name,
         return 0;
 }
 
-int mgs_set_index(struct obd_device *obd, struct mgmt_target_info *mti)
+int mgs_set_index(struct obd_device *obd, struct mgs_target_info *mti)
 {
         struct fs_db *db;
         void *imap;
@@ -655,7 +679,7 @@ static int mgs_clear_log(struct obd_device *obd, char *name)
 
 /* lov is the first thing in the mdt and client logs */
 static int mgs_write_log_lov(struct obd_device *obd, struct fs_db *db, 
-                             struct mgmt_target_info *mti,
+                             struct mgs_target_info *mti,
                              char *logname, char *lovname)
 {
         struct llog_handle *llh = NULL;
@@ -701,16 +725,27 @@ static int mgs_write_log_lov(struct obd_device *obd, struct fs_db *db,
 }
 
 static int mgs_write_log_mdt(struct obd_device *obd, struct fs_db *db,
-                             struct mgmt_target_info *mti)
+                             struct mgs_target_info *mti)
 {
         struct llog_handle *llh = NULL;
-        char *cliname, *mdcname, *lovname, *nodeuuid, *mdsuuid, *mdcuuid;
+        char *cliname, *mdcname, *lovname, *nodeuuid, *mdcuuid;
         lnet_nid_t nid;
         int rc, i, first_log = 0;
+        ENTRY;
 
         CDEBUG(D_MGS, "writing new mdt %s\n", mti->mti_svname);
 
-        name_create(mti->mti_fsname, "-mdtlov", &lovname);
+        if (*mti->mti_uuid == 0) {
+                snprintf(mti->mti_uuid, sizeof(mti->mti_uuid),
+                         "%s_UUID", mti->mti_svname);
+                name_create(mti->mti_fsname, "-mdtlov", &lovname);
+        } else {
+                /* We're starting with an old uuid.  Assume old name for lov
+                   as well. */
+                /* FIXME parse mds name out of uuid */
+                name_create("lov", "_mdsA", &lovname);
+        }
+
         /* Append mdt info to mdt log */
         if (mgs_log_is_empty(obd, mti->mti_svname)) {
                 /* This is the first time for all logs for this fs, 
@@ -721,8 +756,6 @@ static int mgs_write_log_mdt(struct obd_device *obd, struct fs_db *db,
         } 
         /* else there's already some ost entries in the mdt log. */
 
-        name_create(mti->mti_svname, "_UUID", &mdsuuid);
-        
         /* We added the lov, maybe some osc's, now for the mdt.
            We might add more ost's after this. Note that during the parsing
            of this log, this is when the mdt will start. (This was not 
@@ -736,13 +769,18 @@ static int mgs_write_log_mdt(struct obd_device *obd, struct fs_db *db,
         rc = record_start_log(obd, &llh, mti->mti_svname);
         rc = record_marker(obd, llh, db, CM_START, "add mdt"); 
         rc = record_mount_opt(obd, llh, mti->mti_svname, lovname, 0);
-        rc = record_attach(obd, llh, mti->mti_svname, LUSTRE_MDS_NAME, mdsuuid);
+        rc = record_attach(obd, llh, mti->mti_svname, LUSTRE_MDS_NAME, 
+                           mti->mti_uuid);
         rc = record_setup(obd,llh,mti->mti_svname,
                           "dev"/*ignored*/,"type"/*ignored*/,
                           mti->mti_svname, 0/*options*/);
         rc = record_marker(obd, llh, db, CM_END, "add mdt"); 
         rc = record_end_log(obd, &llh);
 
+        if (mti->mti_flags & LDD_F_UPGRADE14) 
+                /* If we're upgrading, the client log is done. */
+                GOTO(out_nocli, rc);
+
         /* Append the mdt info to the client log */
         name_create(mti->mti_fsname, "-client", &cliname);
         name_destroy(lovname);
@@ -752,7 +790,6 @@ static int mgs_write_log_mdt(struct obd_device *obd, struct fs_db *db,
                 rc = mgs_write_log_lov(obd, db, mti, cliname, lovname);
         }
 
-        /* Add the mdt info to the client log */
         name_create(libcfs_nid2str(mti->mti_nids[0]), /*"_UUID"*/"", &nodeuuid);
         name_create(mti->mti_svname, "-mdc", &mdcname);
         name_create(mdcname, "_UUID", &mdcuuid);
@@ -771,7 +808,7 @@ static int mgs_write_log_mdt(struct obd_device *obd, struct fs_db *db,
                 rc = record_add_uuid(obd, llh, mti->mti_nids[i], nodeuuid);
         }
         rc = record_attach(obd, llh, mdcname, LUSTRE_MDC_NAME, mdcuuid);
-        rc = record_setup(obd,llh,mdcname,mdsuuid,nodeuuid,0,0);
+        rc = record_setup(obd,llh,mdcname,mti->mti_uuid,nodeuuid,0,0);
         for (i = 0; i < mti->mti_failnid_count; i++) {
                 nid = mti->mti_failnids[i];
                 CERROR("add failover nid %s\n", libcfs_nid2str(nid));
@@ -786,15 +823,15 @@ static int mgs_write_log_mdt(struct obd_device *obd, struct fs_db *db,
         name_destroy(mdcname);
         name_destroy(nodeuuid);
         name_destroy(cliname);
-        name_destroy(mdsuuid);
+out_nocli:
         name_destroy(lovname);
-        return rc;
+        RETURN(rc);
 }
 
 /* Add the ost info to the client/mdt lov */
 static int mgs_write_log_osc(struct obd_device *obd, struct fs_db *db,
-                             struct mgmt_target_info *mti,
-                             char *logname, char *lovname, char *ostuuid)
+                             struct mgs_target_info *mti,
+                             char *logname, char *lovname)
 {
         struct llog_handle *llh = NULL;
         char *nodeuuid, *oscname, *oscuuid, *lovuuid;
@@ -821,7 +858,7 @@ static int mgs_write_log_osc(struct obd_device *obd, struct fs_db *db,
         #05 L setup    0:OSC_uml1_ost1_MNT_client  1:ost1_UUID  2:uml1_UUID
         #06 L add_uuid nid=uml2@tcp(0x20000c0a80202) 0:  1:uml2_UUID
         #07 L add_conn 0:OSC_uml1_ost1_MNT_client  1:uml2_UUID
-        #08 L lov_modify_tgts add 0:lov1  1:ost1_UUID  2:0  3:1
+        #08 L lov_modify_tgts add 0:lov1  1:ost1_UUID  2(index):0  3(gen):1
         */
         rc = record_start_log(obd, &llh, logname);
         rc = record_marker(obd, llh, db, CM_START, "add osc"); 
@@ -830,7 +867,7 @@ static int mgs_write_log_osc(struct obd_device *obd, struct fs_db *db,
                 rc = record_add_uuid(obd, llh, mti->mti_nids[i], nodeuuid);
         }
         rc = record_attach(obd, llh, oscname, LUSTRE_OSC_NAME, lovuuid);
-        rc = record_setup(obd, llh, oscname, ostuuid, nodeuuid, 0, 0);
+        rc = record_setup(obd, llh, oscname, mti->mti_uuid, nodeuuid, 0, 0);
         for (i = 0; i < mti->mti_failnid_count; i++) {
                 nid = mti->mti_failnids[i];
                 CERROR("add failover nid %s\n", libcfs_nid2str(nid));
@@ -838,7 +875,7 @@ static int mgs_write_log_osc(struct obd_device *obd, struct fs_db *db,
                 rc = record_add_conn(obd, llh, libcfs_nid2str(nid));
         }
         snprintf(index, sizeof(index), "%d", mti->mti_stripe_index);
-        rc = record_lov_add(obd,llh, lovname, ostuuid, index,"1"/*generation*/);
+        rc = record_lov_add(obd, llh, lovname, mti->mti_uuid, index, "1");
         rc = record_marker(obd, llh, db, CM_END, "add osc"); 
         rc = record_end_log(obd, &llh);
         
@@ -850,11 +887,12 @@ static int mgs_write_log_osc(struct obd_device *obd, struct fs_db *db,
 }
 
 static int mgs_write_log_ost(struct obd_device *obd, struct fs_db *db,
-                             struct mgmt_target_info *mti)
+                             struct mgs_target_info *mti)
 {
         struct llog_handle *llh = NULL;
-        char *logname, *lovname, *ostuuid;
+        char *logname, *lovname;
         int rc;
+        ENTRY;
         
         CDEBUG(D_MGS, "writing new ost %s\n", mti->mti_svname);
 
@@ -881,15 +919,21 @@ static int mgs_write_log_ost(struct obd_device *obd, struct fs_db *db,
         */
         rc = record_start_log(obd, &llh, mti->mti_svname);
         rc = record_marker(obd, llh, db, CM_START, "add ost"); 
-        name_create(mti->mti_svname, "_UUID", &ostuuid);
+        if (*mti->mti_uuid == 0) 
+                snprintf(mti->mti_uuid, sizeof(mti->mti_uuid),
+                         "%s_UUID", mti->mti_svname);
         rc = record_attach(obd, llh, mti->mti_svname,
-                           "obdfilter"/*LUSTRE_OST_NAME*/, ostuuid);
+                           "obdfilter"/*LUSTRE_OST_NAME*/, mti->mti_uuid);
         rc = record_setup(obd,llh,mti->mti_svname,
                           "dev"/*ignored*/,"type"/*ignored*/,
                           "f", 0/*options*/);
         rc = record_marker(obd, llh, db, CM_END, "add ost"); 
         rc = record_end_log(obd, &llh);
         
+        if (mti->mti_flags & LDD_F_UPGRADE14) 
+                /* If we're upgrading, the client log is done. */
+                RETURN(rc);
+
         /* We also have to update the other logs where this osc is part of 
            the lov */
         /* Append ost info to mdt log */
@@ -897,27 +941,33 @@ static int mgs_write_log_ost(struct obd_device *obd, struct fs_db *db,
         // FIXME add to all mdt logs for CMD
         name_create(mti->mti_fsname, "-MDT0000", &logname);
         name_create(mti->mti_fsname, "-mdtlov", &lovname);
-        mgs_write_log_osc(obd, db, mti, logname, lovname, ostuuid);
+        mgs_write_log_osc(obd, db, mti, logname, lovname);
         name_destroy(lovname);
         name_destroy(logname);
 
         /* Append ost info to the client log */
         name_create(mti->mti_fsname, "-client", &logname);
         name_create(mti->mti_fsname, "-clilov", &lovname);
-        mgs_write_log_osc(obd, db, mti, logname, lovname, ostuuid);
+        mgs_write_log_osc(obd, db, mti, logname, lovname);
         name_destroy(lovname);
         name_destroy(logname);
         
-        name_destroy(ostuuid);
-        return rc;
+        RETURN(rc);
 }
 
 int mgs_write_log_target(struct obd_device *obd,
-                         struct mgmt_target_info *mti)
+                         struct mgs_target_info *mti)
 {
         struct fs_db *db;
         int rc = -EINVAL;
 
+        /* set/check the new target index */
+        rc = mgs_set_index(obd, mti);
+        if (rc) {
+                CERROR("Can't get index (%d)\n", rc);
+                return rc;
+        }
+
         rc = mgs_find_or_make_db(obd, mti->mti_fsname, &db); 
         if (rc) {
                 CERROR("Can't get db for %s\n", mti->mti_fsname);
@@ -935,6 +985,140 @@ int mgs_write_log_target(struct obd_device *obd,
         return rc;
 }
 
+/***************** upgrade pre-mountconf logs to mountconf *****************/
+
+int mgs_upgrade_logs_14(struct obd_device *obd, struct fs_db *db, 
+                        struct mgs_target_info *mti)
+{
+        int rc = 0;
+        ENTRY;
+
+        CDEBUG(D_MGS, "Upgrading old logs for %s\n", mti->mti_fsname);
+
+        /* If we get here, we know: 
+                the client log fsname-client exists
+                the logs have not been updated
+           so
+        1. parse the old client log (client log name?) to find out UUIDs for
+           all servers
+        2. regen all ost logs: servers will get new
+           name based on index, but will keep their old uuids.
+        3. append mdt startup to the end of the mdt log
+        4. append marker to old client log signifying we did the upgrade
+        ?  translate mds/client logs to new names?
+                  2 UP mdt MDS MDS_uuid 3
+                  3 UP lov lov_mdsA 47d06_lov_mdsA_61f31f85bc 4
+                  4 UP osc OSC_uml1_ost1_mdsA 47d06_lov_mdsA_61f31f85bc 4
+                  5 UP osc OSC_uml1_ost2_mdsA 47d06_lov_mdsA_61f31f85bc 4
+                  6 UP mds lustre-MDT0000 mdsA_UUID 3
+                to
+        ?  update server uuids?
+        */
+
+        /* FIXME hardcoded for proof-of-concept. Really, we have to parse the
+           old logs to find osts, lov & mdc for client mountopt.  */
+
+        if (!(mti->mti_flags & LDD_F_SV_TYPE_MDT)) {
+                CERROR("MDT first\n");
+                RETURN(-EINVAL);
+        }
+                
+        if (1) 
+        {
+                CDEBUG(D_MGS, "Upgrade MDT\n");
+                /* Need to set the mdsuuid first */
+                mti->mti_stripe_index = 0;
+                sv_make_name(mti->mti_flags, mti->mti_stripe_index,
+                             mti->mti_fsname, mti->mti_svname);
+                sprintf(mti->mti_uuid, "mdsA_UUID");
+                if (mgs_log_is_empty(obd, mti->mti_svname)) {
+                        CERROR("The MDT log %s is missing.\n", mti->mti_svname);
+                        RETURN(-ENOENT);
+                }
+                /* FIXME Old logs already have an old mount opt 
+                   which we should drop */
+                rc = mgs_write_log_mdt(obd, db, mti);
+        }
+
+        {
+                /* Write the ost logs */
+                struct mgs_target_info omti;
+                CDEBUG(D_MGS, "Upgrade OST\n");
+
+                /* these indicies were already marked by mgs_db_handler */
+                omti = *mti;
+                omti.mti_flags |= LDD_F_SV_TYPE_OST;
+                omti.mti_flags &= ~(LDD_F_SV_TYPE_MDT | LDD_F_SV_TYPE_MGS);
+                omti.mti_stripe_index = 0;
+                sv_make_name(omti.mti_flags, omti.mti_stripe_index,
+                             omti.mti_fsname, omti.mti_svname);
+                sprintf(omti.mti_uuid, "ost1_UUID");
+                if (!mgs_log_is_empty(obd, omti.mti_svname)) {
+                        CERROR("The OST log %s already exists.\n",
+                               omti.mti_svname);
+                } else {
+                        rc = mgs_write_log_ost(obd, db, &omti);
+                }
+
+                omti.mti_stripe_index = 1;
+                sv_make_name(omti.mti_flags, omti.mti_stripe_index,
+                             omti.mti_fsname, omti.mti_svname);
+                sprintf(omti.mti_uuid, "ost2_UUID");
+                if (!mgs_log_is_empty(obd, omti.mti_svname)) {
+                        CERROR("The OST log %s already exists.\n",
+                               omti.mti_svname);
+                } else {
+                        rc = mgs_write_log_ost(obd, db, &omti);
+                }
+        }
+
+        {
+                struct llog_handle *llh = NULL;
+                char *cliname;
+                CDEBUG(D_MGS, "Upgrade client\n");
+
+                name_create(mti->mti_fsname, "-client", &cliname);
+
+                /* Mark the client log so we know we updated (fd_gen == 1) */
+                rc = record_start_log(obd, &llh, cliname);
+                rc = record_marker(obd, llh, db, CM_START, "upgrade from 1.4"); 
+                /* FIXME find the old lovname and mdcname */
+                /* old: mount_option 0:  1:client  2:lov1  3:MDC_uml1_mdsA_MNT_client */
+                /* new: mount_option 0:  1:lustre-client  2:lustre-clilov  3:lustre-MDT0000-mdc */
+                rc = record_mount_opt(obd, llh, cliname, "lov1", "MDC_uml1_mdsA_MNT_client");
+                rc = record_marker(obd, llh, db, CM_END, "upgrade to 1.6"); 
+                rc = record_end_log(obd, &llh);
+                name_destroy(cliname);
+        }
+        
+        RETURN(rc);
+}
+
+/* Make newly-connecting upgraded servers happy. */ 
+int mgs_upgrade_sv_14(struct obd_device *obd, struct mgs_target_info *mti)
+{
+        struct fs_db *db;
+        int rc = 0;
+        ENTRY;
+        
+        rc = mgs_find_or_make_db(obd, mti->mti_fsname, &db);
+        if (rc) {
+                LCONSOLE_ERROR("The 1.4 log for fs %s is unreadable, I can't "
+                               "upgrade.\n", mti->mti_fsname);
+                RETURN(-ENOENT);
+        }
+
+        if (db->fd_gen == 0) {
+                /* There were no markers in the client log, meaning we have 
+                   not updated the logs for this fs */
+                rc = mgs_upgrade_logs_14(obd, db, mti);
+                if (rc) 
+                        RETURN(rc);
+        }
+
+        RETURN(rc);
+}
+
 /******************** unused *********************/
 
 static int decompose_fullfsname(char *fullfsname, char *fsname, char *poolname)
index c91ab6e..40a82e3 100644 (file)
@@ -497,18 +497,20 @@ static int llog_lvfs_prev_block(struct llog_handle *loghandle,
         RETURN(-EIO);
 }
 
-static struct file *llog_filp_open(char *name, int flags, int mode)
+static struct file *llog_filp_open(char *dir, char *name, int flags, int mode)
 {
         char *logname;
         struct file *filp;
         int len;
 
+        //FIXME remove
+        CDEBUG(D_ERROR, "path %s/%s\n", dir, name);
+
         OBD_ALLOC(logname, PATH_MAX);
         if (logname == NULL)
                 return ERR_PTR(-ENOMEM);
 
-        len = snprintf(logname, PATH_MAX, "%s/%s", 
-                       MOUNT_CONFIGS_DIR, name);
+        len = snprintf(logname, PATH_MAX, "%s/%s", dir, name);
         if (len >= PATH_MAX - 1) {
                 filp = ERR_PTR(-ENAMETOOLONG);
         } else {
@@ -575,7 +577,16 @@ static int llog_lvfs_create(struct llog_ctxt *ctxt, struct llog_handle **res,
                 handle->lgh_id = *logid;
 
         } else if (name) {
-                handle->lgh_file = llog_filp_open(name, open_flags, 0644);
+                /* COMPAT_146 */
+                if (obd->obd_type->typ_name == LUSTRE_MDS_NAME) {
+                        handle->lgh_file = llog_filp_open(MDT_LOGS_DIR, name, 
+                                                          open_flags, 0644);
+                } else {
+                        /* end COMPAT_146 */
+                        handle->lgh_file = llog_filp_open(MOUNT_CONFIGS_DIR,
+                                                          name, open_flags, 
+                                                          0644);
+                }
                 if (IS_ERR(handle->lgh_file))
                         GOTO(cleanup, rc = PTR_ERR(handle->lgh_file));
 
@@ -642,12 +653,22 @@ static int llog_lvfs_destroy(struct llog_handle *handle)
 {
         struct dentry *fdentry;
         struct obdo *oa;
+        struct obd_device *obd = handle->lgh_ctxt->loc_exp->exp_obd;
+        char *dir;
         int rc;
         ENTRY;
 
+        /* COMPAT_146 */
+        if (obd->obd_type->typ_name == LUSTRE_MDS_NAME)
+                dir = MDT_LOGS_DIR;
+        else
+                /* end COMPAT_146 */
+                dir = MOUNT_CONFIGS_DIR;
+        // FIXME remove
+        CDEBUG(D_ERROR, "using config dir %s\n", dir);
+
         fdentry = handle->lgh_file->f_dentry;
-        if (strcmp(fdentry->d_parent->d_name.name, MOUNT_CONFIGS_DIR) == 0) {
-                struct obd_device *obd = handle->lgh_ctxt->loc_exp->exp_obd;
+        if (strcmp(fdentry->d_parent->d_name.name, dir) == 0) {
                 struct inode *inode = fdentry->d_parent->d_inode;
                 struct lvfs_run_ctxt saved;
 
index 55eb8b8..94861a1 100644 (file)
@@ -209,7 +209,6 @@ static void print_lustre_cfg(struct lustre_cfg *lcfg)
         if (!(libcfs_debug & D_OTHER)) /* don't loop on nothing */
                 return;
         CDEBUG(D_OTHER, "lustre_cfg: %p\n", lcfg);
-        CDEBUG(D_OTHER, "\tlcfg->lcfg_magic: %#x\n", lcfg->lcfg_magic);
         CDEBUG(D_OTHER, "\tlcfg->lcfg_version: %#x\n", lcfg->lcfg_version);
 
         CDEBUG(D_OTHER, "\tlcfg->lcfg_command: %#x\n", lcfg->lcfg_command);
@@ -230,22 +229,19 @@ void lustre_swab_lustre_cfg(struct lustre_cfg *lcfg)
         int i;
         ENTRY;
 
-        __swab32s(&lcfg->lcfg_magic);
+        __swab32s(&lcfg->lcfg_version);
 
-        if (lcfg->lcfg_magic != LUSTRE_CFG_MAGIC) {
-                CERROR("not swabbing lustre_cfg magic %#x (expecting %#x)\n",
-                       lcfg->lcfg_magic, LUSTRE_CFG_MAGIC);
+        if (lcfg->lcfg_version != LUSTRE_CFG_VERSION) {
+                CERROR("not swabbing lustre_cfg version %#x (expecting %#x)\n",
+                       lcfg->lcfg_version, LUSTRE_CFG_VERSION);
                 EXIT;
                 return;
         }
 
-        __swab32s(&lcfg->lcfg_version);
         __swab32s(&lcfg->lcfg_command);
-
         __swab32s(&lcfg->lcfg_num);
         __swab32s(&lcfg->lcfg_flags);
         __swab64s(&lcfg->lcfg_nid);
-
         __swab32s(&lcfg->lcfg_bufcount);
         for (i = 0; i < lcfg->lcfg_bufcount && i < LUSTRE_CFG_MAX_BUFCOUNT; i++)
                 __swab32s(&lcfg->lcfg_buflens[i]);
index 03069a4..5c5c3fe 100644 (file)
@@ -727,7 +727,7 @@ static int class_config_llog_handler(struct llog_handle * handle,
                 int inst = 0;
 
                 lcfg = (struct lustre_cfg *)cfg_buf;
-                if (lcfg->lcfg_magic == __swab32(LUSTRE_CFG_MAGIC))
+                if (lcfg->lcfg_version == __swab32(LUSTRE_CFG_VERSION))
                         lustre_swab_lustre_cfg(lcfg);
 
                 rc = lustre_cfg_sanity_check(cfg_buf, cfg_len);
@@ -907,7 +907,7 @@ int class_config_dump_handler(struct llog_handle * handle,
                 rc = -EINVAL;
         }
 out:
-        OBD_FREE(outstr, end - outstr);
+        OBD_FREE(outstr, 256);
         RETURN(rc);
 }
 
index 1744bd4..86127d5 100644 (file)
@@ -835,7 +835,7 @@ static int server_add_target(struct super_block *sb, struct vfsmount *mnt)
         struct lustre_sb_info *lsi = s2lsi(sb);
         struct obd_device *mgc = lsi->lsi_mgc;
         struct lustre_disk_data *ldd = lsi->lsi_ldd;
-        struct mgmt_target_info *mti = NULL;
+        struct mgs_target_info *mti = NULL;
         lnet_process_id_t         id;
         int i = 0;
         int rc;
@@ -843,7 +843,7 @@ static int server_add_target(struct super_block *sb, struct vfsmount *mnt)
 
         LASSERT(mgc);
 
-        /* send MGMT_TARGET_ADD rpc via MGC, MGS should reply with an 
+        /* send MGS_TARGET_ADD rpc via MGC, MGS should reply with an 
            index number. */
         
         OBD_ALLOC(mti, sizeof(*mti));
@@ -905,10 +905,11 @@ static int server_add_target(struct super_block *sb, struct vfsmount *mnt)
                         sizeof(ldd->ldd_svname));
                 /* or ldd_make_sv_name(ldd); */
                 /* FIXME write last_rcvd?, disk label? */
+                mti->mti_flags &= ~LDD_F_NEED_INDEX;
         }
 
         /* Always write out the new flags */
-        ldd->ldd_flags &= ~(LDD_F_NEED_INDEX | LDD_F_NEED_REGISTER);
+        ldd->ldd_flags = mti->mti_flags;
         ldd_write(&mgc->obd_lvfs_ctxt, ldd);
 
 out:
@@ -963,7 +964,7 @@ static int server_start_targets(struct super_block *sb, struct vfsmount *mnt)
 
         /* Register if needed */
         if (lsi->lsi_ldd->ldd_flags & 
-            (LDD_F_NEED_INDEX | LDD_F_NEED_REGISTER)) {
+            (LDD_F_NEED_INDEX | LDD_F_NEED_REGISTER | LDD_F_UPGRADE14)) {
                 CDEBUG(D_MOUNT, "Need new target index from MGS\n");
                 rc = server_add_target(sb, mnt);
                 if (rc) {
@@ -1136,13 +1137,14 @@ static struct vfsmount *server_kernel_mount(struct super_block *sb)
 
         options = (char *)page;
         memset(options, 0, PAGE_SIZE);
-        strcpy(options, ldd->ldd_mount_opts);
+        strncpy(options, ldd->ldd_mount_opts, PAGE_SIZE - 2);
         
         /* Add in any mount-line options */
         if (lmd->lmd_opts && (*(lmd->lmd_opts) != 0)) {
+                int len = PAGE_SIZE - strlen(options) - 2;
                 if (*options != 0) 
                         strcat(options, ",");
-                strcat(options, lmd->lmd_opts);
+                strncat(options, lmd->lmd_opts, len);
         }
 
         /* Special permanent mount flags */
@@ -1204,7 +1206,7 @@ static void server_put_super(struct super_block *sb)
 
         /* If they wanted the mgs to stop separately from the mdt, they
            should have put it on a different device. */ 
-        if (IS_MGMT(lsi->lsi_ldd)) {
+        if (IS_MGS(lsi->lsi_ldd)) {
                 /* stop the mgc before the mgs so the connection gets cleaned
                    up */
                 lustre_stop_mgc(sb);
@@ -1335,7 +1337,7 @@ static int server_fill_super(struct super_block *sb)
         }
 
         /* start MGS before MGC */
-        if (IS_MGMT(lsi->lsi_ldd)) {
+        if (IS_MGS(lsi->lsi_ldd)) {
                 rc = server_start_mgs(sb);
                 if (rc) {
                         CERROR("ignoring Failed MGS start!!\n");
index 6a8bd02..eeea579 100644 (file)
@@ -855,7 +855,7 @@ int ptlrpc_disconnect_import(struct obd_import *imp)
         switch (imp->imp_connect_op) {
         case OST_CONNECT: rq_opc = OST_DISCONNECT; break;
         case MDS_CONNECT: rq_opc = MDS_DISCONNECT; break;
-        case MGMT_CONNECT: rq_opc = MGMT_DISCONNECT; break;
+        case MGS_CONNECT: rq_opc = MGS_DISCONNECT; break;
         default:
                 CERROR("don't know how to disconnect from %s (connect_op %d)\n",
                        imp->imp_target_uuid.uuid, imp->imp_connect_op);
index f40f35f..5cfc889 100644 (file)
@@ -628,7 +628,7 @@ void lustre_swab_mds_body (struct mds_body *b)
         __swab32s (&b->padding_4);
 }
 
-void lustre_swab_mgs_target_info(struct mgmt_target_info *mti)
+void lustre_swab_mgs_target_info(struct mgs_target_info *mti)
 {
         int i;
         LASSERT(sizeof(lnet_nid_t) == sizeof(__u64));
@@ -1117,16 +1117,16 @@ void lustre_assert_wire_constants(void)
                  (long long)LCK_GROUP);
         LASSERTF(LCK_MAXMODE == 65, " found %lld\n",
                  (long long)LCK_MAXMODE);
-        LASSERTF(MGMT_CONNECT == 250, " found %lld\n",
-                 (long long)MGMT_CONNECT);
-        LASSERTF(MGMT_DISCONNECT == 251, " found %lld\n",
-                 (long long)MGMT_DISCONNECT);
-        LASSERTF(MGMT_EXCEPTION == 252, " found %lld\n",
-                 (long long)MGMT_EXCEPTION);
-        LASSERTF(MGMT_TARGET_ADD == 253, " found %lld\n",
-                 (long long)MGMT_TARGET_ADD);
-        LASSERTF(MGMT_TARGET_DEL == 254, " found %lld\n",
-                 (long long)MGMT_TARGET_DEL);
+        LASSERTF(MGS_CONNECT == 250, " found %lld\n",
+                 (long long)MGS_CONNECT);
+        LASSERTF(MGS_DISCONNECT == 251, " found %lld\n",
+                 (long long)MGS_DISCONNECT);
+        LASSERTF(MGS_EXCEPTION == 252, " found %lld\n",
+                 (long long)MGS_EXCEPTION);
+        LASSERTF(MGS_TARGET_ADD == 253, " found %lld\n",
+                 (long long)MGS_TARGET_ADD);
+        LASSERTF(MGS_TARGET_DEL == 254, " found %lld\n",
+                 (long long)MGS_TARGET_DEL);
         LASSERTF(OBD_PING == 400, " found %lld\n",
                  (long long)OBD_PING);
         LASSERTF(OBD_LOG_CANCEL == 401, " found %lld\n",
index 217c9c5..f520fc7 100644 (file)
@@ -54,6 +54,7 @@ command_t cmdlist[] = {
 
 static char *progname;
 static int verbose = 1;
+static int print_only = 0;
 
 /* for running system() */
 static char cmd[128];
@@ -70,10 +71,10 @@ void usage(FILE *out)
                 "\ttarget types:\n"
                 "\t\t--ost: object storage, mutually exclusive with mdt\n"
                 "\t\t--mdt: metadata storage, mutually exclusive with ost\n"
-                "\t\t--mgmt: configuration management service - one per site\n"
+                "\t\t--mgs: configuration management service - one per site\n"
                 "\toptions:\n"
-                "\t\t--mgmtnid=<nid>[,<...>] : NID(s) of a remote mgmt node\n"
-                "\t\t\trequired for all targets other than the mgmt node\n"
+                "\t\t--mgsnid=<nid>[,<...>] : NID(s) of a remote mgs node\n"
+                "\t\t\trequired for all targets other than the mgs node\n"
                 "\t\t--fsname=<filesystem_name> : default is 'lustre'\n"
 #if 0 /* FIXME implement */
                 "\t\t--configdev=<altdevice|file>: store configuration info\n"
@@ -91,6 +92,8 @@ void usage(FILE *out)
                 "\t\t--mkfsoptions=<opts> : format options\n"
                 "\t\t--reformat: overwrite an existing disk\n"
 #endif
+                "\t\t--print: just report what we would do; don't write to "
+                "disk\n"
                 "\t\t--timeout=<secs> : system timeout period\n"
                 "\t\t--verbose\n"
                 "\t\t--quiet\n");
@@ -143,11 +146,10 @@ int get_os_version()
         return version;
 }
 
-/* FIXME use popen */
 int run_command(char *cmd)
 {
-       int i = 0,ret = 0;
-       FILE *rfile = NULL;
+       int i = 0;
+       FILE *fp = NULL;
 
        if (verbose > 1)
                printf("cmd: %s\n", cmd);
@@ -156,28 +158,23 @@ int run_command(char *cmd)
        strcat(cmd, ret_file);
        strcat(cmd, " 2>&1");
   
-       ret = system(cmd);
-
-       rfile = fopen(ret_file, "r");
-       if (rfile == NULL){
-                fprintf(stderr,"%s: Could not open %s \n", progname, ret_file);
-                exit(2);
+       fp = popen(cmd, "r");
+       if (!fp) {
+               fprintf(stderr, "%s: %s\n", progname, strerror(errno));
+               return -1;
        }
       
        memset(cmd_out, 0, sizeof(cmd_out));
-       while (fgets(cmd_out[i], 128, rfile) != NULL) {
+       while (fgets(cmd_out[i], 128, fp) != NULL) {
                if (verbose > 2) 
                        printf("  _ %s", cmd_out[i]); 
                i++;
-               if (i >= 32) {
-                       fprintf(stderr,"%s: WARNING losing some output from %s",
-                               progname, cmd);
+               if (i >= 32) 
                        break;
-               }
        }
-       fclose(rfile);
+       pclose(fp);
 
-       return ret;
+       return 0;
 }
 
 static void run_command_out()
@@ -191,19 +188,20 @@ static void run_command_out()
 }
 
 static int lnet_setup = 0;
-static void lnet_start()
+static int lnet_start()
 {
         ptl_initialize(0, NULL);
         if (access("/proc/sys/lnet", X_OK) != 0) {
                 fprintf(stderr, "%s: The LNET module must be loaded to "
                         "determine local NIDs\n", progname);
-                exit(1);
+                return 1;
         }
         if (jt_ptl_get_nids(NULL) == -ENETDOWN) {
                 char *cmd[]={"network", "up"};
                 jt_ptl_network(2, cmd);
                 lnet_setup++;
         }
+        return 0;
 }
 
 static void lnet_stop()
@@ -230,7 +228,7 @@ int loop_setup(struct mkfs_opts *mop)
                 strcpy(loop_base, "/dev/loop/\0");
         else {
                 fprintf(stderr, "%s: can't access loop devices\n", progname);
-                exit(1);
+                return 1;
         }
 
         /* Find unused loop device */
@@ -238,18 +236,19 @@ int loop_setup(struct mkfs_opts *mop)
                 sprintf(l_device, "%s%d", loop_base, i);
                 if (access(l_device, F_OK | R_OK)) 
                         break;
-
-                sprintf(cmd, "losetup %s", l_device);
-                ret = run_command(cmd);
-                /* losetup gets 1 (256?) for good non-set-up device */
+                sprintf(cmd, "losetup %s > /dev/null 2>&1", l_device);
+                if (verbose > 1) 
+                        printf("cmd: %s\n", cmd);
+                ret = system(cmd);
+                /* losetup gets 1 (ret=256) for non-set-up device */
                 if (ret) {
-                        /* Setup up a loopback device to our file */
+                        /* Set up a loopback device to our file */
                         sprintf(cmd, "losetup %s %s", l_device, mop->mo_device);
                         ret = run_command(cmd);
                         if (ret) {
                                 fprintf(stderr, "%s: error %d on losetup: %s\n",
                                         progname, ret, strerror(ret));
-                                exit(8);
+                                return ret;
                         }
                         strcpy(mop->mo_loopdev, l_device);
                         return ret;
@@ -263,7 +262,7 @@ int loop_setup(struct mkfs_opts *mop)
 int loop_cleanup(struct mkfs_opts *mop)
 {
         int ret = 1;
-        if (mop->mo_flags & MO_IS_LOOP) {
+        if ((mop->mo_flags & MO_IS_LOOP) && *mop->mo_loopdev) {
                 sprintf(cmd, "losetup -d %s", mop->mo_loopdev);
                 ret = run_command(cmd);
         }
@@ -282,7 +281,7 @@ int is_block(char* devname)
         ret = stat(devname, &st);
         if (ret != 0) {
                 fprintf(stderr, "%s: cannot stat %s\n", progname, devname);
-                exit(4);
+                return -1;
         }
         return S_ISBLK(st.st_mode);
 }
@@ -305,7 +304,7 @@ __u64 get_device_size(char* device)
         if (fd < 0) {
                 fprintf(stderr, "%s: cannot open %s: %s\n", 
                         progname, device, strerror(errno));
-                exit(4);
+                return 0;
         }
 
         ret = ioctl(fd, BLKGETSIZE64, (void*)&size);
@@ -313,7 +312,7 @@ __u64 get_device_size(char* device)
         if (ret < 0) {
                 fprintf(stderr, "%s: size ioctl failed: %s\n", 
                         progname, strerror(errno));
-                exit(4);
+                return 0;
         }
         
         return size;
@@ -348,7 +347,6 @@ static int file_in_dev(char *file_name, char *dev_name)
         char debugfs_cmd[256];
         unsigned int inode_num;
 
-        vprint("checking %s\n", file_name);
         /* Construct debugfs command line. */
         memset(debugfs_cmd, 0, sizeof(debugfs_cmd));
         sprintf(debugfs_cmd, "debugfs -c -R 'stat %s' %s 2>&1 | egrep Inode",
@@ -374,9 +372,12 @@ static int is_lustre_target(struct mkfs_opts *mop)
 {
         /* Check whether there exist MOUNT_DATA_FILE,
            LAST_RCVD or CATLIST in the device. */
+        vprint("checking for existing Lustre data\n");
+        
         if (file_in_dev(MOUNT_DATA_FILE, mop->mo_device)
             || file_in_dev(LAST_RCVD, mop->mo_device)
             || file_in_dev(CATLIST, mop->mo_device)) { 
+                vprint("found Lustre data\n");
                 return 1; 
         }
 
@@ -407,8 +408,11 @@ int make_lustre_backfs(struct mkfs_opts *mop)
                 __u64 device_sz = mop->mo_device_sz;
 
                 /* we really need the size */
-                if (device_sz == 0)
+                if (device_sz == 0) {
                         device_sz = get_device_size(mop->mo_device);
+                        if (device_sz == 0) 
+                                return ENODEV;
+                }
 
                 if (strstr(mop->mo_mkfsopts, "-J") == NULL) {
                         /* Choose our own default journal size */
@@ -509,7 +513,7 @@ int make_lustre_backfs(struct mkfs_opts *mop)
 
         vprint("mkfs_cmd = %s\n", mkfs_cmd);
         ret = run_command(mkfs_cmd);
-        if (ret != 0) {
+        if (ret) {
                 fatal();
                 fprintf(stderr, "Unable to build fs: %s \n", dev);
                 run_command_out();
@@ -522,24 +526,35 @@ out:
 
 /* ==================== Lustre config functions =============*/
 
-void print_ldd(struct lustre_disk_data *ldd)
+void print_ldd(char *str, struct lustre_disk_data *ldd)
 {
         int i = 0;
-        printf("\nPermanent disk data:\n");
+        printf("\n   %s:\n", str);
         printf("Target:     %s\n", ldd->ldd_svname);
+        printf("Index:      %d\n", ldd->ldd_svindex);
+        printf("UUID:       %s\n", (char *)ldd->ldd_uuid);
         printf("Lustre FS:  %s\n", ldd->ldd_fsname);
         printf("Mount type: %s\n", MT_STR(ldd));
-        printf("Flags:      %s%s%s%s%s\n",
-               IS_MDT(ldd) ? "MDT ":"", IS_OST(ldd) ? "OST ":"",
-               IS_MGMT(ldd) ? "MGMT ":"",
-               ldd->ldd_flags & LDD_F_NEED_INDEX   ? "needs_index ":"",
-               ldd->ldd_flags & LDD_F_NEED_REGISTER   ? "must_register ":"");
+        printf("Flags:      %#x\n", ldd->ldd_flags);
+        printf("              (%s%s%s%s%s%s)\n",
+               IS_MDT(ldd) ? "MDT ":"", 
+               IS_OST(ldd) ? "OST ":"",
+               IS_MGS(ldd) ? "MGS ":"",
+               ldd->ldd_flags & LDD_F_NEED_INDEX ? "needs_index ":"",
+               ldd->ldd_flags & LDD_F_NEED_REGISTER ? "must_register ":"",
+               ldd->ldd_flags & LDD_F_UPGRADE14 ? "upgrade1.4 ":"");
         printf("Persistent mount opts: %s\n", ldd->ldd_mount_opts);
         printf("MGS nids: ");
         for (i = 0; i < ldd->ldd_mgsnid_count; i++) {
                 printf("%c %s", (i == 0) ? ' ' : ',',
                        libcfs_nid2str(ldd->ldd_mgsnid[i]));
         }
+        printf("\nFailover nids: ");
+        for (i = 0; i < ldd->ldd_failnid_count; i++) {
+                printf("%c %s", (i == 0) ? ' ' : ',',
+                       libcfs_nid2str(ldd->ldd_failnid[i]));
+        }
+
         printf("\n\n");
 }
 
@@ -595,6 +610,40 @@ int write_local_files(struct mkfs_opts *mop)
         fwrite(&mop->mo_ldd, sizeof(mop->mo_ldd), 1, filep);
         fclose(filep);
         
+#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 */
+                vprint("Copying old logs\n");
+                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,
+                        filepnm);
+                if (verbose > 1) 
+                        printf("cmd: %s\n", cmd);
+                ret = system(cmd);
+                if (ret) {
+                        fprintf(stderr, "%s: Can't copy 1.4 config %s/client "
+                                "(%d)\n", progname, MDT_LOGS_DIR, ret);
+                        fprintf(stderr, "mount -t ext3 %s somewhere, "
+                                "find the client log for fs %s and "
+                                "copy it manually into %s/%s-client, "
+                                "then umount.\n",
+                                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 
+                   to fsname-MDT0000 */
+                /* FIXME Yuk - parse the client log to find mdt name? */
+                //filep = fopen(filepnm, "r");
+
+        }
+#endif
+
 out_umnt:
         vprint("unmounting backing device\n");
         umount(mntpt);    
@@ -603,6 +652,103 @@ out_rmdir:
         return ret;
 }
 
+int read_local_files(struct mkfs_opts *mop)
+{
+        char mntpt[] = "/tmp/mntXXXXXX";
+        char filepnm[128];
+        char *dev;
+        FILE *filep;
+        int ret = 0;
+
+        /* Mount this device temporarily in order to read these files */
+        vprint("mounting backing device\n");
+        if (!mkdtemp(mntpt)) {
+                fprintf(stderr, "%s: Can't create temp mount point %s: %s\n",
+                        progname, mntpt, strerror(errno));
+                return errno;
+        }
+
+        dev = mop->mo_device;
+        if (mop->mo_flags & MO_IS_LOOP) 
+                dev = mop->mo_loopdev;
+        
+        ret = mount(dev, mntpt, MT_STR(&mop->mo_ldd), 0, NULL);
+        if (ret) {
+                fprintf(stderr, "%s: Unable to mount %s: %s\n", 
+                        progname, mop->mo_device, strerror(ret));
+                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 {
+                /* 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",
+                        progname, MOUNT_DATA_FILE);
+                sprintf(filepnm, "%s/%s", mntpt, LAST_RCVD);
+                filep = fopen(filepnm, "r");
+                if (!filep) {
+                        fprintf(stderr, "%s: Unable to read old data\n",
+                                progname);
+                        ret = errno;
+                        goto out_umnt;
+                }
+                vprint("Reading %s\n", LAST_RCVD);
+                fread(&lsd, sizeof(lsd), 1, filep);
+
+                if (lsd.lsd_feature_compat & OBD_COMPAT_OST) {
+                        mop->mo_ldd.ldd_flags = LDD_F_SV_TYPE_OST;
+                        mop->mo_ldd.ldd_svindex = lsd.lsd_ost_index;
+                } else if (lsd.lsd_feature_compat & OBD_COMPAT_MDT) {
+                        /* We must co-locate so mgs can see old logs.
+                           If user doesn't want this, they can copy the old
+                           logs manually and re-tunefs. */
+                        mop->mo_ldd.ldd_flags = 
+                                LDD_F_SV_TYPE_MDT | LDD_F_SV_TYPE_MGS;
+                        mop->mo_ldd.ldd_svindex = lsd.lsd_mdt_index;
+                } else  {
+                        /* If neither is set, we're pre-1.4.6, make a guess. */
+                        sprintf(filepnm, "%s/%s", mntpt, MDT_LOGS_DIR);
+                        if (lsd.lsd_ost_index > 0) {
+                                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) 
+                                        mop->mo_ldd.ldd_flags =
+                                        LDD_F_SV_TYPE_MDT | 
+                                        LDD_F_SV_TYPE_MGS;
+                                else
+                                        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;
+                        }
+                }
+
+                memcpy(mop->mo_ldd.ldd_uuid, lsd.lsd_uuid, 
+                       sizeof(mop->mo_ldd.ldd_uuid));
+                mop->mo_ldd.ldd_flags |= LDD_F_UPGRADE14;
+        }
+        fclose(filep);
+        
+out_umnt:
+        vprint("unmounting backing device\n");
+        umount(mntpt);    
+out_rmdir:
+        rmdir(mntpt);
+        return ret;
+}
+
+
 void set_defaults(struct mkfs_opts *mop)
 {
         mop->mo_ldd.ldd_magic = LDD_MAGIC;
@@ -621,17 +767,16 @@ void set_defaults(struct mkfs_opts *mop)
         mop->mo_ldd.ldd_stripe_pattern = 0;
 }
 
-static inline void badopt(char opt, char *type)
+static inline void badopt(const char *opt, char *type)
 {
-        fprintf(stderr, "%s: '%c' only valid for %s\n",
+        fprintf(stderr, "%s: '--%s' only valid for %s\n",
                 progname, opt, type);
         usage(stderr);
-        exit(1);
 }
 
-int main(int argc , char *const argv[])
+int parse_opts(int argc, char *const argv[], struct mkfs_opts *mop,
+               char *mountopts)
 {
-        struct mkfs_opts mop;
         static struct option long_opt[] = {
                 {"backfstype", 1, 0, 'b'},
                 {"configdev", 1, 0, 'C'},
@@ -640,11 +785,12 @@ int main(int argc , char *const argv[])
                 {"failover", 1, 0, 'f'},
                 {"help", 0, 0, 'h'},
                 {"mdt", 0, 0, 'M'},
-                {"mgmt", 0, 0, 'G'},
-                {"mgmtnid", 1, 0, 'm'},
+                {"mgs", 0, 0, 'G'},
+                {"mgsnid", 1, 0, 'm'},
                 {"mkfsoptions", 1, 0, 'k'},
                 {"mountfsoptions", 1, 0, 'o'},
                 {"ost", 0, 0, 'O'},
+                {"print", 0, 0, 'p'},
                 {"quiet", 0, 0, 'q'},
                 {"reformat", 0, 0, 'r'},
                 {"startupwait", 1, 0, 'w'},
@@ -656,132 +802,148 @@ int main(int argc , char *const argv[])
                 {"verbose", 0, 0, 'v'},
                 {0, 0, 0, 0}
         };
-        char *optstring = "b:C:d:n:f:hI:MGm:k:o:Oqrw:c:s:i:t:v";
+        char *optstring = "b:C:d:n:f:hI:MGm:k:o:Opqrw:c:s:i:t:v";
         char opt;
-        char *mountopts = NULL;
-        int  ret = 0;
-
-        if ((progname = strrchr(argv[0], '/')) != NULL)
-                progname++;
-        else
-                progname = argv[0];
-
-        if (argc < 3) {
-                usage(stderr);
-                exit(0);
-        }
-
-        memset(&mop, 0, sizeof(mop));
-        set_defaults(&mop);
+        int longidx;
 
-        while ((opt = getopt_long(argc, argv, optstring, long_opt, NULL)) != 
+        while ((opt = getopt_long(argc, argv, optstring, long_opt, &longidx)) != 
                EOF) {
                 switch (opt) {
                 case 'b': {
                         int i = 0;
                         while (i < LDD_MT_LAST) {
                                 if (strcmp(optarg, mt_str(i)) == 0) {
-                                        mop.mo_ldd.ldd_mount_type = i;
+                                        mop->mo_ldd.ldd_mount_type = i;
                                         break;
                                 }
                                 i++;
                         }
                         break;
                 }
-                case 'C': /* Configdev */
-                        //FIXME
-                        exit(2);
                 case 'c':
-                        if (IS_MDT(&mop.mo_ldd)) {
+                        if (IS_MDT(&mop->mo_ldd)) {
                                 int stripe_count = atol(optarg);
                                 if (stripe_count <= 0) {
                                         fprintf(stderr, "%s: bad stripe count "
                                                 "%d\n", progname, stripe_count);
-                                        exit(1);
+                                        return 1;
                                 }
-                                mop.mo_ldd.ldd_stripe_count = stripe_count;
+                                mop->mo_ldd.ldd_stripe_count = stripe_count;
                         } else {
-                                badopt(opt, "MDT");
+                                badopt(long_opt[longidx].name, "MDT");
+                                return 1;
                         }
                         break;
+                case 'C': /* Configdev */
+                        //FIXME
+                        printf("Configdev not implemented\n");
+                        return 1;
                 case 'd':
-                        mop.mo_device_sz = atol(optarg); 
-                        break;
-                case 'k':
-                        strncpy(mop.mo_mkfsopts, optarg, 
-                                sizeof(mop.mo_mkfsopts) - 1);
+                        mop->mo_device_sz = atol(optarg); 
                         break;
-                case 'f':
-                        /* we must pass this info on when we register with
-                           the mgs */
-                        // FIXME
+                case 'f': {
+                        int i = 0;
+                        char *s1 = optarg, *s2;
+                        if (IS_MGS(&mop->mo_ldd)) {
+                                badopt(long_opt[longidx].name, 
+                                       "non-MGMT MDT,OST");
+                                return 1;
+                        }
+                        while ((s2 = strsep(&s1, ","))) {
+                                mop->mo_ldd.ldd_failnid[i++] =
+                                        libcfs_str2nid(s2);
+                                if (i >= MTI_NIDS_MAX) {
+                                        fprintf(stderr, "%s: too many failover "
+                                                "nids, ignoring %s...\n", 
+                                                progname, s1);
+                                        break;
+                                }
+                        }
+                        mop->mo_ldd.ldd_failnid_count = i;
                         break;
+                }
                 case 'G':
-                        mop.mo_ldd.ldd_flags |= LDD_F_SV_TYPE_MGMT;
+                        mop->mo_ldd.ldd_flags |= LDD_F_SV_TYPE_MGS;
                         break;
                 case 'h':
                         usage(stdout);
-                        exit(0);
+                        return 1;
                 case 'i':
-                        if (IS_MDT(&mop.mo_ldd) || IS_OST(&mop.mo_ldd)) {
-                                mop.mo_ldd.ldd_svindex = atoi(optarg);
-                                mop.mo_ldd.ldd_flags &= ~LDD_F_NEED_INDEX;
+                        if (IS_MDT(&mop->mo_ldd) || IS_OST(&mop->mo_ldd)) {
+                                mop->mo_ldd.ldd_svindex = atoi(optarg);
+                                mop->mo_ldd.ldd_flags &= ~LDD_F_NEED_INDEX;
                         } else {
-                                badopt(opt, "MDT,OST");
+                                badopt(long_opt[longidx].name, "MDT,OST");
+                                return 1;
                         }
                         break;
+                case 'k':
+                        strncpy(mop->mo_mkfsopts, optarg, 
+                                sizeof(mop->mo_mkfsopts) - 1);
+                        break;
                 case 'm': {
                         int i = 0;
                         char *s1 = optarg, *s2;
-                        if (IS_MGMT(&mop.mo_ldd))
-                                badopt(opt, "non-MGMT MDT,OST");
+                        if (IS_MGS(&mop->mo_ldd)) {
+                                badopt(long_opt[longidx].name, 
+                                       "non-MGMT MDT,OST");
+                                return 1;
+                        }
                         while ((s2 = strsep(&s1, ","))) {
-                                mop.mo_ldd.ldd_mgsnid[i++] =
+                                mop->mo_ldd.ldd_mgsnid[i++] =
                                         libcfs_str2nid(s2);
                                 if (i >= MTI_NIDS_MAX) {
                                         fprintf(stderr, "%s: too many MGS nids,"
-                                                " ignoring %s\n", progname, s1);
+                                                " ignoring %s...\n", 
+                                                progname, s1);
                                         break;
                                 }
                         }
-                        mop.mo_ldd.ldd_mgsnid_count = i;
+                        mop->mo_ldd.ldd_mgsnid_count = i;
                         break;
                 }
                 case 'M':
-                        mop.mo_ldd.ldd_flags |= LDD_F_SV_TYPE_MDT;
+                        mop->mo_ldd.ldd_flags |= LDD_F_SV_TYPE_MDT;
                         break;
                 case 'n':
-                        if (!(IS_MDT(&mop.mo_ldd) || IS_OST(&mop.mo_ldd)))
-                                badopt(opt, "MDT,OST");
+                        if (!(IS_MDT(&mop->mo_ldd) || IS_OST(&mop->mo_ldd))) {
+                                badopt(long_opt[longidx].name, "MDT,OST");
+                                return 1;
+                        }
                         if (strlen(optarg) > 8) {
                                 fprintf(stderr, "%s: filesystem name must be "
                                         "<= 8 chars\n", progname);
-                                exit(1);
+                                return 1;
                         }
                         if (optarg[0] != 0) 
-                                strncpy(mop.mo_ldd.ldd_fsname, optarg, 
-                                        sizeof(mop.mo_ldd.ldd_fsname) - 1);
+                                strncpy(mop->mo_ldd.ldd_fsname, optarg, 
+                                        sizeof(mop->mo_ldd.ldd_fsname) - 1);
                         break;
                 case 'o':
                         mountopts = optarg;
                         break;
                 case 'O':
-                        mop.mo_ldd.ldd_flags |= LDD_F_SV_TYPE_OST;
+                        mop->mo_ldd.ldd_flags |= LDD_F_SV_TYPE_OST;
+                        break;
+                case 'p':
+                        print_only++;
                         break;
                 case 'q':
                         verbose--;
                         break;
                 case 'r':
-                        mop.mo_flags |= MO_FORCEFORMAT;
+                        mop->mo_flags |= MO_FORCEFORMAT;
                         break;
                 case 's':
-                        if (IS_MDT(&mop.mo_ldd)) 
-                                mop.mo_ldd.ldd_stripe_sz = atol(optarg) * 1024;
-                        else 
-                                badopt(opt, "MDT");
+                        if (IS_MDT(&mop->mo_ldd)) {
+                                mop->mo_ldd.ldd_stripe_sz = atol(optarg) * 1024;
+                        } else {
+                                badopt(long_opt[longidx].name, "MDT");
+                                return 1;
+                        }
                         break;
                 case 't':
-                        mop.mo_ldd.ldd_timeout = atol(optarg);
+                        mop->mo_ldd.ldd_timeout = atol(optarg);
                         break;
                 case 'v':
                         verbose++;
@@ -792,37 +954,114 @@ int main(int argc , char *const argv[])
                                 fprintf(stderr, "Unknown option '%c'\n", opt);
                         }
                         usage(stderr);
-                        exit(1);
+                        return 1;
                 }
         }//while
         if (optind >= argc) {
                 fatal();
                 fprintf(stderr, "Bad arguments\n");
                 usage(stderr);
-                exit(1);
+                return 1;
+        }
+
+        return 0;
+}
+
+int main(int argc, char *const argv[])
+{
+        struct mkfs_opts mop;
+        char *mountopts = NULL;
+        char default_mountopts[1024] = "";
+        int  ret = 0;
+
+        if ((progname = strrchr(argv[0], '/')) != NULL)
+                progname++;
+        else
+                progname = argv[0];
+
+        if (argc < 2) {
+                usage(stderr);
+                ret = 1;
+                goto out;
         }
 
+        memset(&mop, 0, sizeof(mop));
+        set_defaults(&mop);
+
+        /* device is last arg */
+        strcpy(mop.mo_device, argv[argc - 1]);
+        /* Are we using a loop device? */
+        ret = is_block(mop.mo_device);
+        if (ret < 0) 
+                goto out;
+        if (ret == 0) 
+                mop.mo_flags |= MO_IS_LOOP;
+
+#ifdef TUNEFS
+        /* For tunefs, we must read in the old values before parsing any
+           new ones. */
+        /* Create the loopback file */
+        if (mop.mo_flags & MO_IS_LOOP) {
+                ret = access(mop.mo_device, F_OK);
+                if (ret == 0)  
+                        ret = loop_setup(&mop);
+                if (ret) {
+                        fatal();
+                        fprintf(stderr, "Loop device setup for %s failed: %s\n", 
+                                mop.mo_device, strerror(ret));
+                        goto out;
+                }
+        }
+        
+        /* Check whether the disk has already been formatted by mkfs.lustre */
+        ret = is_lustre_target(&mop);
+        if (ret == 0) {
+                fatal();
+                fprintf(stderr, "Device %s has not been formatted with "
+                        "mkfs.lustre\n", mop.mo_device);
+                goto out;
+        }
+
+        ret = read_local_files(&mop);
+        if (ret) {
+                fatal();
+                fprintf(stderr, "Failed to read previous Lustre data from %s\n",
+                        mop.mo_device);
+                goto out;
+        }
+
+        if (verbose > 0) 
+                print_ldd("Read previous values", &(mop.mo_ldd));
+#endif
+
+        ret = parse_opts(argc, argv, &mop, mountopts);
+        if (ret) 
+                goto out;
+
         if (!(IS_MDT(&mop.mo_ldd) || IS_OST(&mop.mo_ldd) || 
-              IS_MGMT(&mop.mo_ldd))) {
+              IS_MGS(&mop.mo_ldd))) {
                 fatal();
-                fprintf(stderr, "must set target type :{mdt,ost,mgmt}\n");
+                fprintf(stderr, "must set target type :{mdt,ost,mgs}\n");
                 usage(stderr);
-                exit(1);
+                ret = 1;
+                goto out;
         }
 
-        if (IS_MDT(&mop.mo_ldd) && !IS_MGMT(&mop.mo_ldd) && 
+        if (IS_MDT(&mop.mo_ldd) && !IS_MGS(&mop.mo_ldd) && 
             mop.mo_ldd.ldd_mgsnid_count == 0) {
                 vprint("No management node specified, adding MGS to this "
                        "MDT\n");
-                mop.mo_ldd.ldd_flags |= LDD_F_SV_TYPE_MGMT;
+                mop.mo_ldd.ldd_flags |= LDD_F_SV_TYPE_MGS;
         }
 
-        if (IS_MGMT(&mop.mo_ldd) && (mop.mo_ldd.ldd_mgsnid_count == 0)) {
+        if (IS_MGS(&mop.mo_ldd) && (mop.mo_ldd.ldd_mgsnid_count == 0)) {
                 int i;
                 __u64 *nids;
                 
-                vprint("No mgmt nids specified, using all local nids\n");
-                lnet_start();
+                vprint("No mgs nids specified, using all local nids\n");
+                ret = lnet_start();
+                if (ret)
+                        goto out;
                 i = jt_ptl_get_nids(&nids);
                 if (i < 0) {
                         fprintf(stderr, "%s: Can't find local nids "
@@ -842,36 +1081,35 @@ int main(int argc , char *const argv[])
 
         if (mop.mo_ldd.ldd_mgsnid_count == 0) {
                 fatal();
-                fprintf(stderr, "Must specify either --mgmt or --mgmtnode\n");
+                fprintf(stderr, "Must specify either --mgs or --mgsnid\n");
                 usage(stderr);
                 goto out;
         }
 
-        strcpy(mop.mo_device, argv[optind]);
-        
         /* These are the permanent mount options (always included) */ 
         switch (mop.mo_ldd.ldd_mount_type) {
         case LDD_MT_EXT3:
         case LDD_MT_LDISKFS: {
-                sprintf(mop.mo_ldd.ldd_mount_opts, "errors=remount-ro");
-                if (IS_MDT(&mop.mo_ldd) || IS_MGMT(&mop.mo_ldd))
-                        strcat(mop.mo_ldd.ldd_mount_opts,
+                sprintf(default_mountopts, "errors=remount-ro");
+                if (IS_MDT(&mop.mo_ldd) || IS_MGS(&mop.mo_ldd))
+                        strcat(default_mountopts,
                                ",iopen_nopriv,user_xattr");
                 if ((get_os_version() == 24) && IS_OST(&mop.mo_ldd))
-                        strcat(mop.mo_ldd.ldd_mount_opts, ",asyncdel");
+                        strcat(default_mountopts, ",asyncdel");
 #if 0
                 /* Files created while extents are enabled cannot be read if
                    mounted with a kernel that doesn't include the CFS patches.*/
                 if ((get_os_version() == 26) && IS_OST(&mop.mo_ldd) && 
                     mop.mo_ldd.ldd_mount_type == LDD_MT_LDISKFS) {
-                        strcat(mop.mo_ldd.ldd_mount_opts, ",extents,mballoc");
+                        strcat(default_mountopts, ",extents,mballoc");
                 }
 #endif               
  
                 break;
         }
         case LDD_MT_SMFS: {
-                sprintf(mop.mo_ldd.ldd_mount_opts, "type=ext3,dev=%s",
+                mop.mo_flags |= MO_IS_LOOP;
+                sprintf(default_mountopts, "type=ext3,dev=%s",
                         mop.mo_device);
                 break;
         }
@@ -885,38 +1123,42 @@ int main(int argc , char *const argv[])
         }
         }               
 
-        /* User supplied */
-        if (mountopts) {
-                strcat(mop.mo_ldd.ldd_mount_opts, ",");
-                strcat(mop.mo_ldd.ldd_mount_opts, mountopts);
-        }
+#ifndef TUNEFS /* mkfs.lustre */
+        if (mountopts) 
+                /* Tack on user supplied opts */
+                sprintf(mop.mo_ldd.ldd_mount_opts, "%s,%s", 
+                        default_mountopts, mountopts);
+        else
+                strcpy(mop.mo_ldd.ldd_mount_opts, default_mountopts);
+#else   /* tunefs.lustre - if mountopts are specified, they override 
+           whatever we had before, so no defaults. */
+        if (mountopts) 
+                strcpy(mop.mo_ldd.ldd_mount_opts, mountopts);
+        else if (*mop.mo_ldd.ldd_mount_opts == 0) 
+                /* no mount opts were set ever, use the defaults. */
+                strcpy(mop.mo_ldd.ldd_mount_opts, default_mountopts);
+        /* otherwise, use the old. */
+#endif
 
-        /* Are we using a loop device? */
-        if (!is_block(mop.mo_device) || 
-            (mop.mo_ldd.ldd_mount_type == LDD_MT_SMFS))
-                mop.mo_flags |= MO_IS_LOOP;
-                
         ldd_make_sv_name(&(mop.mo_ldd));
 
         if (verbose > 0)
-                print_ldd(&(mop.mo_ldd));
+                print_ldd("Permanent disk data", &(mop.mo_ldd));
+
+        if (print_only) {
+                printf("exiting before disk write.\n");
+                goto out;
+        }
 
 #ifndef TUNEFS /* mkfs.lustre */
-        /* Create the loopback file */
+        /* Create the loopback file of the correct size */
         if (mop.mo_flags & MO_IS_LOOP) {
                 ret = access(mop.mo_device, F_OK);
-                if (ret) 
+                /* Don't destroy the loopback file if no FORCEFORMAT */
+                if (ret || (mop.mo_flags & MO_FORCEFORMAT))
                         ret = loop_format(&mop);
-                if (!ret) {     
-                        /* Device already exists or loop_format() succeeds. */
+                if (ret == 0)  
                         ret = loop_setup(&mop);
-                        if (mop.mo_device_sz == 0) {
-                                fatal();
-                                fprintf(stderr, "loop device requires a "
-                                        "--device-size= param\n");
-                                goto out;
-                        }
-                }
                 if (ret) {
                         fatal();
                         fprintf(stderr, "Loop device setup failed: %s\n", 
@@ -930,49 +1172,21 @@ int main(int argc , char *const argv[])
                 ret = is_lustre_target(&mop);
                 if (ret) {
                         fatal();
-                        fprintf(stderr, "Device %s has already been formatted," 
-                                " use --reformat to reformat it.\n",
+                        fprintf(stderr, "Device %s was previously formatted " 
+                                "for lustre. Use --reformat to reformat it, "
+                                "or tunefs.lustre to modify.\n",
                                 mop.mo_device);
                         goto out;
                 }
         }
 
+        /* Format the backing filesystem */
         ret = make_lustre_backfs(&mop);
         if (ret != 0) {
                 fatal();
                 fprintf(stderr, "mkfs failed %d\n", ret);
                 goto out;
         }
-
-#else   /* tunefs.lustre */
-        /* Set up the loopback file */
-        if (mop.mo_flags & MO_IS_LOOP) {
-                ret = access(mop.mo_device, F_OK);
-                if (ret) {
-                        fatal();
-                        fprintf(stderr, "Device %s does not exist!\n", 
-                                mop.mo_device);
-                        lnet_stop();
-                        return ret;
-                }
-
-                ret = loop_setup(&mop);
-                if (ret) {
-                        fatal();
-                        fprintf(stderr, "Loop device setup failed: %s\n", 
-                                strerror(ret));
-                        goto out;
-                }
-        }
-
-        /* Check whether the disk has already been formatted by mkfs.lustre */
-        ret = is_lustre_target(&mop);
-        if (!ret) {
-                fatal();
-                fprintf(stderr, "Device %s has not been formatted with "
-                        "mkfs.lustre\n", mop.mo_device);
-                goto out;
-        }
 #endif
 
         ret = write_local_files(&mop);
index ee4bef3..b7a674a 100644 (file)
@@ -938,11 +938,11 @@ main(int argc, char **argv)
         CHECK_VALUE(LCK_GROUP);
         CHECK_VALUE(LCK_MAXMODE);
 
-        CHECK_VALUE(MGMT_CONNECT);
-        CHECK_VALUE(MGMT_DISCONNECT);
-        CHECK_VALUE(MGMT_EXCEPTION);
-        CHECK_VALUE(MGMT_TARGET_ADD);
-        CHECK_VALUE(MGMT_TARGET_DEL);
+        CHECK_VALUE(MGS_CONNECT);
+        CHECK_VALUE(MGS_DISCONNECT);
+        CHECK_VALUE(MGS_EXCEPTION);
+        CHECK_VALUE(MGS_TARGET_ADD);
+        CHECK_VALUE(MGS_TARGET_DEL);
 
         CHECK_VALUE(OBD_PING);
         CHECK_VALUE(OBD_LOG_CANCEL);
index 7df3924..70c141d 100644 (file)
@@ -189,16 +189,16 @@ void lustre_assert_wire_constants(void)
                  (long long)LCK_GROUP);
         LASSERTF(LCK_MAXMODE == 65, " found %lld\n",
                  (long long)LCK_MAXMODE);
-        LASSERTF(MGMT_CONNECT == 250, " found %lld\n",
-                 (long long)MGMT_CONNECT);
-        LASSERTF(MGMT_DISCONNECT == 251, " found %lld\n",
-                 (long long)MGMT_DISCONNECT);
-        LASSERTF(MGMT_EXCEPTION == 252, " found %lld\n",
-                 (long long)MGMT_EXCEPTION);
-        LASSERTF(MGMT_TARGET_ADD == 253, " found %lld\n",
-                 (long long)MGMT_TARGET_ADD);
-        LASSERTF(MGMT_TARGET_DEL == 254, " found %lld\n",
-                 (long long)MGMT_TARGET_DEL);
+        LASSERTF(MGS_CONNECT == 250, " found %lld\n",
+                 (long long)MGS_CONNECT);
+        LASSERTF(MGS_DISCONNECT == 251, " found %lld\n",
+                 (long long)MGS_DISCONNECT);
+        LASSERTF(MGS_EXCEPTION == 252, " found %lld\n",
+                 (long long)MGS_EXCEPTION);
+        LASSERTF(MGS_TARGET_ADD == 253, " found %lld\n",
+                 (long long)MGS_TARGET_ADD);
+        LASSERTF(MGS_TARGET_DEL == 254, " found %lld\n",
+                 (long long)MGS_TARGET_DEL);
         LASSERTF(OBD_PING == 400, " found %lld\n",
                  (long long)OBD_PING);
         LASSERTF(OBD_LOG_CANCEL == 401, " found %lld\n",