Whamcloud - gitweb
Branch b1_4_mountconf
authornathan <nathan>
Sat, 12 Nov 2005 00:47:00 +0000 (00:47 +0000)
committernathan <nathan>
Sat, 12 Nov 2005 00:47:00 +0000 (00:47 +0000)
b=8009
mgs disk mount

lustre/mds/handler.c
lustre/mgs/mgs_handler.c
lustre/obdclass/obd_mount.c
lustre/obdfilter/filter.c

index 06a1fdd..5d3a736 100644 (file)
@@ -1458,7 +1458,7 @@ static int mds_setup(struct obd_device *obd, obd_count len, void *buf)
                 obd->obd_fsops = fsfilt_get_ops(lustre_cfg_string(lcfg, 2));
         }
         if (IS_ERR(obd->obd_fsops))
-                RETURN(rc = PTR_ERR(obd->obd_fsops));
+                GOTO(err_put, rc = PTR_ERR(obd->obd_fsops));
 
         CDEBUG(D_SUPER, "%s: mnt = %p\n", lustre_cfg_string(lcfg, 1), mnt);
 
@@ -1474,7 +1474,7 @@ static int mds_setup(struct obd_device *obd, obd_count len, void *buf)
         obd->obd_namespace = ldlm_namespace_new(ns_name, LDLM_NAMESPACE_SERVER);
         if (obd->obd_namespace == NULL) {
                 mds_cleanup(obd);
-                GOTO(err_put, rc = -ENOMEM);
+                GOTO(err_ops, rc = -ENOMEM);
         }
         ldlm_register_intent(obd->obd_namespace, mds_intent_policy);
 
@@ -1501,7 +1501,6 @@ static int mds_setup(struct obd_device *obd, obd_count len, void *buf)
 
                 strncpy(mds->mds_profile, lustre_cfg_string(lcfg, 3),
                         LUSTRE_CFG_BUFLEN(lcfg, 3));
-
         }
 
         ptlrpc_init_client(LDLM_CB_REQUEST_PORTAL, LDLM_CB_REPLY_PORTAL,
@@ -1562,6 +1561,8 @@ err_fs:
 err_ns:
         ldlm_namespace_free(obd->obd_namespace, 0);
         obd->obd_namespace = NULL;
+err_ops:
+        fsfilt_put_ops(obd->obd_fsops);
 err_put:
         if (lmi) {
                 lustre_put_mount(obd->obd_name, mds->mds_vfsmnt);
@@ -1572,7 +1573,6 @@ err_put:
                 lock_kernel();
         }               
         mds->mds_sb = 0;
-        fsfilt_put_ops(obd->obd_fsops);
         return rc;
 }
 
@@ -1759,12 +1759,6 @@ static int mds_cleanup(struct obd_device *obd)
         upcall_cache_cleanup(mds->mds_group_hash);
         mds->mds_group_hash = NULL;
 
-        /* 2 seems normal on mds, (may_umount() also expects 2
-          fwiw), but we only see 1 at this point in obdfilter. */
-        if (atomic_read(&obd->u.mds.mds_vfsmnt->mnt_count) > 2)
-                CERROR("%s: mount busy, mnt_count %d != 2\n", obd->obd_name,
-                       atomic_read(&obd->u.mds.mds_vfsmnt->mnt_count));
-
         must_put = lustre_put_mount(obd->obd_name, mds->mds_vfsmnt);
         /* must_put is for old method (l_p_m returns non-0 on err) */
 
index c525114..c8928c4 100644 (file)
@@ -43,6 +43,7 @@
 #include <linux/lprocfs_status.h>
 #include <linux/lustre_fsfilt.h>
 #include <linux/lustre_commit_confd.h>
+#include <linux/lustre_disk.h>
 #include "mgs_internal.h"
 
 static int mgs_postsetup(struct obd_device *obd);
@@ -148,59 +149,35 @@ static int mgs_disconnect(struct obd_export *exp)
         RETURN(rc);
 }
 
