Whamcloud - gitweb
Branch b1_4_mountconf
authornathan <nathan>
Sat, 19 Nov 2005 00:31:49 +0000 (00:31 +0000)
committernathan <nathan>
Sat, 19 Nov 2005 00:31:49 +0000 (00:31 +0000)
b=8007
use a sigle mgc per node

lustre/include/linux/lustre_disk.h
lustre/llite/llite_lib.c
lustre/lvfs/fsfilt.c
lustre/mgc/mgc_request.c
lustre/mgs/mgs_handler.c
lustre/obdclass/obd_config.c
lustre/obdclass/obd_mount.c
lustre/utils/lustre_cfg.c
lustre/utils/mkfs_lustre.c

index 870305e..75a9f47 100644 (file)
@@ -71,13 +71,16 @@ static inline char *mt_str(enum ldd_mount_type mt)
 
 struct lustre_disk_data {
         __u32      ldd_magic;
+        __u32      ldd_config_ver;      /* we have integrated all llog steps
+                                           through this llog ver. */
         __u32      ldd_flags;           /* LDD_SV_TYPE */
         char       ldd_fsname[64];      /* filesystem this server is part of */
         char       ldd_svname[64];      /* this server's name (lustre-mdt0001) */
-        char       ldd_mount_opts[128]; /* target fs mount opts */
+        __u16      ldd_mgsnid_count;    /* how many failover nids we have for the MGS */
         lnet_nid_t ldd_mgsnid[MAX_FAILOVER_NIDS]; /* mgmt nid list; lmd can override */
         enum ldd_mount_type ldd_mount_type;  /* target fs type LDD_MT_* */
-        //server failover list - must pass to mgs when we first register
+        char       ldd_mount_opts[1024]; /* target fs mount opts */
+        char       ldd_pad[1024];
 };
         
 #define IS_MDT(data)   ((data)->ldd_flags & LDD_F_SV_TYPE_MDT)
@@ -215,8 +218,8 @@ void lustre_register_client_fill_super(int (*cfs)(struct super_block *sb));
 void lustre_common_put_super(struct super_block *sb);
 struct lustre_mount_info *lustre_get_mount(char *name);
 int lustre_put_mount(char *name, struct vfsmount *mnt);
-int lustre_get_process_log(struct super_block *, char *, 
-                           struct config_llog_instance *);
+int lustre_get_process_log(struct super_block *, char *,
+                           struct config_llog_instance *cfg);
 
 #endif
 
index 505ae86..569dbe8 100644 (file)
@@ -501,8 +501,9 @@ int ll_fill_super(struct super_block *sb)
 
         ll_options(lsi->lsi_lmd->lmd_opts, &osc, &mdc, &sbi->ll_flags);
 
-        /* generate a string unique to this super, let's try
-           the address of the super itself.*/
+        /* Generate a string unique to this super, in case some joker tries
+           to mount the same fs at two mount points. 
+           Use the address of the super itself.*/
         sprintf(ll_instance, "%p", sb);
         cfg.cfg_instance = ll_instance;
         cfg.cfg_uuid = lsi->lsi_llsbi->ll_sb_uuid;
index cc14ab6..2cca5dd 100644 (file)
@@ -35,16 +35,16 @@ int fsfilt_register_ops(struct fsfilt_operations *fs_ops)
         if ((found = fsfilt_search_type(fs_ops->fs_type))) {
                 if (found != fs_ops) {
                         CERROR("different operations for type %s\n",
-                              fs_ops->fs_type);
+                               fs_ops->fs_type);
                         /* unlock fsfilt_types list */
                         RETURN(-EEXIST);
                 }
         } else {
                 PORTAL_MODULE_USE;
-               list_add(&fs_ops->fs_list, &fsfilt_types);
-       }
+                list_add(&fs_ops->fs_list, &fsfilt_types);
+        }
 
-       /* unlock fsfilt_types list */
+        /* unlock fsfilt_types list */
         return 0;
 }
 
