Whamcloud - gitweb
Branch b1_4_mountconf
authornathan <nathan>
Wed, 28 Sep 2005 00:21:55 +0000 (00:21 +0000)
committernathan <nathan>
Wed, 28 Sep 2005 00:21:55 +0000 (00:21 +0000)
b=8010
dynamically allocate lmd options, change lmd parsing to work for 2.4
fix leaky mgc_setup

lustre/include/linux/lustre_disk.h
lustre/mgc/mgc_request.c
lustre/obdclass/obd_mount.c
lustre/utils/module_setup.sh
lustre/utils/mount_lustre.c

index ae4ce14..3cc46cf 100644 (file)
@@ -93,12 +93,12 @@ struct lustre_disk_data {
 /* Passed by mount - no persistent info here */
 struct lustre_mount_data {
         __u32      lmd_magic;
-        __u32      lmd_flags;          /* lustre mount flags */
-        __u16      lmd_mgsnid_count;   /* how many failover nids we have for the MGS */
+        __u32      lmd_flags;         /* lustre mount flags */
+        __u16      lmd_mgsnid_count;  /* how many failover nids we have for the MGS */
         lnet_nid_t lmd_mgsnid[MAX_FAILOVER_LIST];  /* who to contact at startup */
         //struct lustre_disk_data *lmd_ldd; /* in-mem copy of ldd */
-        char       lmd_dev[128];       /* device or file system name */
-        char       lmd_opts[256];      /* lustre mount options (as opposed to 
+        char      *lmd_dev;           /* device or file system name */
+        char      *lmd_opts;          /* lustre mount options (as opposed to 
                                          _device_ mount options) */
 };
 
index 6e6e07e..3cd773b 100644 (file)
@@ -127,15 +127,10 @@ static int mgc_cleanup(struct obd_device *obd)
         struct mgc_obd *mgc = &obd->u.mgc;
         int rc;
 
-        rc = llog_cleanup(llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT));
-
-        // FIXME REPL rc = obd_llog_finish(obd, 0);
-        if (rc != 0)
-                CERROR("failed to cleanup llogging subsystems\n");
 
         //lprocfs_obd_cleanup(obd);
         
-        //rc = mgc_obd_cleanup(obd);
+        rc = mgc_obd_cleanup(obd);
 
         if (mgc->mgc_vfsmnt) {
                 /* if we're a server, eg. something's mounted */
@@ -144,9 +139,14 @@ static int mgc_cleanup(struct obd_device *obd)
                      CERROR("mount_put failed %d\n", rc);
         }
 
+        rc = obd_llog_finish(obd, 0);
+        if (rc != 0)
+                CERROR("failed to cleanup llogging subsystems\n");
+
         ptlrpcd_decref();
         
         OBD_FREE(mgc->mgc_rpc_lock, sizeof (*mgc->mgc_rpc_lock));
+        
 
         return(rc);
 }
@@ -181,13 +181,14 @@ static int mgc_setup(struct obd_device *obd, obd_count len, void *buf)
                         CERROR("fs setup failed %d\n", rc);
                         mgc_cleanup(obd);
                         RETURN(-ENOENT);
-                        GOTO(err_rpc_lock, rc);
                 }                                                                                                     
         } else {
                 CERROR("mgc does not have local disk (client only)\n");
                 rc = mgc_obd_setup(obd, len, buf);
-                if (rc)
-                        GOTO(err_rpc_lock, rc);
+                if (rc) {
+                        mgc_cleanup(obd);
+                        RETURN(-ENOENT);
+                }
         }
 
         RETURN(rc);
@@ -340,10 +341,12 @@ static int mgc_llog_finish(struct obd_device *obd, int count)
         ENTRY;
 
         rc = llog_cleanup(llog_get_context(obd, LLOG_CONFIG_REPL_CTXT));
+        rc = llog_cleanup(llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT));
+
         RETURN(rc);
 }
 
