Whamcloud - gitweb
LU-836 ldiskfs: require ldiskfs filesystem has journal
authorAndriy.Skulysh <Andriy_Skulysh@xyratex.com>
Tue, 30 Aug 2011 08:42:31 +0000 (11:42 +0300)
committerOleg Drokin <green@whamcloud.com>
Thu, 29 Mar 2012 04:23:42 +0000 (00:23 -0400)
Add check for journal presence during ldiskfs mount

Xyratex-Bug-Id: MRP-118
Change-Id: If26005f7b597ed8815991fac7cda80e1df2f36e9
Signed-off-by: Andriy Skulysh <Andriy_Skulysh@xyratex.com>
Reviewed-by: Alexey Lyashkov <alexey_lyashkov@xyratex.com>
Reviewed-by: Andrew Perepechko <andrew_perepechko@xyratex.com>
Reviewed-on: http://review.whamcloud.com/1687
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/lvfs/fsfilt_ext3.c
lustre/mds/handler.c
lustre/mgc/mgc_request.c
lustre/mgs/mgs_fs.c
lustre/obdfilter/filter.c
lustre/tests/conf-sanity.sh

index 209f433..454bd3e 100644 (file)
@@ -1450,6 +1450,12 @@ static int fsfilt_ext3_setup(struct super_block *sb)
         sbi->dx_unlock = fsfilt_ext3_dx_unlock;
 #endif
 #endif
         sbi->dx_unlock = fsfilt_ext3_dx_unlock;
 #endif
 #endif
+        if (!EXT3_HAS_COMPAT_FEATURE(sb,
+                                EXT3_FEATURE_COMPAT_HAS_JOURNAL)) {
+                CERROR("ext3 mounted without journal\n");
+                return -EINVAL;
+        }
+
 #ifdef S_PDIROPS
         CWARN("Enabling PDIROPS\n");
         set_opt(sbi->s_mount_opt, PDIROPS);
 #ifdef S_PDIROPS
         CWARN("Enabling PDIROPS\n");
         set_opt(sbi->s_mount_opt, PDIROPS);
index 35af1a9..2163dcd 100644 (file)
@@ -262,22 +262,25 @@ struct lvfs_callback_ops mds_lvfs_ops = {
         l_fid2dentry:     mds_lvfs_fid2dentry,
 };
 
         l_fid2dentry:     mds_lvfs_fid2dentry,
 };
 
-static void mds_init_ctxt(struct obd_device *obd, struct vfsmount *mnt)
+static int mds_init_ctxt(struct obd_device *obd, struct vfsmount *mnt)
 {
         struct mds_obd *mds = &obd->u.mds;
 {
         struct mds_obd *mds = &obd->u.mds;
+        int rc;
 
         mds->mds_obt.obt_vfsmnt = mnt;
         /* why not mnt->mnt_sb instead of mnt->mnt_root->d_inode->i_sb? */
         obd->u.obt.obt_sb = mnt->mnt_root->d_inode->i_sb;
         obd->u.obt.obt_magic = OBT_MAGIC;
 
         mds->mds_obt.obt_vfsmnt = mnt;
         /* why not mnt->mnt_sb instead of mnt->mnt_root->d_inode->i_sb? */
         obd->u.obt.obt_sb = mnt->mnt_root->d_inode->i_sb;
         obd->u.obt.obt_magic = OBT_MAGIC;
-        fsfilt_setup(obd, obd->u.obt.obt_sb);
+        rc = fsfilt_setup(obd, obd->u.obt.obt_sb);
+        if (rc)
+                return rc;
 
         OBD_SET_CTXT_MAGIC(&obd->obd_lvfs_ctxt);
         obd->obd_lvfs_ctxt.pwdmnt = mnt;
         obd->obd_lvfs_ctxt.pwd = mnt->mnt_root;
         obd->obd_lvfs_ctxt.fs = get_ds();
         obd->obd_lvfs_ctxt.cb_ops = mds_lvfs_ops;
 
         OBD_SET_CTXT_MAGIC(&obd->obd_lvfs_ctxt);
         obd->obd_lvfs_ctxt.pwdmnt = mnt;
         obd->obd_lvfs_ctxt.pwd = mnt->mnt_root;
         obd->obd_lvfs_ctxt.fs = get_ds();
         obd->obd_lvfs_ctxt.cb_ops = mds_lvfs_ops;
-        return;
+        return 0;
 }
 
 /*mds still need lov setup here*/
 }
 
 /*mds still need lov setup here*/
@@ -316,14 +319,16 @@ static int mds_cmd_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
         cfs_init_rwsem(&mds->mds_notify_lock);
 
         obd->obd_fsops = fsfilt_get_ops(MT_STR(lsi->lsi_ldd));
         cfs_init_rwsem(&mds->mds_notify_lock);
 
         obd->obd_fsops = fsfilt_get_ops(MT_STR(lsi->lsi_ldd));