-/* mount the file system (secretly) */
+/* Start the MGS obd */
 static int mgs_setup(struct obd_device *obd, obd_count len, void *buf)
 {
         struct lprocfs_static_vars lvars;
-        struct lustre_cfg* lcfg = buf;
-        char *options = NULL;
         char *ns_name = "MGS";
         struct mgs_obd *mgs = &obd->u.mgs;
+        struct lustre_mount_info *lmi;
+        struct lustre_sb_info *lsi;
         struct vfsmount *mnt;
-        unsigned long page;
         int rc = 0;
         ENTRY;
 
-        /* setup 1:/dev/loop/0 2:ext3 3:mgs 4:errors=remount-ro,iopen_nopriv*/
+        CDEBUG(D_CONFIG, "Starting MGS\n");
 
-        if (lcfg->lcfg_bufcount < 3)
+        lmi = lustre_get_mount(obd->obd_name);
+        if (!lmi) 
                 RETURN(rc = -EINVAL);
 
-        if (LUSTRE_CFG_BUFLEN(lcfg, 1) == 0 || LUSTRE_CFG_BUFLEN(lcfg, 2) == 0)
-                RETURN(rc = -EINVAL);
-
-        obd->obd_fsops = fsfilt_get_ops(lustre_cfg_string(lcfg, 2));
+        mnt = lmi->lmi_mnt;
+        lsi = s2lsi(lmi->lmi_sb);
+        obd->obd_fsops = fsfilt_get_ops(MT_STR(lsi->lsi_ldd));
         if (IS_ERR(obd->obd_fsops))
-                RETURN(rc = PTR_ERR(obd->obd_fsops));
-
-        page = __get_free_page(GFP_KERNEL);
-        if (!page)
-                RETURN(-ENOMEM);
-
-        options = (char *)page;
-        memset(options, 0, PAGE_SIZE);
-
-        if (LUSTRE_CFG_BUFLEN(lcfg, 4) > 0 && lustre_cfg_buf(lcfg, 4))
-                sprintf(options , ",%s", lustre_cfg_string(lcfg, 4));
-
-        //FIXME mount was already done in lustre_fill_super,
-        //we just need to access it
-        mnt = do_kern_mount(lustre_cfg_string(lcfg, 2), 0,
-                            lustre_cfg_string(lcfg, 1), (void *)options);
-        free_page(page);
-        if (IS_ERR(mnt)) {
-                rc = PTR_ERR(mnt);
-                CERROR("do_kern_mount failed: rc = %d\n", rc);
-                GOTO(err_ops, rc);
-        }
-
-        CDEBUG(D_SUPER, "%s: mnt = %p\n", lustre_cfg_string(lcfg, 1), mnt);
+                GOTO(err_put, rc = PTR_ERR(obd->obd_fsops));
 
-        /*namespace for mgs llog */
+        /* namespace for mgs llog */
         obd->obd_namespace = ldlm_namespace_new(ns_name, LDLM_NAMESPACE_SERVER);
         if (obd->obd_namespace == NULL) {
                 mgs_cleanup(obd);
-                GOTO(err_put, rc = -ENOMEM);
+                GOTO(err_ops, rc = -ENOMEM);
         }
 
         LASSERT(!lvfs_check_rdonly(lvfs_sbdev(mnt->mnt_sb)));
@@ -225,27 +202,7 @@ static int mgs_setup(struct obd_device *obd, obd_count len, void *buf)
         lprocfs_init_vars(mgs, &lvars);
         lprocfs_obd_setup(obd, lvars.obd_vars);
 
-        if (obd->obd_recovering) {
-                LCONSOLE_WARN("MGT %s now serving %s, but will be in recovery "
-                              "until %d %s reconnect, or if no clients "
-                              "reconnect for %d:%.02d; during that time new "
-                              "clients will not be allowed to connect. "
-                              "Recovery progress can be monitored by watching "
-                              "/proc/fs/lustre/mgs/%s/recovery_status.\n",
-                              obd->obd_name,
-                              lustre_cfg_string(lcfg, 1),
-                              obd->obd_recoverable_clients,
-                              (obd->obd_recoverable_clients == 1) 
-                              ? "client" : "clients",
-                              (int)(OBD_RECOVERY_TIMEOUT / HZ) / 60,
-                              (int)(OBD_RECOVERY_TIMEOUT / HZ) % 60,
-                              obd->obd_name);
-        } else {
-                LCONSOLE_INFO("MGT %s now serving %s with recovery %s.\n",
-                              obd->obd_name,
-                              lustre_cfg_string(lcfg, 1),
-                              obd->obd_replayable ? "enabled" : "disabled");
-        }
+        LCONSOLE_INFO("MGS %s started\n", obd->obd_name);
 
         ldlm_timeout = 6;
         ping_evictor_start();
@@ -258,13 +215,11 @@ err_fs:
 err_ns:
         ldlm_namespace_free(obd->obd_namespace, 0);
         obd->obd_namespace = NULL;
-err_put:
-        unlock_kernel();
-        mntput(mgs->mgs_vfsmnt);
-        mgs->mgs_sb = 0;
-        lock_kernel();
 err_ops:
         fsfilt_put_ops(obd->obd_fsops);
+err_put:
+        lustre_put_mount(obd->obd_name, mgs->mgs_vfsmnt);
+        mgs->mgs_sb = 0;
         return rc;
 }
 
