Whamcloud - gitweb
Branch b1_4_newconfig2
authornathan <nathan>
Tue, 9 Aug 2005 23:55:32 +0000 (23:55 +0000)
committernathan <nathan>
Tue, 9 Aug 2005 23:55:32 +0000 (23:55 +0000)
b=6663
move fs registration out of llite

lustre/include/linux/lustre_disk.h
lustre/llite/super.c
lustre/llite/super25.c
lustre/mds/handler.c
lustre/mgc/mgc_request.c
lustre/obdclass/class_obd.c
lustre/obdclass/obd_mount.c
lustre/utils/mkfs_lustre.c
lustre/utils/module_setup.sh
lustre/utils/mount_lustre.c

index 574ecb8..4cae445 100644 (file)
@@ -216,7 +216,6 @@ struct lustre_mount_info {
 #ifdef __KERNEL__
 
 /* obd_mount.c */
-int lustre_fill_super(struct super_block *sb, void *data, int silent);
 void lustre_register_client_fill_super(int (*cfs)(struct super_block *sb));
 void lustre_common_put_super(struct super_block *sb);
 int class_manual_cleanup(struct obd_device *obd, char *flags);
index 44b04d7..6694b76 100644 (file)
 extern struct address_space_operations ll_aops;
 extern struct address_space_operations ll_dir_aops;
 
-static struct super_block *lustre_read_super(struct super_block *sb,
-                                             void *data, int silent)
-{
-        int err;
-        ENTRY;
-        err = lustre_fill_super(sb, data, silent);
-        if (err)
-                RETURN(NULL);
-        RETURN(sb);
-}
 
 /* exported operations */
 struct super_operations lustre_super_operations =
@@ -65,13 +55,6 @@ struct super_operations lustre_super_operations =
         .remount_fs     = ll_remount_fs,
 };
 
-static struct file_system_type lustre_fs_type = {
-        .owner          = THIS_MODULE,
-        .name           = "lustre",
-        .fs_flags       = FS_NFSEXP_FSID,
-        .read_super     = lustre_read_super,
-};
-
 static int __init init_lustre_lite(void)
 {
         int rc;
@@ -87,24 +70,17 @@ static int __init init_lustre_lite(void)
         if (proc_lustre_root)
                 proc_lustre_fs_root = proc_mkdir("llite", proc_lustre_root);
 
-        // FIXME register_filesystem should be in obd_mount init, not here.
-        // here we just have: 
-        lustre_register_client_fill_super(ll_fill_super);
-
         ll_register_cache(&ll_cache_definition);
 
-        rc = register_filesystem(&lustre_fs_type);
-        if (rc) {
-                ll_unregister_cache(&ll_cache_definition);
-        }
+        lustre_register_client_fill_super(ll_fill_super);
 
         return rc;
 }
 
 static void __exit exit_lustre_lite(void)
 {
-        unregister_filesystem(&lustre_fs_type);
-
+        lustre_register_client_fill_super(NULL);
+        
         ll_unregister_cache(&ll_cache_definition);
 
         LASSERTF(kmem_cache_destroy(ll_file_data_slab) == 0,
index 4a15218..41c9867 100644 (file)
 #include <linux/lprocfs_status.h>
 #include "llite_internal.h"
 
-struct super_block * lustre_get_sb(struct file_system_type *fs_type,
-                               int flags, const char *devname, void * data)
-{
-        /* calls back in fill super */
-        return get_sb_nodev(fs_type, flags, data, lustre_fill_super);
-}
-
 static kmem_cache_t *ll_inode_cachep;
 
 static struct inode *ll_alloc_inode(struct super_block *sb)
@@ -102,13 +95,6 @@ struct super_operations lustre_super_operations =
         .remount_fs    = ll_remount_fs,
 };
 
-struct file_system_type lustre_fs_type = {
-        .owner        = THIS_MODULE,
-        .name         = "lustre",
-        .get_sb       = lustre_get_sb,
-        .kill_sb      = kill_anon_super,
-        .fs_flags     = FS_BINARY_MOUNTDATA,
-};
 
 static int __init init_lustre_lite(void)
 {
@@ -129,21 +115,16 @@ static int __init init_lustre_lite(void)
         proc_lustre_fs_root = proc_lustre_root ?
                               proc_mkdir("llite", proc_lustre_root) : NULL;
 
-        lustre_register_client_fill_super(ll_fill_super);
-
         ll_register_cache(&ll_cache_definition);
-
-        rc = register_filesystem(&lustre_fs_type);
-        if (rc) {
-                ll_unregister_cache(&ll_cache_definition);
-        }
-
+        
+        lustre_register_client_fill_super(ll_fill_super);
+        
         return rc;
 }
 
 static void __exit exit_lustre_lite(void)
 {
-        unregister_filesystem(&lustre_fs_type);
+        lustre_register_client_fill_super(NULL);
 
         ll_unregister_cache(&ll_cache_definition);
 
index 91ac52a..1e24963 100644 (file)
@@ -1475,7 +1475,8 @@ static int mds_setup(struct obd_device *obd, obd_count len, void *buf)
                 /* We already mounted in lustre_fill_super */
                 mnt = lmi->lmi_mnt;
         } else {
-                /* old path */
+                /* old path - used for llog writing from mkfs.lustre */
+                CERROR("Using old MDS mount method\n");
                 page = __get_free_page(GFP_KERNEL);
                 if (!page)
                         RETURN(-ENOMEM);
index 9eadaa6..9aee0f1 100644 (file)
@@ -46,6 +46,7 @@
 #include <linux/lustre_log.h>
 #include <linux/lustre_fsfilt.h>
 #include <linux/lustre_disk.h>
+#include <linux/lustre_net.h>
 //#include <linux/lprocfs_status.h>
 #include "mgc_internal.h"
 
index 9d692d7..f021a10 100644 (file)
@@ -661,6 +661,7 @@ int init_obdclass(void)
         struct obd_device *obd;
 #ifdef __KERNEL__
         struct proc_dir_entry *entry;
+        int lustre_register_fs(void);
 #endif
         int err;
         int i;
@@ -712,6 +713,8 @@ int init_obdclass(void)
                 RETURN(-ENOMEM);
         }
         entry->proc_fops = &obd_device_list_fops;
+
+        lustre_register_fs();
 #endif
         return 0;
 }