-        mds_init_ctxt(obd, mnt);
+        rc = mds_init_ctxt(obd, mnt);
+        if (rc)
+                GOTO(err_putfs, rc);
 
         push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
         dentry = simple_mkdir(cfs_fs_pwd(current->fs), mnt, "OBJECTS", 0777, 1);
         if (IS_ERR(dentry)) {
                 rc = PTR_ERR(dentry);
                 CERROR("cannot create OBJECTS directory: rc = %d\n", rc);
 
         push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
         dentry = simple_mkdir(cfs_fs_pwd(current->fs), mnt, "OBJECTS", 0777, 1);
         if (IS_ERR(dentry)) {
                 rc = PTR_ERR(dentry);
                 CERROR("cannot create OBJECTS directory: rc = %d\n", rc);
-                GOTO(err_putfs, rc);
+                GOTO(err_pop, rc);
         }
         mds->mds_objects_dir = dentry;
 
         }
         mds->mds_objects_dir = dentry;
 
@@ -348,14 +353,16 @@ static int mds_cmd_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
         if (rc)
                 GOTO(err_objects, rc);
 
         if (rc)
                 GOTO(err_objects, rc);
 
-err_pop:
         pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
         pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
-        RETURN(rc);
+        RETURN(0);
+
 err_objects:
         dput(mds->mds_objects_dir);
 err_objects:
         dput(mds->mds_objects_dir);
+err_pop:
+        pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
 err_putfs:
         fsfilt_put_ops(obd->obd_fsops);
 err_putfs:
         fsfilt_put_ops(obd->obd_fsops);
-        goto err_pop;
+        return rc;
 }
 
 static int mds_cmd_cleanup(struct obd_device *obd)
 }
 
 static int mds_cmd_cleanup(struct obd_device *obd)
index 914b5be..18f93f9 100644 (file)
@@ -633,7 +633,9 @@ static int mgc_fs_setup(struct obd_device *obd, struct super_block *sb,
         }
 
         cli->cl_mgc_vfsmnt = mnt;
         }
 
         cli->cl_mgc_vfsmnt = mnt;
-        fsfilt_setup(obd, mnt->mnt_sb);
+        err = fsfilt_setup(obd, mnt->mnt_sb);
+        if (err)
+                GOTO(err_ops, err);
 
         OBD_SET_CTXT_MAGIC(&obd->obd_lvfs_ctxt);
         obd->obd_lvfs_ctxt.pwdmnt = mnt;
 
         OBD_SET_CTXT_MAGIC(&obd->obd_lvfs_ctxt);
         obd->obd_lvfs_ctxt.pwdmnt = mnt;
index f414069..75d3781 100644 (file)
@@ -162,7 +162,9 @@ int mgs_fs_setup(struct obd_device *obd, struct vfsmount *mnt)
         mgs->mgs_vfsmnt = mnt;
         mgs->mgs_sb = mnt->mnt_root->d_inode->i_sb;
 
         mgs->mgs_vfsmnt = mnt;
         mgs->mgs_sb = mnt->mnt_root->d_inode->i_sb;
 
-        fsfilt_setup(obd, mgs->mgs_sb);
+        rc = fsfilt_setup(obd, mgs->mgs_sb);
+        if (rc)
+                RETURN(rc);
 
         OBD_SET_CTXT_MAGIC(&obd->obd_lvfs_ctxt);
         obd->obd_lvfs_ctxt.pwdmnt = mnt;
 
         OBD_SET_CTXT_MAGIC(&obd->obd_lvfs_ctxt);
         obd->obd_lvfs_ctxt.pwdmnt = mnt;
index 63a0664..17ace2e 100644 (file)
@@ -2038,7 +2038,9 @@ int filter_common_setup(struct obd_device *obd, struct lustre_cfg* lcfg,
         filter->fo_fstype = mnt->mnt_sb->s_type->name;
         CDEBUG(D_SUPER, "%s: mnt = %p\n", filter->fo_fstype, mnt);
 
         filter->fo_fstype = mnt->mnt_sb->s_type->name;
         CDEBUG(D_SUPER, "%s: mnt = %p\n", filter->fo_fstype, mnt);
 
-        fsfilt_setup(obd, obd->u.obt.obt_sb);
+        rc = fsfilt_setup(obd, obd->u.obt.obt_sb);
+        if (rc)
+                GOTO(err_ops, rc);
 
         OBD_SET_CTXT_MAGIC(&obd->obd_lvfs_ctxt);
         obd->obd_lvfs_ctxt.pwdmnt = mnt;
 
         OBD_SET_CTXT_MAGIC(&obd->obd_lvfs_ctxt);
         obd->obd_lvfs_ctxt.pwdmnt = mnt;
index b8bc4bb..36b2f97 100644 (file)
@@ -2821,6 +2821,22 @@ test_61() { # LU-80
 }
 run_test 61 "large xattr"
 
 }
 run_test 61 "large xattr"
 
+test_62() {
+    # MRP-118
+    local mdsdev=$(mdsdevname 1)
+    local ostdev=$(ostdevname 1)
+
+    echo "disable journal for mds"
+    do_facet mds tune2fs -O ^has_journal $mdsdev || error "tune2fs failed"
+    start_mds && error "MDT start should fail"
+    echo "disable journal for ost"
+    do_facet ost1 tune2fs -O ^has_journal $ostdev || error "tune2fs failed"
+    start_ost && error "OST start should fail"
+    cleanup || return $?
+    reformat_and_config
+}
+run_test 62 "start with disabled journal"
+
 if ! combined_mgs_mds ; then
        stop mgs
 fi
 if ! combined_mgs_mds ; then
        stop mgs
 fi