-/*mgc_obd_setup for mount-conf*/
+/* create a mgs client */
 int mgc_obd_setup(struct obd_device *obddev, obd_count len, void *buf)
 {
         struct lustre_cfg* lcfg = buf;
index 2e741e1..9b1e5c2 100644 (file)
@@ -652,7 +652,12 @@ struct lustre_sb_info *lustre_init_sbi(struct super_block *sb)
 
         OBD_ALLOC(sbi, sizeof(*sbi));
         if (!sbi)
-                RETURN(NULL);
+                return(NULL);
+        OBD_ALLOC(sbi->lsi_lmd, sizeof(*sbi->lsi_lmd));
+        if (!sbi->lsi_lmd) {
+                OBD_FREE(sbi, sizeof(*sbi));
+                return(NULL);
+        }
 
         s2sbi_nocast(sb) = sbi;
         atomic_set(&sbi->lsi_mounts, 0);
@@ -667,8 +672,15 @@ void lustre_free_sbi(struct super_block *sb)
         if (sbi != NULL) {
                 if (sbi->lsi_ldd != NULL) 
                         OBD_FREE(sbi->lsi_ldd, sizeof(*sbi->lsi_ldd));
-                if (sbi->lsi_lmd != NULL) 
+                if (sbi->lsi_lmd != NULL) {
+                        if (sbi->lsi_lmd->lmd_dev != NULL) 
+                                OBD_FREE(sbi->lsi_lmd->lmd_dev, 
+                                         strlen(sbi->lsi_lmd->lmd_dev) + 1);
+                        if (sbi->lsi_lmd->lmd_opts != NULL) 
+                                OBD_FREE(sbi->lsi_lmd->lmd_opts, 
+                                         strlen(sbi->lsi_lmd->lmd_opts) + 1);
                         OBD_FREE(sbi->lsi_lmd, sizeof(*sbi->lsi_lmd));
+                }
                 LASSERT(sbi->lsi_llsbi == NULL);
                 OBD_FREE(sbi, sizeof(*sbi));
                 s2sbi_nocast(sb) = NULL;
@@ -975,21 +987,37 @@ static void print_lmd(struct lustre_mount_data *lmd)
         int i;
 
         for (i = 0; i < lmd->lmd_mgsnid_count; i++) 
-        CERROR("nid %d:           %s\n", i, libcfs_nid2str(lmd->lmd_mgsnid[i]));
-        CERROR("fsname:          %s\n", lmd->lmd_dev);
-        CERROR("options:         %s\n", lmd->lmd_opts);
-
+                CERROR("nid %d:   %s\n", i, libcfs_nid2str(lmd->lmd_mgsnid[i]));
+        if (lmd_is_client(lmd)) 
+                CERROR("fsname:  %s\n", lmd->lmd_dev);
+        else
+                CERROR("device:  %s\n", lmd->lmd_dev);
+        CERROR("options: %s\n", lmd->lmd_opts);
 }
 
-static int parse_lmd(char *devname, char *options,
-                     struct lustre_mount_data *lmd)
+static int parse_lmd(char *options, struct lustre_mount_data *lmd)
 {
-        char *s1, *s2;
+        char *s1, *s2, *devname;
+        ENTRY;
+
+        /* Linux 2.4 doesn't pass the device, so we stuck it at the end of 
+           the options. */
+        s1 = strstr(options, ",device=");
+        if (s1) {
+                devname = s1 + 8; /* strlen(",device=") */
+                *s1 = 0; /* cut it out of the options */
+        } else {
+                LCONSOLE_ERROR("Can't find device name\n");
+                goto invalid;
+        }
+
         if (strchr(devname, ',')) {
                 LCONSOLE_ERROR("No commas are allowed in the device name\n");
                 goto invalid;
         }
+
         s1 = devname;
+        /* Get MGS nids if client mount */
         while ((s2 = strchr(s1, ':'))) {
                 lnet_nid_t nid;
                 *s2 = 0;
@@ -1007,55 +1035,65 @@ static int parse_lmd(char *devname, char *options,
                 s1 = s2 + 1;
         }
 
-        while (*++s1 == '/')
-                ;
-        
-        if (strlen(s1) > sizeof(lmd->lmd_dev)) {
-                LCONSOLE_ERROR("Filesystem name too long: '%s'\n", s1);
+        if (lmd_is_client(lmd)) {
+                /* Remove leading /s from fsname */
+                while (*++s1 == '/')
+                        ;
+        }
+
+        if (!strlen(s1)) {
+                LCONSOLE_ERROR("No filesytem specified\n");
                 goto invalid;
         }
+
+        /* freed in lustre_free_sbi */
+        OBD_ALLOC(lmd->lmd_dev, strlen(s1) + 1);
+        if (!lmd->lmd_dev) 
+                RETURN(-ENOMEM);
         strcpy(lmd->lmd_dev, s1);
         
-        if (strlen(options) > sizeof(lmd->lmd_opts)) {
-                LCONSOLE_ERROR("Options string too long: '%s'\n", options);
-                goto invalid;
+        if (strlen(options)) {
+                /* freed in lustre_free_sbi */
+                OBD_ALLOC(lmd->lmd_opts, strlen(options) + 1);
+                if (!lmd->lmd_opts) 
+                        RETURN(-ENOMEM);
+                strcpy(lmd->lmd_opts, options);
         }
-        strcpy(lmd->lmd_opts, options);
 
         lmd->lmd_magic = LMD_MAGIC;
 
         print_lmd(lmd);
-        return 0;
+        RETURN(0);
 
 invalid:
-        return -EINVAL;          
+        RETURN(-EINVAL);          
 }
 
 
 /* Common mount */
 int lustre_fill_super(struct super_block *sb, void *data, int silent)
 {
-        struct lustre_mount_data * lmd = data;
+        struct lustre_mount_data *lmd;
         struct lustre_sb_info *sbi;
         int err;
         ENTRY;
  
         CDEBUG(D_VFSTRACE, "VFS Op: sb %p\n", sb);
-        if (lmd_bad_magic(lmd))
-                RETURN(-EINVAL);
+        
         sbi = lustre_init_sbi(sb);
-        if (!sbi)
+        if (!sbi) 
                 RETURN(-ENOMEM);
+        lmd = sbi->lsi_lmd;
 
-        /* save mount data */
-        OBD_ALLOC(sbi->lsi_lmd, sizeof(*sbi->lsi_lmd));
-        if (sbi->lsi_lmd == NULL) {
+        /* Figure out the lmd from the mount options */
+        if (parse_lmd((char *)data, lmd)) {
                 lustre_free_sbi(sb);
-                RETURN(-ENOMEM);
+                RETURN(-EINVAL);
+        }
+        if (lmd_bad_magic(lmd)) {
+                lustre_free_sbi(sb);
+                RETURN(-EINVAL);
         }
-        memcpy(sbi->lsi_lmd, lmd, sizeof(*lmd));
-        
         if (lmd_is_client(lmd)) {
                 if (!client_fill_super) {
                         CERROR("Nothing registered for client_fill_super!\n"
@@ -1078,6 +1116,7 @@ int lustre_fill_super(struct super_block *sb, void *data, int silent)
         } else {
                 CERROR("Mounting server\n");
                 err = server_fill_super(sb);
+                /* calls lustre_start_mgc */
         }
                                                                                 
         if (err){
@@ -1103,20 +1142,8 @@ void lustre_register_client_fill_super(int (*cfs)(struct super_block *sb))
 struct super_block * lustre_get_sb(struct file_system_type *fs_type,
                                int flags, const char *devname, void * data)
 {
-        struct lustre_mount_data lmd;
-
-        if (((struct lustre_mount_data *)data)->lmd_magic == LMD_MAGIC ) {
-                /* mount.lustre is sending lmd */
-                CERROR("Using mount.lustre's lmd\n");
-                return get_sb_nodev(fs_type, flags, data, lustre_fill_super);
-        }
-
-        /* Figure out the lmd from the mount line */
-        if (parse_lmd((char *)devname, (char *)data, &lmd))
-                return ERR_PTR(-EINVAL);
-        
         /* calls back in fill super */
-        return get_sb_nodev(fs_type, flags, (void *)&lmd, lustre_fill_super);
+        return get_sb_nodev(fs_type, flags, data, lustre_fill_super);
 }
 
 struct file_system_type lustre_fs_type = {
@@ -1132,9 +1159,9 @@ struct file_system_type lustre_fs_type = {
 static struct super_block *lustre_read_super(struct super_block *sb,
                                              void *data, int silent)
 {
-        //FIXME need the device for the lmd!!
         int err;
         ENTRY;
+
         err = lustre_fill_super(sb, data, silent);
         if (err)
                 RETURN(NULL);
index 483a662..6e7f5f2 100755 (executable)
@@ -17,9 +17,9 @@ echo "Copying modules from local build dir to "$MDIR
 
 mkdir -p $MDIR
 
-cp ../../portals/libcfs/libcfs.$EXT $MDIR
-cp ../../portals/portals/portals.$EXT $MDIR
-cp ../../portals/knals/socknal/ksocknal.$EXT $MDIR
+cp ../../lnet/libcfs/libcfs.$EXT $MDIR
+cp ../../lnet/lnet/lnet.$EXT $MDIR
+cp ../../lnet/klnds/socklnd/ksocklnd.$EXT $MDIR
 cp ../lvfs/lvfs.$EXT $MDIR
 cp ../obdclass/obdclass.$EXT $MDIR
 cp ../ptlrpc/ptlrpc.$EXT $MDIR
@@ -47,25 +47,17 @@ MP="/sbin/modprobe"
 MPI="$MP --ignore-install"
 
 [ -e $MODFILE ] || touch $MODFILE
-if [ `grep -c lustre $MODFILE` -eq 0 ]; then
+if [ `egrep -c "lustre|lnet" $MODFILE` -eq 0 ]; then
     echo Modifying $MODFILE
     echo "# Lustre modules added by $0" >> $MODFILE
+    echo "# Networking options, see /sys/module/lnet/parameters" >> $MODFILE
+    echo "options lnet networks=tcp" >> $MODFILE
+    echo "# for zeroconf clients" >> $MODFILE
     if [ $KVER -eq 24 ]; then
-       echo alias _lustre ksocknal >> $MODFILE
-       echo add above _lustre mgc $FSFLT portals >> $MODFILE
-       echo add below mds _lustre osc lov >> $MODFILE
-       echo add below ost _lustre >> $MODFILE
-       echo add below llite _lustre osc mdc lov >> $MODFILE
-       echo alias lustre llite >> $MODFILE
+        echo "add below llite lov osc" >> $MODFILE
     else
-       echo "install kptlrouter $MP portals && $MPI kptlrouter" >> $MODFILE
-       echo "install _lustre $MP portals && $MP lvfs && $MP obdclass && $MP ptlrpc && $MP mgc" >> $MODFILE
-       echo "install obdfilter $MP _lustre && $MP ost && $MP ldiskfs && $MP $FSFLT && $MPI obdfilter" >> $MODFILE
-       echo "install ost $MP _lustre && $MPI ost" >> $MODFILE
-       echo "install mds $MP _lustre && $MP osc && $MP lov && $MPI mds" >> $MODFILE
-       echo "install llite $MP _lustre && $MP osc && $MP mdc && $MP lov && $MPI llite" >> $MODFILE
-       echo "alias lustre llite" >> $MODFILE
+        echo "install llite $MP lov; $MP osc; $MPI llite" >> $MODFILE
     fi
+    echo "alias lustre llite" >> $MODFILE
     echo "# end Lustre modules" >> $MODFILE
 fi
-
index 66bf85a..5e8c3df 100644 (file)
@@ -231,9 +231,8 @@ int parse_options(char *orig_options, int *flagp)
 
 int main(int argc, char *const argv[])
 {
-        char *source, *target, *options = "";
-        int i, nargs = 3, opt, rc, flags;
-        struct lustre_mount_data lmd;
+        char *source, *target, *options = "", *optcopy;
+        int i, nargs = 3, opt, rc, flags, optlen;
         static struct option long_opt[] = {
                 {"fake", 0, 0, 'f'},
                 {"force", 0, 0, 1},
@@ -324,11 +323,19 @@ int main(int argc, char *const argv[])
                 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);
+        optcopy = malloc(optlen);
+        strcpy(optcopy, options);
+        strcat(optcopy, ",device=");
+        strcat(optcopy, source);
+
         if (!fake)
                 /* flags and target get to lustre_get_sb, but not 
                    lustre_fill_super.  Lustre ignores the flags, but mount 
                    does not. */
-                rc = mount(source, target, "lustre", flags, (void *)options);
+                rc = mount(source, target, "lustre", flags, (void *)optcopy);
         if (rc) {
                 fprintf(stderr, "%s: mount(%s, %s) failed: %s\n", progname, 
                         source, target, strerror(errno));
@@ -340,5 +347,6 @@ int main(int argc, char *const argv[])
                 rc = update_mtab_entry(source, target, "lustre", options,0,0,0);
         }
 
+        free(optcopy);
         return rc;
 }