@@ -724,8 +727,11 @@ static void cleanup_obdclass(void)
 {
         int i;
         int leaked;
+        int lustre_unregister_fs(void);
         ENTRY;
 
+        lustre_unregister_fs();
+
         misc_deregister(&obd_psdev);
         for (i = 0; i < MAX_OBD_DEVICES; i++) {
                 struct obd_device *obd = &obd_dev[i];
index 96dd8da..e09b20d 100644 (file)
 #include <linux/lustre_fsfilt.h>
 #include <linux/obd_class.h>
 #include <lustre/lustre_user.h>
-
+#include <linux/version.h> 
+                      
 static int (*client_fill_super)(struct super_block *sb) = NULL;
 
-/******* mount lookup *****/
+/*********** mount lookup *********/
 DECLARE_MUTEX(lustre_mount_info_lock);
 struct list_head lustre_mount_info_list = LIST_HEAD_INIT(lustre_mount_info_list);
 
@@ -158,7 +159,7 @@ struct lustre_mount_info *lustre_put_mount(char *name)
 }
 
 
-/******* utilities *********/
+/******* mount helper utilities *********/
 
 static int dentry_readdir(struct obd_device *obd, struct dentry *dir, 
                           struct vfsmount *inmnt, struct list_head *dentry_list)
@@ -218,11 +219,14 @@ int parse_mount_data(struct lvfs_run_ctxt *mount_ctxt,
         CERROR("Have %s, size %lu\n", MOUNT_DATA_FILE, len);
 
         err = lustre_fread(file, ldd, len, &off);
-        if (err) {
-                CERROR("OBD filter: error reading %s: err %d\n", 
-                       MOUNT_DATA_FILE, err);
+        if (err != len) {
+                CERROR("OBD filter: error reading %s: read %d of %lu\n", 
+                       MOUNT_DATA_FILE, err, len);
+                err = -EINVAL;
                 goto out_close;
         }
+        err = 0;
+
         if (ldd->ldd_magic != LDD_MAGIC) {
                 CERROR("Bad magic in %s: %x!=%x\n", MOUNT_DATA_FILE, 
                        ldd->ldd_magic, LDD_MAGIC);
@@ -281,238 +285,6 @@ out:
         return(err);
 }
 
-static int do_lcfg(char *cfgname, ptl_nid_t nid, int cmd,
-                   char *s1, char *s2, char *s3, char *s4)
-{
-        struct lustre_cfg_bufs bufs;
-        struct lustre_cfg    * lcfg = NULL;
-        int err;
-
-        lustre_cfg_bufs_reset(&bufs, cfgname);
-        if (s1) 
-                lustre_cfg_bufs_set_string(&bufs, 1, s1);
-        if (s2) 
-                lustre_cfg_bufs_set_string(&bufs, 2, s2);
-        if (s3) 
-                lustre_cfg_bufs_set_string(&bufs, 3, s3);
-        if (s4) 
-                lustre_cfg_bufs_set_string(&bufs, 4, s4);
-
-        lcfg = lustre_cfg_new(cmd, &bufs);
-        lcfg->lcfg_nid = nid;
-        err = class_process_config(lcfg);
-        lustre_cfg_free(lcfg);
-        return(err);
-}
-
-int class_manual_cleanup(struct obd_device *obd, char *flags)
-{
-        int err, rc = 0;
-        
-        LASSERT(obd);
-        err = do_lcfg(obd->obd_name, 0, LCFG_CLEANUP, flags, 0, 0, 0);
-        if (err) {
-                CERROR("cleanup failed (%d): %s\n", err, obd->obd_name);
-                rc = err;
-        }
-        
-        err = do_lcfg(obd->obd_name, 0, LCFG_DETACH, 0, 0, 0, 0);
-        if (err) {
-                CERROR("detach failed (%d): %s\n", err, obd->obd_name);
-                if (!rc) 
-                        rc = err;
-        }
-
-        return(rc);
-}
-
-struct lustre_sb_info *lustre_init_sbi(struct super_block *sb)
-{
-        struct lustre_sb_info *sbi = NULL;
-
-        OBD_ALLOC(sbi, sizeof(*sbi));
-        if (!sbi)
-                RETURN(NULL);
-
-        s2sbi_nocast(sb) = sbi;
-        atomic_set(&sbi->lsi_mounts, 0);
-        return(sbi);
-}
-
-void lustre_free_sbi(struct super_block *sb)
-{
-        struct lustre_sb_info *sbi = s2sbi(sb);
-        ENTRY;
-
-        if (sbi != NULL) {
-                if (sbi->lsi_ldd != NULL) 
-                        OBD_FREE(sbi->lsi_ldd, sizeof(*sbi->lsi_ldd));
-                if (sbi->lsi_lmd != NULL) 
-                        OBD_FREE(sbi->lsi_lmd, sizeof(*sbi->lsi_lmd));
-                LASSERT(sbi->lsi_llsbi == NULL);
-                OBD_FREE(sbi, sizeof(*sbi));
-                s2sbi_nocast(sb) = NULL;
-        }
-        EXIT;
-}
-           
-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 };
-                CERROR("update new logs.\n");
-                err = obd_iocontrol(OBD_IOC_UPDATE_LOG, obd->obd_self_export,
-                                    sizeof ioc_data, &ioc_data, NULL);
-                if (err)
-                        CERROR("Failed to Update logs. \n");
-        }
-#endif
-      return err;
-}
-
-static void server_put_super(struct super_block *sb)
-{
-        struct list_head dentry_list;
-        struct lustre_sb_info *sbi = s2sbi(sb);
-        struct l_linux_dirent *dirent, *n;
-        struct obd_device *obd;
-        struct mgc_obd *mgcobd;
-        char flags[2] = "";
-        int err;
-                                                                                       
-        obd = sbi->lsi_mgc;
-        CERROR("server put_super %s\n", obd->obd_name);
-        mgcobd = &obd->u.mgc;
-                                                                                       
-        lustre_update_llog(obd);
-                                                                                       
-        //FIXME cleanup does the mntput; we have to make sure MGS is done with
-        //it as well
-
-        if (sbi->lsi_flags & LSI_UMOUNT_FORCE)
-                strcat(flags, "A");
-        if (sbi->lsi_flags & LSI_UMOUNT_FAILOVER)
-                strcat(flags, "F");
-
-        /* Clean up all the -conf obd's in the LOGS directory.
-            FIXME this may not be complete / reasonable.
-            Really, we should have a list of every obd we started,
-            maybe an additional field to obd_device for group_uuid, then
-            just use lustre_manual_cleanup.
-            CRAY_MDS:
-                 client  client-clean  mdsA  mdsA-clean  mdsA-conf
-            CRAY_OST:
-                 OSS-conf  OST_uml2-conf
-            This does clean up oss, ost, mds, but not mdt. mdt is set up
-            as part of mdsA-conf.
-         */
-        
-        /* Find all the logs in the CONFIGS directory */
-        err = dentry_readdir(obd, mgcobd->mgc_configs_dir,
-                       mgcobd->mgc_vfsmnt, &dentry_list);
-        if (err)
-                CERROR("Can't read %s dir, %d\n", MOUNT_CONFIGS_DIR, err);
-                                                                                       
-        list_for_each_entry_safe(dirent, n, &dentry_list, lld_list) {
-                char *logname;
-                int len;
-
-                list_del(&dirent->lld_list);
-                
-                logname = dirent->lld_name;
-                /* Confobd start adds "-conf" */
-                len = strlen(logname) - 5;
-                if ((len < 1) || strcmp(logname, "-conf")) {
-                        CDEBUG(D_CONFIG, "ignoring %s\n", logname);
-                        OBD_FREE(dirent, sizeof(*dirent));
-                        continue;
-                }
-                logname[len] = 0;
-                                                                                       
-                obd = class_name2obd(logname);
-                if (!obd) {
-                        CERROR("no obd %s\n", logname);
-                        continue;
-                }
-                                                                                       
-                CERROR("stopping %s\n", logname);
-                err = class_manual_cleanup(obd, flags);
-                if (err) {
-                        CERROR("failed to cleanup %s: %d\n", logname, err);
-                }
-                OBD_FREE(dirent, sizeof(*dirent));
-        }
-                                                                                       
-        /* FIXME so until we decide the above, completly evil hack 
-        the MDT, soon to be known as the MDS, will be started at insmod and 
-        removed at rmmod, so take out of here. */
-        obd = class_name2obd("MDT");
-        if (obd)
-                class_manual_cleanup(obd, flags);
-
-        class_del_profile(sbi->lsi_ldd->ldd_svname);
-        lustre_common_put_super(sb);
-}
-
-static void server_umount_begin(struct super_block *sb)
-{
-        struct lustre_sb_info *sbi = s2sbi(sb);
-                                                                                       
-        CERROR("Umount -f\n");
-        // FIXME decide FORCE or FAILOVER based on mount option -o umount=failover
-        sbi->lsi_flags |= LSI_UMOUNT_FORCE;
-}
-
-static struct super_operations server_ops =
-{
-        //.statfs         = NULL,
-        .put_super      = server_put_super,
-        .umount_begin   = server_umount_begin, /* umount -f */
-};
-
-#define log2(n) ffz(~(n))
-#define LUSTRE_SUPER_MAGIC 0x0BD00BD1
-
-static int server_fill_super_common(struct super_block *sb)
-{
-        struct inode *root = 0;
-        //struct ll_sb_info *sbi = ll_s2sbi(sb);
-        ENTRY;
-                                                                                 
-        CERROR("Server sb, dev=%d\n", (int)sb->s_dev);
-                                                                                 
-        sb->s_blocksize = 4096;
-        sb->s_blocksize_bits = log2(sb->s_blocksize);
-        sb->s_magic = LUSTRE_SUPER_MAGIC;
-        sb->s_maxbytes = 0; //PAGE_CACHE_MAXBYTES;
-        sb->s_flags |= MS_RDONLY;
-        sb->s_op = &server_ops;
-        root = new_inode(sb);
-        if (!root) {
-                CERROR("Can't make root inode\n");
-                RETURN(-EIO);
-        }
-                                                                                 
-        /* returns -EIO for every operation */
-        /* make_bad_inode(root); -- badness - can't umount */
-        /* apparently we need to be a directory for the mount to finish */
-        root->i_mode = S_IFDIR;
-                                                                                 
-        sb->s_root = d_alloc_root(root);
-        if (!sb->s_root) {
-                CERROR("Can't make root dentry\n");
-                iput(root);
-                RETURN(-EIO);
-        }
-                                                                                 
-        RETURN(0);
-}
-                           
 
 /* Get the log "profile" from a remote MGMT and process it.
   FIXME  If remote doesn't exist, try local
@@ -686,27 +458,174 @@ int lustre_process_logs(struct super_block *sb,
         return(err);
 }
 
-/* Kernel mount using mount options in MOUNT_DATA_FILE */
-static struct vfsmount *lustre_kern_mount(struct super_block *sb)
+static int lustre_update_llog(struct obd_device *obd)
 {
-        struct lvfs_run_ctxt mount_ctxt;
-        struct lustre_sb_info *sbi = s2sbi(sb);
-        struct lustre_disk_data *ldd;
-        struct lustre_mount_data *lmd = sbi->lsi_lmd;
-        struct vfsmount *mnt;
-        char *options = NULL;
-        unsigned long page;
-        int err;
-
-        OBD_ALLOC(ldd, sizeof(*ldd));
-        if (!ldd)
-                return(ERR_PTR(-ENOMEM));
+        int err = 0;
 
-        /* Pre-mount ext3 with no options to read the MOUNT_DATA_FILE */
-        CERROR("Pre-mount ext3 %s\n", lmd->lmd_dev);
-        mnt = do_kern_mount("ext3", 0, lmd->lmd_dev, 0);
-        if (IS_ERR(mnt)) {
-                err = PTR_ERR(mnt);
+        // 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 };
+                CERROR("update new logs.\n");
+                err = obd_iocontrol(OBD_IOC_UPDATE_LOG, obd->obd_self_export,
+                                    sizeof ioc_data, &ioc_data, NULL);
+                if (err)
+                        CERROR("Failed to Update logs. \n");
+        }
+#endif
+      return err;
+}
+
+
+static int do_lcfg(char *cfgname, ptl_nid_t nid, int cmd,
+                   char *s1, char *s2, char *s3, char *s4)
+{
+        struct lustre_cfg_bufs bufs;
+        struct lustre_cfg    * lcfg = NULL;
+        int err;
+
+        lustre_cfg_bufs_reset(&bufs, cfgname);
+        if (s1) 
+                lustre_cfg_bufs_set_string(&bufs, 1, s1);
+        if (s2) 
+                lustre_cfg_bufs_set_string(&bufs, 2, s2);
+        if (s3) 
+                lustre_cfg_bufs_set_string(&bufs, 3, s3);
+        if (s4) 
+                lustre_cfg_bufs_set_string(&bufs, 4, s4);
+
+        lcfg = lustre_cfg_new(cmd, &bufs);
+        lcfg->lcfg_nid = nid;
+        err = class_process_config(lcfg);
+        lustre_cfg_free(lcfg);
+        return(err);
+}
+
+/* Set up a mgcobd to process startup logs */
+static int lustre_start_mgc(char *mcname, struct super_block *sb)
+{
+        struct config_llog_instance cfg;
+        struct lustre_sb_info *sbi = s2sbi(sb);
+        struct obd_device *obd;
+        int err = 0;
+
+        cfg.cfg_instance = mcname;
+        snprintf(cfg.cfg_uuid.uuid, sizeof(cfg.cfg_uuid.uuid), mcname);
+        err = do_lcfg(mcname, 0, LCFG_ATTACH, LUSTRE_MGC_NAME, cfg.cfg_uuid.uuid, 0, 0);
+        if (err)
+                goto out_free;
+                                                                                       
+        err = do_lcfg(mcname, 0, LCFG_SETUP, 0, 0, 0, 0);
+        if (err) {
+                CERROR("mgcobd setup error %d\n", err);
+                do_lcfg(mcname, 0, LCFG_DETACH, 0, 0, 0, 0);
+                goto out_free;
+        }
+        
+        obd = class_name2obd(mcname);
+        if (!obd) {
+                CERROR("Can't find mgcobd %s\n", mcname);
+                err = -ENOTCONN;
+                goto out_free;
+        }
+        sbi->lsi_mgc = obd;
+        
+out_free:
+        return err;
+}
+
+static void lustre_stop_mgc(struct super_block *sb)
+{
+        struct lustre_sb_info *sbi = s2sbi(sb);
+        struct obd_device *obd;
+
+        obd = sbi->lsi_mgc;
+        if (obd) 
+                class_manual_cleanup(obd, NULL);
+}
+          
+//FIXME move to obd_config.c
+int class_manual_cleanup(struct obd_device *obd, char *flags)
+{
+        int err, rc = 0;
+        
+        if (!obd)
+                return 0;
+
+        err = do_lcfg(obd->obd_name, 0, LCFG_CLEANUP, flags, 0, 0, 0);
+        if (err) {
+                CERROR("cleanup failed (%d): %s\n", err, obd->obd_name);
+                rc = err;
+        }
+        
+        err = do_lcfg(obd->obd_name, 0, LCFG_DETACH, 0, 0, 0, 0);
+        if (err) {
+                CERROR("detach failed (%d): %s\n", err, obd->obd_name);
+                if (!rc) 
+                        rc = err;
+        }
+
+        return(rc);
+}
+
+
+/***************** mount **************/
+
+struct lustre_sb_info *lustre_init_sbi(struct super_block *sb)
+{
+        struct lustre_sb_info *sbi = NULL;
+
+        OBD_ALLOC(sbi, sizeof(*sbi));
+        if (!sbi)
+                RETURN(NULL);
+
+        s2sbi_nocast(sb) = sbi;
+        atomic_set(&sbi->lsi_mounts, 0);
+        return(sbi);
+}
+
+void lustre_free_sbi(struct super_block *sb)
+{
+        struct lustre_sb_info *sbi = s2sbi(sb);
+        ENTRY;
+
+        if (sbi != NULL) {
+                if (sbi->lsi_ldd != NULL) 
+                        OBD_FREE(sbi->lsi_ldd, sizeof(*sbi->lsi_ldd));
+                if (sbi->lsi_lmd != NULL) 
+                        OBD_FREE(sbi->lsi_lmd, sizeof(*sbi->lsi_lmd));
+                LASSERT(sbi->lsi_llsbi == NULL);
+                OBD_FREE(sbi, sizeof(*sbi));
+                s2sbi_nocast(sb) = NULL;
+        }
+        EXIT;
+}
+           
+
+/*************** server mount ******************/
+
+/* Kernel mount using mount options in MOUNT_DATA_FILE */
+static struct vfsmount *lustre_kern_mount(struct super_block *sb)
+{
+        struct lvfs_run_ctxt mount_ctxt;
+        struct lustre_sb_info *sbi = s2sbi(sb);
+        struct lustre_disk_data *ldd;
+        struct lustre_mount_data *lmd = sbi->lsi_lmd;
+        struct vfsmount *mnt;
+        char *options = NULL;
+        unsigned long page;
+        int err;
+
+        OBD_ALLOC(ldd, sizeof(*ldd));
+        if (!ldd)
+                return(ERR_PTR(-ENOMEM));
+
+        /* Pre-mount ext3 with no options to read the MOUNT_DATA_FILE */
+        CERROR("Pre-mount ext3 %s\n", lmd->lmd_dev);
+        mnt = do_kern_mount("ext3", 0, lmd->lmd_dev, 0);
+        if (IS_ERR(mnt)) {
+                err = PTR_ERR(mnt);
                 CERROR("premount failed: err = %d\n", err);
                 goto out_free;
         }
@@ -763,51 +682,146 @@ out_free:
         sbi->lsi_ldd = NULL;    
         return(ERR_PTR(err));
 }
