Whamcloud - gitweb
b=8169
authornathan <nathan>
Tue, 8 Nov 2005 00:44:07 +0000 (00:44 +0000)
committernathan <nathan>
Tue, 8 Nov 2005 00:44:07 +0000 (00:44 +0000)
client accepts multiple mgs nids during mount

lustre/llite/llite_lib.c
lustre/obdclass/obd_mount.c
lustre/utils/mount_lustre.c

index 0bebce8..5753f72 100644 (file)
@@ -481,8 +481,8 @@ int ll_fill_super(struct super_block *sb)
         struct lustre_profile *lprof;
         struct lustre_sb_info *lsi = s2sbi(sb);
         struct ll_sb_info *sbi;
-        char  *osc;
-        char  *mdc;
+        char  *osc = NULL;
+        char  *mdc = NULL;
         char  *profilenm = get_profile_name(sb);
         struct config_llog_instance cfg;
         char   ll_instance[sizeof(sb) * 2 + 1];
index 9ce4dca..385902a 100644 (file)
@@ -346,6 +346,8 @@ static int do_lcfg(char *cfgname, lnet_nid_t nid, int cmd,
         struct lustre_cfg_bufs bufs;
         struct lustre_cfg    * lcfg = NULL;
         int err;
+               
+        CDEBUG(D_ERROR, "lcfg %s %#x %s %s %s %s\n", cfgname, cmd, s1, s2, s3, s4); 
 
         lustre_cfg_bufs_reset(&bufs, cfgname);
         if (s1) 
@@ -453,12 +455,12 @@ static int lustre_start_mgc(struct super_block *sb, struct vfsmount *mnt)
                 GOTO(out_free, err);
 
         /* Start the MGC */
-        if ((err = lustre_start_simple(mgcname, LUSTRE_MGC_NAME, "MGS", 
+        if ((err = lustre_start_simple(mgcname, LUSTRE_MDC_NAME/*LUSTRE_MGC_NAME*/, "MGS", 
                                        libcfs_nid2str(nid))))
                 GOTO(out_dereg, err);
         
         /* Add the redundant MGS's */
-        for (i = i; i < sbi->lsi_lmd->lmd_mgsnid_count; i++) {
+        for (i = 1; i < sbi->lsi_lmd->lmd_mgsnid_count; i++) {
                 nid = sbi->lsi_lmd->lmd_mgsnid[i];
                 err = do_lcfg(mgcname, nid, LCFG_ADD_UUID, libcfs_nid2str(nid),
                               0, 0, 0);
@@ -482,13 +484,6 @@ static int lustre_start_mgc(struct super_block *sb, struct vfsmount *mnt)
         }
         sbi->lsi_mgc = obd;
 
-        /* Get a new index if needed */
-        if (sbi->lsi_ldd->ldd_flags & LDD_F_NEED_INDEX) {
-                // FIXME implement
-                CERROR("Need new server index from MGS!\n");
-                // rewrite last_rcvd, ldd (for new svname)
-        }
-
 out_free:
         OBD_FREE(mgcname, mgcname_size);
 out:
@@ -520,6 +515,13 @@ static int server_start_targets(struct super_block *sb)
         LASSERT(obd);
                                         
         CERROR("starting target %s\n", sbi->lsi_ldd->ldd_svname);
+        
+        /* Get a new index if needed */
+        if (sbi->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)
+        }
 
         /* The MGC starts targets using the svname llog */
         ioc_data.ioc_inllen1 = strlen(sbi->lsi_ldd->ldd_svname) + 1;
@@ -806,9 +808,10 @@ static int server_fill_super(struct super_block *sb)
         /* mount to read server info */
         mnt = lustre_kern_mount(sb);
         if (IS_ERR(mnt)) {
+                err = PTR_ERR(mnt);
                 CERROR("Unable to mount device %s: %d\n", 
                       sbi->lsi_lmd->lmd_dev, err);
-                GOTO(out, err = PTR_ERR(mnt));
+                GOTO(out, err);
         }
         LASSERT(sbi->lsi_ldd);
         CERROR("Found service %s for fs %s on device %s\n",
@@ -831,7 +834,7 @@ static int server_fill_super(struct super_block *sb)
         err = lustre_start_mgc(sb, mnt);
         if (err) 
                 GOTO(out_dereg, err);
-        
+
         /* Set up all obd devices for service */
         err = server_start_targets(sb);
         if (err < 0) {
@@ -964,7 +967,7 @@ static int parse_lmd(char *options, struct lustre_mount_data *lmd)
                         LCONSOLE_ERROR("Too many NIDs: '%s'\n", s1);
                         goto invalid;
                 }
-                lmd->lmd_mgsnid[lmd->lmd_mgsnid_count++] = libcfs_str2nid(s1);
+                lmd->lmd_mgsnid[lmd->lmd_mgsnid_count++] = nid;
                 s1 = s2 + 1;
         }
 
index 021315e..af643d4 100644 (file)
@@ -35,8 +35,6 @@
 #include <getopt.h>
 #include <sys/utsname.h>
 
-#include <linux/lustre_disk.h>
-//#include <portals/ptlctl.h>
 #include "obdctl.h"
 
 int          verbose;
@@ -48,10 +46,10 @@ static char *progname = NULL;
 void usage(FILE *out)
 {
         fprintf(out, "%s v1.%d\n", progname, LMD_MAGIC & 0xFF);
-        fprintf(out, "usage: %s <mdsnode>:/<mdsname>/<cfgname> <mountpt> "
+        fprintf(out, "usage: %s <mgmtnid>[:<altmgtnid>...]:/<filesystem>[/<cfgname>] <mountpt> "
                 "[-fhnv] [-o mntopt]\n", progname);
         fprintf(out, "\t<mdsnode>: nid of MDS (config) node\n"
-                "\t<mdsname>: name of MDS service (e.g. mds1)\n"
+                "\t<filesystem>: name of the Lustre filesystem (e.g. lustre1)\n"
                 "\t<cfgname>: name of client config (e.g. client)\n"
                 "\t<mountpt>: filesystem mountpoint (e.g. /mnt/lustre)\n"
                 "\t-f|--fake: fake mount (updates /etc/mtab)\n"
@@ -62,33 +60,6 @@ void usage(FILE *out)
         exit((out != stdout) ? EINVAL : 0);
 }
 
-static int load_module(char *module_name)
-{
-        char buf[256];
-        int rc;
-        
-        if (verbose)
-                printf("loading %s\n", module_name);
-        sprintf(buf, "/sbin/modprobe %s", module_name);
-        rc = system(buf);
-        if (rc) {
-                fprintf(stderr, "%s: failed to modprobe %s: %s\n", 
-                        progname, module_name, strerror(errno));
-                fprintf(stderr, "Check /etc/modules.conf\n");
-        }
-        return rc;
-}
-
-static int load_modules()
-{
-        int rc = 0;
-
-        rc = load_module("lustre");
-        rc = load_module("mds");
-        rc = load_module("ost");
-        return rc;
-}
-
 static int check_mtab_entry(char *spec, char *mtpt, char *type)
 {
         FILE *fp;
@@ -148,6 +119,42 @@ update_mtab_entry(char *spec, char *mtpt, char *type, char *opts,
         return rc;
 }
 
+/* Get rid of symbolic hostnames for tcp */
+#define MAXNIDSTR 256
+static char *convert_hostnames(char *s1)
+{
+        char *converted, *s2, *c;
+        int left = MAXNIDSTR;
+        lnet_nid_t nid;
+        
+        converted = malloc(left);
+        c = converted;
+        while ((left > 0) && ((s2 = strsep(&s1, ",:")))) {
+                nid = libcfs_str2nid(s2);
+                if (nid == LNET_NID_ANY) {
+                        if (*s2 == '/') 
+                                /* end of nids */
+                                break;
+                        fprintf(stderr, "%s: Can't parse NID '%s'\n", 
+                                progname, s2);
+                        free(converted);
+                        return NULL;
+                }
+                if (LNET_NETTYP(LNET_NIDNET(nid)) == SOCKLND) {
+                        __u32 addr = LNET_NIDADDR(nid);
+                        c += snprintf(c, left, "%u.%u.%u.%u@%s%u:",
+                                      (addr >> 24) & 0xff, (addr >> 16) & 0xff,
+                                      (addr >> 8) & 0xff, addr & 0xff,
+                                      libcfs_lnd2str(SOCKLND), 
+                                      LNET_NETNUM(LNET_NIDNET(nid)));
+                } else {
+                        c += snprintf(converted, left, "%s:", s2);
+                }
+                left = converted + MAXNIDSTR - c;
+        }
+        snprintf(c, left, "%s", s2);
+        return converted;
+}
 
 /*****************************************************************************
  *
@@ -248,8 +255,6 @@ int main(int argc, char *const argv[])
         progname = strrchr(argv[0], '/');
         progname = progname ? progname + 1 : argv[0];
 
-        printf("starting %s\n", progname);
-
         while ((opt = getopt_long(argc, argv, "fhno:v",
                                   long_opt, NULL)) != EOF){
                 switch (opt) {
@@ -293,9 +298,13 @@ int main(int argc, char *const argv[])
                 usage(stderr);
         }
 
-        source = argv[optind];
+        source = convert_hostnames(argv[optind]);
         target = argv[optind + 1];
 
+        if (!source) {
+                usage(stderr);
+        }
+
         if (verbose) {
                 for (i = 0; i < argc; i++)
                         printf("arg[%d] = %s\n", i, argv[i]);
@@ -320,14 +329,9 @@ int main(int argc, char *const argv[])
                 return rc;
         }
 
-        /* FIXME remove */
-        if ((rc = load_modules())) {
-                return rc;
-        }
-
         /* In Linux 2.4, the target device doesn't get passed to any of our
            functions.  So we'll stick it on the end of the options. */
-        optlen = strlen(options) + strlen(",device=") + strlen(target);
+        optlen = strlen(options) + strlen(",device=") + strlen(source);
         optcopy = malloc(optlen);
         strcpy(optcopy, options);
         strcat(optcopy, ",device=");
@@ -351,5 +355,6 @@ int main(int argc, char *const argv[])
         }
 
         free(optcopy);
+        free(source);
         return rc;
 }