From 1ccdab699584306383dc21ff2c0f48bce70f6660 Mon Sep 17 00:00:00 2001 From: Lai Siyao Date: Fri, 22 Feb 2013 22:35:29 +0800 Subject: [PATCH] LU-2844 mdd: mdt prepare failure should not oops If mdd prepare fails, lfsck data may not be initialized, mdd lfsck stop should check this flag. Add one test to fail mdt prepare, and system should not oops upon this failure. Signed-off-by: Lai Siyao Change-Id: Ie3e81a2a18aedaa47965800881292c122937506a Reviewed-on: http://review.whamcloud.com/5519 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Ned Bass Reviewed-by: Fan Yong Reviewed-by: Oleg Drokin --- lustre/include/obd_support.h | 1 + lustre/mdd/mdd_device.c | 6 ++++++ lustre/mdd/mdd_lfsck.c | 3 +++ lustre/obdclass/obd_mount.c | 2 +- lustre/tests/recovery-small.sh | 12 ++++++++++++ 5 files changed, 23 insertions(+), 1 deletion(-) diff --git a/lustre/include/obd_support.h b/lustre/include/obd_support.h index e8c8b09..eeef78b 100644 --- a/lustre/include/obd_support.h +++ b/lustre/include/obd_support.h @@ -241,6 +241,7 @@ int obd_alloc_fail(const void *ptr, const char *name, const char *type, #define OBD_FAIL_MDS_HSM_CT_UNREGISTER_NET 0x14e #define OBD_FAIL_MDS_SWAP_LAYOUTS_NET 0x14f #define OBD_FAIL_MDS_HSM_ACTION_NET 0x150 +#define OBD_FAIL_MDS_CHANGELOG_INIT 0x151 /* layout lock */ #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170 diff --git a/lustre/mdd/mdd_device.c b/lustre/mdd/mdd_device.c index 639b688..06db993 100644 --- a/lustre/mdd/mdd_device.c +++ b/lustre/mdd/mdd_device.c @@ -293,6 +293,12 @@ static int mdd_changelog_llog_init(const struct lu_env *env, struct llog_ctxt *ctxt = NULL, *uctxt = NULL; int rc; + ENTRY; + + /* LU-2844 mdd setup failure should not cause umount oops */ + if (OBD_FAIL_CHECK(OBD_FAIL_MDS_CHANGELOG_INIT)) + RETURN(-EIO); + OBD_SET_CTXT_MAGIC(&obd->obd_lvfs_ctxt); obd->obd_lvfs_ctxt.dt = mdd->mdd_bottom; rc = llog_setup(env, obd, &obd->obd_olg, LLOG_CHANGELOG_ORIG_CTXT, diff --git a/lustre/mdd/mdd_lfsck.c b/lustre/mdd/mdd_lfsck.c index c31f3ad..152a2d4 100644 --- a/lustre/mdd/mdd_lfsck.c +++ b/lustre/mdd/mdd_lfsck.c @@ -2893,6 +2893,9 @@ int mdd_lfsck_stop(const struct lu_env *env, struct md_lfsck *lfsck, struct l_wait_info lwi = { 0 }; ENTRY; + if (!lfsck->ml_initialized) + RETURN(0); + mutex_lock(&lfsck->ml_mutex); spin_lock(&lfsck->ml_lock); if (thread_is_init(thread) || thread_is_stopped(thread)) { diff --git a/lustre/obdclass/obd_mount.c b/lustre/obdclass/obd_mount.c index 83bb072..55096da 100644 --- a/lustre/obdclass/obd_mount.c +++ b/lustre/obdclass/obd_mount.c @@ -1888,7 +1888,7 @@ static int server_start_targets(struct super_block *sb, struct vfsmount *mnt) lu_context_enter(&session_ctx); env.le_ses = &session_ctx; - dev->ld_ops->ldo_prepare(&env, NULL, dev); + rc = dev->ld_ops->ldo_prepare(&env, NULL, dev); lu_env_fini(&env); lu_context_exit(&session_ctx); diff --git a/lustre/tests/recovery-small.sh b/lustre/tests/recovery-small.sh index 3f4a5cb..c2cbac1 100755 --- a/lustre/tests/recovery-small.sh +++ b/lustre/tests/recovery-small.sh @@ -1761,6 +1761,18 @@ test_110f () { } run_test 110f "remove remote directory: drop slave rep" +# LU-2844 mdt prepare fail should not cause umount oops +test_111 () { + local mdsdev=$(mdsdevname ${SINGLEMDS//mds/}) +#define OBD_FAIL_MDS_CHANGELOG_INIT 0x151 + do_facet $SINGLEMDS lctl set_param fail_loc=0x151 + stop $SINGLEMDS || error "stop MDS failed" + start $SINGLEMDS $mdsdev && error "start MDS should fail" + do_facet $SINGLEMDS lctl set_param fail_loc=0 + start $SINGLEMDS $mdsdev || error "start MDS failed" +} +run_test 111 "mdd setup fail should not cause umount oops" + complete $SECONDS check_and_cleanup_lustre exit_status -- 1.8.3.1