-
-/* Set up a mgcobd to process startup logs */
-static int lustre_start_mgc(char *mcname, struct super_block *sb)
+                      
+static void server_put_super(struct super_block *sb)
 {
-        struct config_llog_instance cfg;
+        struct list_head dentry_list;
         struct lustre_sb_info *sbi = s2sbi(sb);
+        struct l_linux_dirent *dirent, *n;
         struct obd_device *obd;
-        int err = 0;
+        struct mgc_obd *mgcobd;
+        char flags[2] = "";
+        int err;
+                                                                                       
+        obd = sbi->lsi_mgc;
+        CERROR("server put_super %s\n", obd->obd_name);
+        mgcobd = &obd->u.mgc;
+                                                                                       
+        lustre_update_llog(obd);
+                                                                                       
+        //FIXME cleanup does the mntput; we have to make sure MGS is done with
+        //it as well
 
-        cfg.cfg_instance = mcname;
-        snprintf(cfg.cfg_uuid.uuid, sizeof(cfg.cfg_uuid.uuid), mcname);
-        err = do_lcfg(mcname, 0, LCFG_ATTACH, LUSTRE_MGC_NAME, cfg.cfg_uuid.uuid, 0, 0);
+        if (sbi->lsi_flags & LSI_UMOUNT_FORCE)
+                strcat(flags, "A");
+        if (sbi->lsi_flags & LSI_UMOUNT_FAILOVER)
+                strcat(flags, "F");
+
+        /* Clean up all the -conf obd's in the LOGS directory.
+            FIXME this may not be complete / reasonable.
+            Really, we should have a list of every obd we started,
+            maybe an additional field to obd_device for group_uuid, then
+            just use lustre_manual_cleanup.
+            CRAY_MDS:
+                 client  client-clean  mdsA  mdsA-clean  mdsA-conf
+            CRAY_OST:
+                 OSS-conf  OST_uml2-conf
+            This does clean up oss, ost, mds, but not mdt. mdt is set up
+            as part of mdsA-conf.
+         */
+        
+        /* Find all the logs in the CONFIGS directory */
+        err = dentry_readdir(obd, mgcobd->mgc_configs_dir,
+                       mgcobd->mgc_vfsmnt, &dentry_list);
         if (err)
-                goto out_free;
+                CERROR("Can't read %s dir, %d\n", MOUNT_CONFIGS_DIR, err);
                                                                                        
-        err = do_lcfg(mcname, 0, LCFG_SETUP, 0, 0, 0, 0);
-        if (err) {
-                CERROR("mgcobd setup error %d\n", err);
-                do_lcfg(mcname, 0, LCFG_DETACH, 0, 0, 0, 0);
-                goto out_free;
-        }
-        
-        obd = class_name2obd(mcname);
-        if (!obd) {
-                CERROR("Can't find mgcobd %s\n", mcname);
-                err = -ENOTCONN;
-                goto out_free;
+        list_for_each_entry_safe(dirent, n, &dentry_list, lld_list) {
+                char *logname;
+                int len;
+
+                list_del(&dirent->lld_list);
+                
+                logname = dirent->lld_name;
+                /* Confobd start adds "-conf" */
+                len = strlen(logname) - 5;
+                if ((len < 1) || strcmp(logname, "-conf")) {
+                        CDEBUG(D_CONFIG, "ignoring %s\n", logname);
+                        OBD_FREE(dirent, sizeof(*dirent));
+                        continue;
+                }
+                logname[len] = 0;
+                                                                                       
+                obd = class_name2obd(logname);
+                if (!obd) {
+                        CERROR("no obd %s\n", logname);
+                        continue;
+                }
+                                                                                       
+                CERROR("stopping %s\n", logname);
+                err = class_manual_cleanup(obd, flags);
+                if (err) {
+                        CERROR("failed to cleanup %s: %d\n", logname, err);
+                }
+                OBD_FREE(dirent, sizeof(*dirent));
         }
-        sbi->lsi_mgc = obd;
-        
-out_free:
-        return err;
+                                                                                       
+        /* FIXME so until we decide the above, completly evil hack 
+        the MDT, soon to be known as the MDS, will be started at insmod and 
+        removed at rmmod, so take out of here. */
+        obd = class_name2obd("MDT");
+        if (obd)
+                class_manual_cleanup(obd, flags);
+
+        class_del_profile(sbi->lsi_ldd->ldd_svname);
+        lustre_common_put_super(sb);
 }
 
-static void lustre_stop_mgc(struct super_block *sb)
+static void server_umount_begin(struct super_block *sb)
 {
         struct lustre_sb_info *sbi = s2sbi(sb);
-        struct obd_device *obd;
+                                                                                       
+        CERROR("Umount -f\n");
+        // FIXME decide FORCE or FAILOVER based on mount option -o umount=failover
+        sbi->lsi_flags |= LSI_UMOUNT_FORCE;
+}
 
-        obd = sbi->lsi_mgc;
+#define log2(n) ffz(~(n))
+#define LUSTRE_SUPER_MAGIC 0x0BD00BD1
+
+static struct super_operations server_ops =
+{
+        //.statfs         = NULL,
+        .put_super      = server_put_super,
+        .umount_begin   = server_umount_begin, /* umount -f */
+};
 
-        class_manual_cleanup(obd, NULL);
+static int server_fill_super_common(struct super_block *sb)
+{
+        struct inode *root = 0;
+        //struct ll_sb_info *sbi = ll_s2sbi(sb);
+        ENTRY;
+                                                                                 
+        CERROR("Server sb, dev=%d\n", (int)sb->s_dev);
+                                                                                 
+        sb->s_blocksize = 4096;
+        sb->s_blocksize_bits = log2(sb->s_blocksize);
+        sb->s_magic = LUSTRE_SUPER_MAGIC;
+        sb->s_maxbytes = 0; //PAGE_CACHE_MAXBYTES;
+        sb->s_flags |= MS_RDONLY;
+        sb->s_op = &server_ops;
+        root = new_inode(sb);
+        if (!root) {
+                CERROR("Can't make root inode\n");
+                RETURN(-EIO);
+        }
+                                                                                 
+        /* returns -EIO for every operation */
+        /* make_bad_inode(root); -- badness - can't umount */
+        /* apparently we need to be a directory for the mount to finish */
+        root->i_mode = S_IFDIR;
+                                                                                 
+        sb->s_root = d_alloc_root(root);
+        if (!sb->s_root) {
+                CERROR("Can't make root dentry\n");
+                iput(root);
+                RETURN(-EIO);
+        }
+                                                                                 
+        RETURN(0);
 }
-                                                
+     
 static int server_fill_super(struct super_block *sb)
 {
         struct config_llog_instance cfg;
@@ -822,7 +836,7 @@ static int server_fill_super(struct super_block *sb)
            the address of the super itself.*/
         OBD_ALLOC(mgcname, mgcname_sz);
         if (!mgcname)
-                GOTO(out_free, err = -ENOMEM);
+                GOTO(out, err = -ENOMEM);
         sprintf(mgcname, "MGC_%p", sb);
 
         /* mount to read server info */
@@ -886,6 +900,9 @@ out:
         RETURN(err);
 }
 
+
+/*************** mount common betweeen server and client ***************/
+
 /* Common umount */
 void lustre_common_put_super(struct super_block *sb)
 {
@@ -930,7 +947,11 @@ int lustre_fill_super(struct super_block *sb, void *data, int silent)
                         snprintf(mgcname, sizeof(mgcname), "mgc-client-%s", 
                                  lmd->lmd_dev);
                         CERROR("Mounting client\n");
-                        lustre_start_mgc(mgcname, sb);
+                        err = lustre_start_mgc(mgcname, sb);
+                        if (err) {
+                                lustre_free_sbi(sb);
+                                RETURN(err);
+                        }
                         /* Connect and start */
                         /* (should always be ll_fill_super) */
                         err = (*client_fill_super)(sb);
@@ -956,7 +977,56 @@ void lustre_register_client_fill_super(int (*cfs)(struct super_block *sb))
         client_fill_super = cfs;
 }
 
-EXPORT_SYMBOL(lustre_fill_super);
+/***************** FS registration ******************/
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
+/* 2.5 and later */
+struct super_block * lustre_get_sb(struct file_system_type *fs_type,
+                               int flags, const char *devname, void * data)
+{
+        /* calls back in fill super */
+        return get_sb_nodev(fs_type, flags, data, lustre_fill_super);
+}
+
+struct file_system_type lustre_fs_type = {
+        .owner        = THIS_MODULE,
+        .name         = "lustre",
+        .get_sb       = lustre_get_sb,
+        .kill_sb      = kill_anon_super,
+        .fs_flags     = FS_BINARY_MOUNTDATA,
+};
+
+#else
+/* 2.4 */
+static struct super_block *lustre_read_super(struct super_block *sb,
+                                             void *data, int silent)
+{
+        int err;
+        ENTRY;
+        err = lustre_fill_super(sb, data, silent);
+        if (err)
+                RETURN(NULL);
+        RETURN(sb);
+}
+
+static struct file_system_type lustre_fs_type = {
+        .owner          = THIS_MODULE,
+        .name           = "lustre",
+        .fs_flags       = FS_NFSEXP_FSID,
+        .read_super     = lustre_read_super,
+};
+#endif
+
+int lustre_register_fs(void)
+{
+        return register_filesystem(&lustre_fs_type);
+}
+
+int lustre_unregister_fs(void)
+{
+        return unregister_filesystem(&lustre_fs_type);
+}
+
 EXPORT_SYMBOL(lustre_register_client_fill_super);
 EXPORT_SYMBOL(lustre_common_put_super);
 EXPORT_SYMBOL(lustre_get_process_log);
index 5e75eda..113fb40 100644 (file)
@@ -918,7 +918,6 @@ int main(int argc , char *const argv[])
                 {"fsname",1, 0, 'n'},
                 {"failover", 1, 0, 'f'},
                 {"help", 0, 0, 'h'},
-                {"index", 1, 0, 'I'},
                 {"mdt", 0, 0, 'M'},
                 {"mgmt", 0, 0, 'G'},
                 {"mgmtnode", 1, 0, 'm'},
@@ -930,6 +929,7 @@ int main(int argc , char *const argv[])
                 {"stripe_count", 1, 0, 'c'},
                 {"stripe_size", 1, 0, 's'},
                 {"stripe_index", 1, 0, 'i'},
+                {"index", 1, 0, 'i'},
                 {"timeout", 1, 0, 't'},
                 {"verbose", 0, 0, 'v'},
                 {0, 0, 0, 0}
@@ -1077,15 +1077,14 @@ int main(int argc , char *const argv[])
         strcpy(mop.mo_device, argv[optind]);
         
         /* These are the permanent mount options. */ 
-        if (mop.mo_ldd.ldd_mount_type == LDD_MT_EXT3) {
-                sprintf(mop.mo_ldd.ldd_mount_opts, "errors=remount-ro");
-                if (IS_OST(&mop.mo_ldd))
-                        strcat(mop.mo_ldd.ldd_mount_opts, ",asyncdel");
-        } else if (mop.mo_ldd.ldd_mount_type == LDD_MT_LDISKFS) {
+        if ((mop.mo_ldd.ldd_mount_type == LDD_MT_EXT3) ||
+            (mop.mo_ldd.ldd_mount_type == LDD_MT_LDISKFS)) {
                 sprintf(mop.mo_ldd.ldd_mount_opts, "errors=remount-ro");
+                // extents,mballoc? 
                 if (IS_MDT(&mop.mo_ldd))
-                        // FIXME ext3 also
                         strcat(mop.mo_ldd.ldd_mount_opts, ",iopen_nopriv");
+                if ((get_os_version() == 24) && IS_OST(&mop.mo_ldd))
+                        strcat(mop.mo_ldd.ldd_mount_opts, ",asyncdel");
         } else if (mop.mo_ldd.ldd_mount_type == LDD_MT_SMFS) {
                 sprintf(mop.mo_ldd.ldd_mount_opts, "type=ext3,dev=%s",
                         mop.mo_device);
index 74adfe6..c056927 100755 (executable)
@@ -32,6 +32,8 @@ cp ../lvfs/$FSFLT.$EXT $MDIR
 cp ../ost/ost.$EXT $MDIR
 cp ../obdfilter/obdfilter.$EXT $MDIR
 cp ../llite/llite.$EXT $MDIR
+cp ../mgc/mgc.$EXT $MDIR
+cp ../mgs/mgs.$EXT $MDIR
 
 # prevent warnings on my uml
 rm -f /lib/modules/`uname -r`/modules.*
@@ -52,7 +54,6 @@ if [ `grep -c lustre $MODFILE` -eq 0 ]; then
        echo alias _lustre portals >> $MODFILE
        echo add above _lustre ksocknal $FSFLT >> $MODFILE
        echo add below mds _lustre osc >> $MODFILE
-       echo add below oss _lustre ost >> $MODFILE
        echo add below ost _lustre >> $MODFILE
        echo add below llite _lustre osc mdc >> $MODFILE
        echo alias lustre llite >> $MODFILE
@@ -60,7 +61,7 @@ if [ `grep -c lustre $MODFILE` -eq 0 ]; then
        echo "install kptlrouter $MP portals && $MPI kptlrouter" >> $MODFILE
        echo "install _lustre $MP portals && $MP lvfs && $MP obdclass && $MP ptlrpc" >> $MODFILE
        echo "install obdfilter $MP _lustre && $MP ost && $MP ldiskfs && $MP $FSFLT && $MPI obdfilter" >> $MODFILE
-       echo "install oss $MP _lustre && $MP ost && $MPI oss" >> $MODFILE
+       echo "install ost $MP _lustre && $MPI ost" >> $MODFILE
        echo "install mds $MP _lustre && $MP osc && $MPI mds" >> $MODFILE
        echo "install llite $MP _lustre && $MP osc && $MP mdc && $MPI llite" >> $MODFILE
        echo "alias lustre llite" >> $MODFILE
index 3eeb47d..991db98 100644 (file)
@@ -106,12 +106,14 @@ static int load_modules(struct lustre_mount_data *lmd)
 {
         int rc = 0;
 
+        rc = load_module("_lustre");
+
         if (lmd_is_client(lmd)) {
-                rc = load_module("lustre");
+                rc = load_module("llite");
         } else {
                 rc = load_module("mds");
                 if (rc) return rc;
-                rc = load_module("oss");
+                rc = load_module("ost");
         }
         return rc;
 }
@@ -472,8 +474,8 @@ int main(int argc, char *const argv[])
                    does not. */
                 rc = mount(source, target, "lustre", flags, (void *)&lmd);
         if (rc) {
-                fprintf(stderr, "%s: mount(%s, %s) failed: %s\n", source,
-                        target, progname, strerror(errno));
+                fprintf(stderr, "%s: mount(%s, %s) failed: %s\n", progname, 
+                        source, target, strerror(errno));
                 if (errno == ENODEV)
                         fprintf(stderr, "Are the lustre modules loaded?\n"
                              "Check /etc/modules.conf and /proc/filesystems\n");