@@ -292,7 +247,6 @@ static int mgs_cleanup(struct obd_device *obd)
 {
         struct mgs_obd *mgs = &obd->u.mgs;
         lvfs_sbdev_type save_dev;
-        int must_relock = 0;
         ENTRY;
 
         ping_evictor_stop();
@@ -307,18 +261,7 @@ static int mgs_cleanup(struct obd_device *obd)
 
         mgs_fs_cleanup(obd);
 
-        if (atomic_read(&obd->u.mgs.mgs_vfsmnt->mnt_count) > 2)
-                CERROR("%s: mount busy, mnt_count %d != 2\n", obd->obd_name,
-                       atomic_read(&obd->u.mgs.mgs_vfsmnt->mnt_count));
-
-        /* We can only unlock kernel if we are in the context of sys_ioctl,
-           otherwise we never called lock_kernel */
-        if (kernel_locked()) {
-                unlock_kernel();
-                must_relock++;
-        }
-
-        mntput(mgs->mgs_vfsmnt);
+        lustre_put_mount(obd->obd_name, mgs->mgs_vfsmnt);
         mgs->mgs_sb = NULL;
 
         ldlm_namespace_free(obd->obd_namespace, obd->obd_force);
@@ -332,12 +275,9 @@ static int mgs_cleanup(struct obd_device *obd)
 
         lvfs_clear_rdonly(save_dev);
 
-        if (must_relock)
-                lock_kernel();
-
         fsfilt_put_ops(obd->obd_fsops);
 
-        LCONSOLE_INFO("MGT %s has stopped.\n", obd->obd_name);
+        LCONSOLE_INFO("MGS %s has stopped.\n", obd->obd_name);
 
         RETURN(0);
 }
index b15f1a3..7d8c328 100644 (file)
@@ -25,7 +25,7 @@
 
 
 #define DEBUG_SUBSYSTEM S_MGMT
-#define D_MOUNT D_ERROR
+#define D_MOUNT D_SUPER|D_CONFIG|D_ERROR
 
 #include <linux/obd.h>
 #include <linux/lvfs.h>
@@ -197,6 +197,11 @@ int lustre_put_mount(char *name, struct vfsmount *mnt)
                 CDEBUG(D_MOUNT, "Last put of mnt %p from %s, mount count %d\n", 
                        lmi->lmi_mnt, name, 
                        atomic_read(&lmi->lmi_mnt->mnt_count));
+                /* 2 seems normal on mds, (may_umount() also expects 2
+                  fwiw), but we only see 1 at this point in obdfilter. */
+                if (atomic_read(&lmi->lmi_mnt->mnt_count) > 2)
+                        CERROR("%s: mount busy, mnt_count %d != 2\n", name,
+                               atomic_read(&lmi->lmi_mnt->mnt_count));
         }
         up(&lustre_mount_info_lock);
 
@@ -377,7 +382,8 @@ static int do_lcfg(char *cfgname, lnet_nid_t nid, int cmd,
         struct lustre_cfg    * lcfg = NULL;
         int err;
                
-        CDEBUG(D_ERROR, "lcfg %s %#x %s %s %s %s\n", cfgname, cmd, s1, s2, s3, s4); 
+        CDEBUG(D_TRACE, "lcfg %s %#x %s %s %s %s\n", cfgname,
+               cmd, s1, s2, s3, s4); 
 
         lustre_cfg_bufs_reset(&bufs, cfgname);
         if (s1) 
@@ -426,7 +432,7 @@ static int lustre_start_mgs(struct super_block *sb, struct vfsmount *mnt)
                 return (-ENOMEM);
         sprintf(mgsname, "MGS_%p", sb);
 
-        CDEBUG(D_MOUNT, "Start MGS service %s\n", mgsname);
+        CDEBUG(D_CONFIG, "Start MGS service %s\n", mgsname);
 
         err = lustre_register_mount(mgsname, sb, mnt);
 
@@ -589,8 +595,7 @@ 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);
-        int err, mdsstart=0, oststart=0;
-                                                                                       
+        int err;
                                         
         CDEBUG(D_MOUNT, "starting target %s\n", lsi->lsi_ldd->ldd_svname);
         