@@ -54,7 +54,7 @@ void fsfilt_unregister_ops(struct fsfilt_operations *fs_ops)
 
         /* lock fsfilt_types list */
         list_for_each(p, &fsfilt_types) {
-               struct fsfilt_operations *found;
+                struct fsfilt_operations *found;
 
                 found = list_entry(p, typeof(*found), fs_list);
                 if (found == fs_ops) {
@@ -86,9 +86,9 @@ struct fsfilt_operations *fsfilt_get_ops(const char *type)
                 }
 
                 if (rc) {
-                        CERROR("Can't find fsfilt_%s interface\n", name);
+                        CERROR("Can't find %s interface\n", name);
                         RETURN(ERR_PTR(rc));
-                       /* unlock fsfilt_types list */
+                        /* unlock fsfilt_types list */
                 }
         }
         try_module_get(fs_ops->fs_owner);
index 301dc5d..dcfd7c4 100644 (file)
@@ -265,8 +265,6 @@ static int mgc_cleanup(struct obd_device *obd)
 static int mgc_setup(struct obd_device *obd, obd_count len, void *buf)
 {
         struct client_obd *cli = &obd->u.cli;
-        struct lustre_mount_info *lmi;
-        //struct lprocfs_static_vars lvars;
         int rc;
         ENTRY;
 
@@ -287,6 +285,12 @@ static int mgc_setup(struct obd_device *obd, obd_count len, void *buf)
                 GOTO(err_rpc_lock, rc);
         }
 
+#if 0
+        struct lustre_mount_info *lmi;
+        /* FIXME There's only one mgc for all local servers.  Must mgc_fs_setup 
+           on demand only when reading a local log file, then cleanup.
+           Make sure there's a lock so nobody else can mgc_fs_setup in the 
+           meantime */
         lmi = lustre_get_mount(obd->obd_name);
         if (lmi) {
                 CERROR("mgc has local disk\n");
@@ -300,6 +304,7 @@ static int mgc_setup(struct obd_device *obd, obd_count len, void *buf)
         }
         else
                 CERROR("mgc does not have local disk (client only)\n");
+#endif
 
         INIT_LIST_HEAD(&cli->cl_mgc_open_llogs);
 
index d1cbf24..68f1182 100644 (file)
@@ -259,7 +259,7 @@ static int mgs_cleanup(struct obd_device *obd)
 
  //       mgs_update_server_data(obd, 1);
 
-        mgs_fs_cleanup(obd);
+        //mgs_fs_cleanup(obd);
 
         lustre_put_mount(obd->obd_name, mgs->mgs_vfsmnt);
         mgs->mgs_sb = NULL;
index b179682..21742ee 100644 (file)
@@ -703,6 +703,8 @@ static int class_config_llog_handler(struct llog_handle * handle,
                                 lustre_cfg_string(lcfg, 0),
                                 cfg->cfg_instance);
                         lustre_cfg_bufs_set_string(&bufs, 0, inst_name);
+                        CERROR("cmd %x, instance name: %s\n", 
+                               lcfg->lcfg_command, inst_name);
                 }
 
                 if (cfg && lcfg->lcfg_command == LCFG_ATTACH) {
index 7d8c328..f54d94d 100644 (file)
@@ -162,6 +162,10 @@ struct lustre_mount_info *lustre_get_mount(char *name)
         atomic_inc(&lsi->lsi_mounts);
         
         up(&lustre_mount_info_lock);
+        
+        CDEBUG(D_MOUNT, "get_mnt %p from %s, vfscount=%d\n", 
+               lmi->lmi_mnt, name, atomic_read(&lmi->lmi_mnt->mnt_count));
+
         return lmi;
 }
 
@@ -190,6 +194,9 @@ int lustre_put_mount(char *name, struct vfsmount *mnt)
                 return -ENOENT;
         }
 
+        CDEBUG(D_MOUNT, "put_mnt %p from %s, vfscount=%d\n", 
+               lmi->lmi_mnt, name, atomic_read(&lmi->lmi_mnt->mnt_count));
+
         lsi = s2lsi(lmi->lmi_sb);
         LASSERT(lmi->lmi_mnt == mnt);
         unlock_mntput(lmi->lmi_mnt);
@@ -214,9 +221,28 @@ int lustre_put_mount(char *name, struct vfsmount *mnt)
 
 /******* mount helper utilities *********/
 