index 5c2e9db..eb5641f 100644 (file)
@@ -1327,32 +1327,34 @@ int filter_common_setup(struct obd_device *obd, obd_count len, void *buf,
             LUSTRE_CFG_BUFLEN(lcfg, 2) < 1)
                 RETURN(-EINVAL);
 
-        obd->obd_fsops = fsfilt_get_ops(lustre_cfg_string(lcfg, 2));
-        if (IS_ERR(obd->obd_fsops))
-                RETURN(PTR_ERR(obd->obd_fsops));
-
-        rc = filter_iobuf_pool_init(filter, OST_NUM_THREADS);
-        if (rc != 0)
-                GOTO(err_ops, rc);
-
         lmi = lustre_get_mount(obd->obd_name);
         if (lmi) {
-                /* We already mounted in lustre_fill_super */
+                /* We already mounted in lustre_fill_super.
+                   lcfg bufs 1, 2, 4 (device, fstype, mount opts) are ignored.*/
+                struct lustre_sb_info *lsi = s2lsi(lmi->lmi_sb);
                 mnt = lmi->lmi_mnt;
+                obd->obd_fsops = fsfilt_get_ops(MT_STR(lsi->lsi_ldd));
         } else {
                 /* old path - used by lctl */
                 CERROR("Using old MDS mount method\n");
                 mnt = do_kern_mount(lustre_cfg_string(lcfg, 2),
                                     MS_NOATIME|MS_NODIRATIME,
-                                    lustre_cfg_string(lcfg, 1), option);       
+                                    lustre_cfg_string(lcfg, 1), option);    
+                if (IS_ERR(mnt)) {
+                        rc = PTR_ERR(mnt);
+                        LCONSOLE_ERROR("Can't mount disk %s (%d)\n",
+                                       lustre_cfg_string(lcfg, 1), rc);
+                        RETURN(rc);
+                }
+
+                obd->obd_fsops = fsfilt_get_ops(lustre_cfg_string(lcfg, 2));
         }
+        if (IS_ERR(obd->obd_fsops))
+                GOTO(err_mntput, rc = PTR_ERR(obd->obd_fsops));
 
-        if (IS_ERR(mnt)) {
-                rc = PTR_ERR(mnt);
-                LCONSOLE_ERROR("Can't mount disk %s (%d)\n",
-                               lustre_cfg_string(lcfg, 1), rc);
+        rc = filter_iobuf_pool_init(filter, OST_NUM_THREADS);
+        if (rc != 0)
                 GOTO(err_ops, rc);
-        }
 
         LASSERT(!lvfs_check_rdonly(lvfs_sbdev(mnt->mnt_sb)));
 
@@ -1382,7 +1384,7 @@ int filter_common_setup(struct obd_device *obd, obd_count len, void *buf,
 
         rc = filter_prep(obd);
         if (rc)
-                GOTO(err_mntput, rc);
+                GOTO(err_ops, rc);
 
         filter->fo_destroy_in_progress = 0;
         sema_init(&filter->fo_create_lock, 1);
@@ -1454,6 +1456,9 @@ int filter_common_setup(struct obd_device *obd, obd_count len, void *buf,
 
 err_post:
         filter_post(obd);
+err_ops:
+        fsfilt_put_ops(obd->obd_fsops);
+        filter_iobuf_pool_done(filter);
 err_mntput:
         if (lmi) {
                 lustre_put_mount(obd->obd_name, mnt);
@@ -1464,9 +1469,6 @@ err_mntput:
                 lock_kernel();
         }
         filter->fo_sb = 0;
-err_ops:
-        fsfilt_put_ops(obd->obd_fsops);
-        filter_iobuf_pool_done(filter);
         return rc;
 }