-int parse_mount_data(struct lvfs_run_ctxt *mount_ctxt, 
-                     struct lustre_disk_data *ldd)
+static void print_ldd(struct lustre_disk_data *ldd)
 {
+        int i;
+
+        CDEBUG(D_MOUNT, "disk data\n"); 
+        CDEBUG(D_MOUNT, "config:  %d\n", ldd->ldd_config_ver);
+        CDEBUG(D_MOUNT, "fs:      %s\n", ldd->ldd_fsname);
+        CDEBUG(D_MOUNT, "server:  %s\n", ldd->ldd_svname);
+        CDEBUG(D_MOUNT, "flags:   %#x\n", ldd->ldd_flags);
+        CDEBUG(D_MOUNT, "diskfs:  %s\n", MT_STR(ldd));
+        CDEBUG(D_MOUNT, "options: %s\n", ldd->ldd_mount_opts);
+        if (!ldd->ldd_mgsnid_count) 
+                CDEBUG(D_MOUNT, "no MGS nids\n");
+        else for (i = 0; i < ldd->ldd_mgsnid_count; i++) {
+                CDEBUG(D_MOUNT, "nid %d:  %s\n", i, 
+                       libcfs_nid2str(ldd->ldd_mgsnid[i]));
+        }
+}
+
+static int parse_disk_data(struct lvfs_run_ctxt *mount_ctxt, 
+                           struct lustre_disk_data *ldd)
+{       
         struct lvfs_run_ctxt saved;
         struct file *file;
         loff_t off = 0;
@@ -234,21 +260,27 @@ int parse_mount_data(struct lvfs_run_ctxt *mount_ctxt,
  
         len = file->f_dentry->d_inode->i_size;
         CDEBUG(D_MOUNT, "Have %s, size %lu\n", MOUNT_DATA_FILE, len);
+        if (len != sizeof(*ldd)) {
+                CERROR("disk data size does not match: see %lu expect %lu\n", 
+                       len, sizeof(*ldd));
+                GOTO(out_close, err = -EINVAL);
+        }
 
         err = lustre_fread(file, ldd, len, &off);
         if (err != len) {
                 CERROR("error reading %s: read %d of %lu\n", 
                        MOUNT_DATA_FILE, err, len);
-                err = -EINVAL;
-                goto out_close;
+                GOTO(out_close, err = -EINVAL);
         }
-        err = 0;
 
         if (ldd->ldd_magic != LDD_MAGIC) {
                 CERROR("Bad magic in %s: %x!=%x\n", MOUNT_DATA_FILE, 
                        ldd->ldd_magic, LDD_MAGIC);
-                err = -EINVAL;
+                GOTO(out_close, err = -EINVAL);
         }
+        
+        err = 0;
+        print_ldd(ldd);
 
 out_close:
         filp_close(file, 0);
@@ -303,41 +335,57 @@ out:
         return(err);
 }
 
-/* Get the log "profile" from a remote MGS and process it.
-  FIXME  If remote doesn't exist, try local
-  This func should work for both clients and servers */
-int lustre_get_process_log(struct super_block *sb, char *profile,
-                           struct config_llog_instance *cfg)
+/* Get the log "profile" from a MGS and process it.  MGS might be remote
+   or local. This func should work for both clients and servers */
+int lustre_get_process_log(struct super_block *sb, char *profile, 
+                       struct config_llog_instance *cfg)
 {
         struct lustre_sb_info *lsi = s2lsi(sb);
         struct obd_device *mgc = lsi->lsi_mgc;
         struct lustre_handle mgc_conn = {0, };
-        struct obd_export *exp;
+        struct obd_export *exp = NULL;
         struct llog_ctxt *ctxt;
         int err, rc;
         LASSERT(mgc);
 
+        CDEBUG(D_MOUNT, "parsing config log %s\n", profile);
+
         err = obd_connect(&mgc_conn, mgc, &(mgc->obd_uuid), NULL);
-        if (err) {
-                CERROR("cannot connect to MGS: rc = %d\n", err);
-                return (err);
+        if (!err) {
+                exp = class_conn2export(&mgc_conn);
+                ctxt = llog_get_context(exp->exp_obd, LLOG_CONFIG_REPL_CTXT);
+        } else {
+                /* If we couldn't connect to the MGS, try reading a copy
+                   of the config log stored locally on disk */
+                CERROR("cannot connect to MGS: rc = %d\n"
+                       "Will try local log\n", err);
+                /* FIXME set up local originator with mgc_fs_setup
+                   could use ioctl (can't call directly because of layering)
+                */
+                ctxt = llog_get_context(mgc, LLOG_CONFIG_ORIG_CTXT);
+                /* FIXME set this up anyhow, and copy the mgs remote log 
+                   to the local disk */
         }
         
-        exp = class_conn2export(&mgc_conn);
+        if (!ctxt) {
+                CERROR("no config llog context\n");
+                GOTO(out, rc = -EINVAL);
+        }
 
-        ctxt = llog_get_context(exp->exp_obd, LLOG_CONFIG_REPL_CTXT);
 #if 0
         /* For debugging, it's useful to just dump the log */
         rc = class_config_dump_llog(ctxt, profile, cfg);
 #endif
         rc = class_config_parse_llog(ctxt, profile, cfg);
 
+        //FIXME cleanup local originator with mgc_fs_cleanup (if necessary)
+
         switch (rc) {
         case 0:
                 break;
         case -EINVAL:
                 LCONSOLE_ERROR("%s: The configuration '%s' could not be read "
-                               "from the MGS.  Make sure this client and the "
+                               "from the MGS.  Make sure this node and the "
                                "MGS are running compatible versions of "
                                "Lustre.\n",
                                mgc->obd_name, profile);
@@ -347,34 +395,17 @@ int lustre_get_process_log(struct super_block *sb, char *profile,
                 break;
         }
 
+out:
         /* We don't so much care about errors in cleaning up the config llog
          * connection, as we have already read the config by this point. */
-        err = obd_disconnect(exp);
-        if (err)
-                CERROR("disconnect failed: rc = %d\n", err);
-        
-        return (rc);
-}
-
-static int lustre_update_llog(struct obd_device *obd)
-{
-        int err = 0;
-
-        // FIXME this should be called from lov_add_obd?
-#if 0
-        if (mgcobd->cfobd_logs_info.ost_number > 0) {
-                struct obd_ioctl_data ioc_data = { 0 };
-                CDEBUG(D_MOUNT, "update new logs.\n");
-                err = obd_iocontrol(OBD_IOC_UPDATE_LOG, obd->obd_self_export,
-                                    sizeof ioc_data, &ioc_data, NULL);
+        if (exp) {
+                err = obd_disconnect(exp);
                 if (err)
-                        CERROR("Failed to update logs.\n");
+                        CERROR("disconnect failed: rc = %d\n", err);
         }
-#endif
-      return err;
+        return (rc);
 }
 
-
 static int do_lcfg(char *cfgname, lnet_nid_t nid, int cmd,
                    char *s1, char *s2, char *s3, char *s4)
 {
@@ -421,16 +452,24 @@ static int lustre_start_simple(char *obdname, char *type, char *s1, char *s2)
 }
 
 /* Set up a MGS to serve startup logs */
-static int lustre_start_mgs(struct super_block *sb, struct vfsmount *mnt)
+static int lustre_start_mgs(struct super_block *sb)
 {
-        char*  mgsname;
-        int    mgsname_size, err = 0;
+        struct lustre_sb_info    *lsi = s2lsi(sb);
+        struct vfsmount          *mnt = lsi->lsi_srv_mnt;
+        struct lustre_mount_info *lmi;
+        char   mgsname[] = "MGS";
+        int    err = 0;
+        LASSERT(mnt);
 
-        mgsname_size = 2 * sizeof(sb) + 5;
-        OBD_ALLOC(mgsname, mgsname_size);
-        if (!mgsname)
-                return (-ENOMEM);
-        sprintf(mgsname, "MGS_%p", sb);
+        /* It is impossible to have more than 1 MGS per node, since
+           MGC wouldn't know which to connect to */
+        lmi = lustre_find_mount(mgsname);
+        if (lmi) {
+                lsi = s2lsi(lmi->lmi_sb);
+                LCONSOLE_ERROR("The MGS service was already started from "
+                               "server %s\n", lsi->lsi_ldd->ldd_svname);
+                return -EALREADY;
+        }
 
         CDEBUG(D_CONFIG, "Start MGS service %s\n", mgsname);
 
@@ -444,18 +483,14 @@ static int lustre_start_mgs(struct super_block *sb, struct vfsmount *mnt)
                 LCONSOLE_ERROR("Failed to start MGS %s (%d).  Is the 'mgs' "
                                "module loaded?\n", mgsname, err);
 
-        OBD_FREE(mgsname, mgsname_size);
-
         return err;
 }
 
 static void lustre_stop_mgs(struct super_block *sb)
 {
         struct obd_device *obd;
-        char mgsname[2 * sizeof(sb) + 5];
+        char mgsname[] = "MGS";
 
-        sprintf(mgsname, "MGS_%p", sb);
         CDEBUG(D_MOUNT, "Stop MGS service %s\n", mgsname);
 
         obd = class_name2obd(mgsname);
@@ -468,47 +503,38 @@ static void lustre_stop_mgs(struct super_block *sb)
 }
 
 /* Set up a mgcobd to process startup logs */
-static int lustre_start_mgc(struct super_block *sb, struct vfsmount *mnt)
+static int lustre_start_mgc(struct super_block *sb)
 {
         struct lustre_sb_info *lsi = s2lsi(sb);
         struct obd_device *obd;
-        char*  mgcname;
-        int    mgcname_size, err = 0, i;
+        char mgcname[] = "MGC";
+        int  err = 0, i;
         lnet_nid_t nid;
         LASSERT(lsi->lsi_lmd);
         
+        obd = class_name2obd(mgcname);
+        if (obd) /* mgc already running */
+                goto out;
+
         if (lsi->lsi_lmd->lmd_mgsnid_count == 0) {
                 LCONSOLE_ERROR("No NIDs for the MGS were given.\n");
                 return (-EINVAL);
         }
 
-        mgcname_size = 2 * sizeof(sb) + 5;
-        OBD_ALLOC(mgcname, mgcname_size);
-        if (!mgcname)
-                GOTO(out, err = -ENOMEM);
-        sprintf(mgcname, "MGC_%p", sb);
-        
         CDEBUG(D_MOUNT, "Start MGC %s\n", mgcname);
 
-        /* register a mount for the mgc so it can call mgc_fs_setup() */
-        if (mnt != NULL) {
-                err = lustre_register_mount(mgcname, sb, mnt);
-                if (err) 
-                        GOTO(out_free, err);
-        }
-        
-        /* Add a uuid for the MGS */
+        /* Add the first uuid for the MGS */
         nid = lsi->lsi_lmd->lmd_mgsnid[0];
         err = do_lcfg(mgcname, nid, LCFG_ADD_UUID, libcfs_nid2str(nid), 0,0,0);
         if (err < 0)
-                GOTO(out_dereg, err);
+                return err;
 
         /* Start the MGC */
         if ((err = lustre_start_simple(mgcname, LUSTRE_MGC_NAME, "MGS", 
                                        libcfs_nid2str(nid))))
-                GOTO(out_dereg, err);
+                return err;
         
-        /* Add the redundant MGS's */
+        /* Add the redundant MGS nids */
         for (i = 1; i < lsi->lsi_lmd->lmd_mgsnid_count; i++) {
                 nid = lsi->lsi_lmd->lmd_mgsnid[i];
                 err = do_lcfg(mgcname, nid, LCFG_ADD_UUID, libcfs_nid2str(nid),
@@ -529,17 +555,12 @@ static int lustre_start_mgc(struct super_block *sb, struct vfsmount *mnt)
         obd = class_name2obd(mgcname);
         if (!obd) {
                 CERROR("Can't find mgcobd %s\n", mgcname);
-                GOTO(out_dereg, err = -ENOTCONN);
+                return (-ENOTCONN);
         }
-        lsi->lsi_mgc = obd;
 
-out_free:
-        OBD_FREE(mgcname, mgcname_size);
 out:
+        lsi->lsi_mgc = obd;
         return err;
-out_dereg:
-        lustre_deregister_mount(mgcname);
-        goto out_free;
 }
 
 static void lustre_stop_mgc(struct super_block *sb)
@@ -547,6 +568,7 @@ static void lustre_stop_mgc(struct super_block *sb)
         struct lustre_sb_info *lsi = s2lsi(sb);
         struct obd_device *obd;
 
+        // FIXME cleanup on refcount = 0 
         obd = lsi->lsi_mgc;
         if (obd) 
                 class_manual_cleanup(obd);
@@ -592,9 +614,9 @@ static void server_stop_servers(struct super_block *sb)
 /* Start targets */
 static int server_start_targets(struct super_block *sb, struct vfsmount *mnt)
 {
-        struct obd_ioctl_data ioc_data = { 0 };
         struct obd_device *obd;
         struct lustre_sb_info *lsi = s2lsi(sb);
+        struct config_llog_instance cfg;
         int err;
                                         
         CDEBUG(D_MOUNT, "starting target %s\n", lsi->lsi_ldd->ldd_svname);
@@ -623,22 +645,35 @@ static int server_start_targets(struct super_block *sb, struct vfsmount *mnt)
         if (lsi->lsi_ldd->ldd_flags & LDD_F_NEED_INDEX) {
                 // FIXME implement
                 CERROR("Need new target index from MGS!\n");
-                // FIXME rewrite last_rcvd, ldd (for new svname)
+                /* send TARGET_INITIAL_CONNECT, MGS should reply with index
+                   number. Maybe need to change NEED_INDEX to NEVER_CONNECTED,
+                   in case index number was given but llog still is needed.
+                   In any case, T_I_C should send current index (usually FFFF)
+                   and MGS can reply with actual index. */ 
+                /* FIXME rewrite last_rcvd, ldd (for new svname), drop
+                   NEVER_CONNECTED flag, change disk label? */
         }
 
         /* The MGC starts targets using the svname llog */
         obd = lsi->lsi_mgc;
         LASSERT(obd);
 
+        /* Register the mount for the target */
         err = lustre_register_mount(lsi->lsi_ldd->ldd_svname, sb, mnt);
         if (err) 
                 goto out;
 
+        /* FIXME replace ioctl with lustre_get_process_log 
+        struct obd_ioctl_data ioc_data = { 0 };
         ioc_data.ioc_inllen1 = strlen(lsi->lsi_ldd->ldd_svname) + 1;
         ioc_data.ioc_inlbuf1 = lsi->lsi_ldd->ldd_svname;
         
         err = obd_iocontrol(OBD_IOC_START, obd->obd_self_export,
                             sizeof ioc_data, &ioc_data, NULL);
+        */
+        cfg.cfg_instance = NULL;
+        cfg.cfg_uuid = obd->obd_uuid;
+        lustre_get_process_log(sb, lsi->lsi_ldd->ldd_svname, &cfg);
         if (err) {
                 CERROR("failed to start server %s: %d\n",
                        lsi->lsi_ldd->ldd_svname, err);
@@ -746,7 +781,7 @@ static struct vfsmount *lustre_kern_mount(struct super_block *sb)
         mount_ctxt.pwd = mnt->mnt_root;
         mount_ctxt.fs = get_ds();
 
-        err = parse_mount_data(&mount_ctxt, ldd); 
+        err = parse_disk_data(&mount_ctxt, ldd); 
         unlock_mntput(mnt);
 
         if (err) {
@@ -805,8 +840,6 @@ static void server_put_super(struct super_block *sb)
                                                                                        
         CDEBUG(D_MOUNT, "server put_super %s\n", lsi->lsi_ldd->ldd_svname);
                                                                                        
-        lustre_update_llog(obd);
-                                                                                       
         obd = class_name2obd(lsi->lsi_ldd->ldd_svname);
         if (obd) {
                 CDEBUG(D_MOUNT, "stopping %s\n", obd->obd_name);
@@ -914,13 +947,15 @@ static int server_fill_super(struct super_block *sb)
                lsi->lsi_lmd->lmd_dev);
 
         /* append ldd nids to lmd nids */
-        while ((lsi->lsi_ldd->ldd_mgsnid[i] != LNET_NID_ANY) &&
-               (lsi->lsi_lmd->lmd_mgsnid_count < MAX_FAILOVER_NIDS))
+        for (i = 0; (i < lsi->lsi_ldd->ldd_mgsnid_count) && 
+              (lsi->lsi_lmd->lmd_mgsnid_count < MAX_FAILOVER_NIDS); i++) {
                 lsi->lsi_lmd->lmd_mgsnid[lsi->lsi_lmd->lmd_mgsnid_count++] = 
-                lsi->lsi_ldd->ldd_mgsnid[i++];
+                        lsi->lsi_ldd->ldd_mgsnid[i];
+        }
 
+        /* start MGS before MGC */
         if (lsi->lsi_ldd->ldd_flags & LDD_F_SV_TYPE_MGMT) {
-                err = lustre_start_mgs(sb, mnt);
+                err = lustre_start_mgs(sb);
                 if (err) {
                         CERROR("ignoring Failed MGS start!!\n");
                         //GOTO(out_mnt, err);
@@ -929,7 +964,7 @@ static int server_fill_super(struct super_block *sb)
                 }
         }
 
-        err = lustre_start_mgc(sb, mnt);
+        err = lustre_start_mgc(sb);
         if (err) 
                 GOTO(out_mnt, err);
 
@@ -942,7 +977,11 @@ static int server_fill_super(struct super_block *sb)
         
         /* FIXME overmount client here,
            or can we just start a client log and client_fill_super on this sb? 
-           have to fix up the s_ops after! */
+           We need to make sure server_put_super gets called too - ll_put_super
+           calls lustre_common_put_super; check there for LSI_SERVER flag, 
+           call s_p_s if so. 
+           Probably should start client from new thread so we can return.
+           Client will not finish until all servers are connected. */
         err = server_fill_super_common(sb);
         if (err) 
                 GOTO(out_mnt, err);
@@ -1130,20 +1169,15 @@ int lustre_fill_super(struct super_block *sb, void *data, int silent)
         }
 
         if (lmd_is_client(lmd)) {
+                CDEBUG(D_MOUNT, "Mounting client for fs %s\n", lmd->lmd_dev);
                 if (!client_fill_super) {
                         LCONSOLE_ERROR("Nothing registered for client mount!"
                                " Is llite module loaded?\n");
                         err = -ENOSYS;
                 } else {
-                        char mgcname[64];
-                        snprintf(mgcname, sizeof(mgcname), "mgc-client-%s", 
-                                 lmd->lmd_dev);
-                        CDEBUG(D_MOUNT, "Mounting client for fs %s\n", lmd->lmd_dev);
-                        err = lustre_start_mgc(sb, NULL);
-                        if (err) {
-                                lustre_free_lsi(sb);
-                                RETURN(err);
-                        }
+                        err = lustre_start_mgc(sb);
+                        if (err) 
+                                goto out;
                         /* Connect and start */
                         /* (should always be ll_fill_super) */
                         err = (*client_fill_super)(sb);
@@ -1151,9 +1185,12 @@ int lustre_fill_super(struct super_block *sb, void *data, int silent)
         } else {
                 CDEBUG(D_MOUNT, "Mounting server\n");
                 err = server_fill_super(sb);
-                /* calls lustre_start_mgc after the mount */
+                /* s_f_s calls lustre_start_mgc after the mount because we need
+                   the MGS nids which are stored on disk.  Plus, we may
+                   need to start the MGS first. */
         }
                                                                                 
+out:
         if (err){
                 CERROR("Unable to mount %s\n", lmd->lmd_dev);
                 lustre_stop_mgc(sb);
index 755973c..a2a20a9 100644 (file)
@@ -601,7 +601,7 @@ int jt_lcfg_add_conn(int argc, char **argv)
                 fprintf(stderr, "%s: please use 'cfg_device name' to set the "
                         "device name for config commands.\n", 
                         jt_cmdname(argv[0])); 
-               return -EINVAL;
+                return -EINVAL;
         }
 
         lustre_cfg_bufs_reset(&bufs, lcfg_devname);
@@ -634,7 +634,7 @@ int jt_lcfg_del_conn(int argc, char **argv)
                 fprintf(stderr, "%s: please use 'cfg_device name' to set the "
                         "device name for config commands.\n", 
                         jt_cmdname(argv[0])); 
-               return -EINVAL;
+                return -EINVAL;
         }
 
         lustre_cfg_bufs_reset(&bufs, lcfg_devname);
index 16f4a33..2685cae 100644 (file)
@@ -470,7 +470,7 @@ out:
 
 void print_ldd(struct lustre_disk_data *ldd)
 {
-        int count = 0;
+        int i = 0;
         printf("\nPermanent disk data:\n");
         printf("Server:     %s\n", ldd->ldd_svname);
         printf("Lustre FS:  %s\n", ldd->ldd_fsname);
@@ -482,12 +482,9 @@ void print_ldd(struct lustre_disk_data *ldd)
                ldd->ldd_flags & LDD_F_NEED_INDEX   ? "needs_index ":"");
         printf("Persistent mount opts: %s\n", ldd->ldd_mount_opts);
         printf("MGS nids: ");
-        while (count < MAX_FAILOVER_NIDS) {
-                if (ldd->ldd_mgsnid[count] == LNET_NID_ANY)
-                        break;
-                printf("%c %s", (count == 0) ? ' ' : ',',
-                       libcfs_nid2str(ldd->ldd_mgsnid[count]));
-                count++;
+        for (i = 0; i < ldd->ldd_mgsnid_count; i++) {
+                printf("%c %s", (i == 0) ? ' ' : ',',
+                       libcfs_nid2str(ldd->ldd_mgsnid[i]));
         }
         printf("\n\n");
 }
@@ -854,8 +851,9 @@ static void make_sv_name(struct mkfs_opts *mop)
 void set_defaults(struct mkfs_opts *mop)
 {
         mop->mo_ldd.ldd_magic = LDD_MAGIC;
+        mop->mo_ldd.ldd_config_ver = 0;
         mop->mo_ldd.ldd_flags = LDD_F_NEED_INDEX;
-        mop->mo_ldd.ldd_mgsnid[0] = LNET_NID_ANY;
+        mop->mo_ldd.ldd_mgsnid_count = 0;
         strcpy(mop->mo_ldd.ldd_fsname, "lustre");
         if (get_os_version() == 24) 
                 mop->mo_ldd.ldd_mount_type = LDD_MT_EXT3;
@@ -966,22 +964,20 @@ int main(int argc , char *const argv[])
                         }
                         break;
                 case 'm': {
-                        int count = 0;
+                        int i = 0;
                         char *s1 = optarg, *s2;
                         if (IS_MGMT(&mop.mo_ldd))
                                 badopt(opt, "non-MGMT MDT,OST");
                         while ((s2 = strsep(&s1, ","))) {
-                                mop.mo_ldd.ldd_mgsnid[count++] =
+                                mop.mo_ldd.ldd_mgsnid[i++] =
                                         libcfs_str2nid(s2);
-                                if (count >= MAX_FAILOVER_NIDS) {
+                                if (i >= MAX_FAILOVER_NIDS) {
                                         fprintf(stderr, "too many MGS nids, "
                                                 "ignoring %s\n", s1);
                                         break;
                                 }
                         }
-                        if (count < MAX_FAILOVER_NIDS) 
-                                mop.mo_ldd.ldd_mgsnid[count] = 
-                                LNET_NID_ANY;
+                        mop.mo_ldd.ldd_mgsnid_count = i;
                         break;
                 }
                 case 'M':
@@ -1049,31 +1045,30 @@ int main(int argc , char *const argv[])
                 mop.mo_ldd.ldd_flags |= LDD_F_SV_TYPE_MGMT;
         }
 
-        if (IS_MGMT(&mop.mo_ldd) && 
-            (mop.mo_ldd.ldd_mgsnid[0] == LNET_NID_ANY)) {
-                int count;
+        if (IS_MGMT(&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();
-                count = jt_ptl_get_nids(&nids);
-                if (count < 0) {
+                i = jt_ptl_get_nids(&nids);
+                if (i < 0) {
                         fprintf(stderr, "Can't find local nids "
                                 "(is the lnet module loaded?)\n");
                 } else {
-                        if (count > 0) {
-                                vprint("Adding %d local nids for MGS\n", count);
+                        if (i > 0) {
+                                if (i > MAX_FAILOVER_NIDS) 
+                                        i = MAX_FAILOVER_NIDS;
+                                vprint("Adding %d local nids for MGS\n", i);
                                 memcpy(mop.mo_ldd.ldd_mgsnid, nids,
                                        sizeof(mop.mo_ldd.ldd_mgsnid));
                                 free(nids);
                         }
-                        if (count < MAX_FAILOVER_NIDS) {
-                                mop.mo_ldd.ldd_mgsnid[count] = LNET_NID_ANY;
-                        }
+                        mop.mo_ldd.ldd_mgsnid_count = i;
                 }
         }
 
-        if (mop.mo_ldd.ldd_mgsnid[0] == LNET_NID_ANY) {
+        if (mop.mo_ldd.ldd_mgsnid_count == 0) {
                 fatal();
                 fprintf(stderr, "Must specify either --mgmt or --mgmtnode\n");
                 usage(stderr);