From: Bobi Jam Date: Tue, 21 Aug 2012 02:42:51 +0000 (+0800) Subject: LU-1773 lov: lov_delete_raid0() need heed lov_fini_raid0() X-Git-Tag: 2.3.51~164 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=dcc455397fb895a4e5ea0eebe146d96ba23a6eb8 LU-1773 lov: lov_delete_raid0() need heed lov_fini_raid0() Add a sanity test case and handle failure of lov_init_raid0() correctly. LU-1480 is also due to the failure of lov_init_raid0(). Signed-off-by: Jinshan Xiong Signed-off-by: Bobi Jam Change-Id: If900cb854846f778c74d0368d64cb7a9d5189406 Reviewed-on: http://review.whamcloud.com/3732 Tested-by: Hudson Reviewed-by: Fan Yong Tested-by: Maloo Reviewed-by: Oleg Drokin --- diff --git a/lustre/include/obd_support.h b/lustre/include/obd_support.h index 9649e49..6a36343 100644 --- a/lustre/include/obd_support.h +++ b/lustre/include/obd_support.h @@ -437,6 +437,7 @@ int obd_alloc_fail(const void *ptr, const char *name, const char *type, #define OBD_FAIL_LLITE 0x1400 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401 #define OBD_FAIL_LOCK_STATE_WAIT_INTR 0x1402 +#define OBD_FAIL_LOV_INIT 0x1403 /* Assign references to moved code to reduce code changes */ #define OBD_FAIL_PRECHECK(id) CFS_FAIL_PRECHECK(id) diff --git a/lustre/lov/lov_cl_internal.h b/lustre/lov/lov_cl_internal.h index 3870ddf..627abb2 100644 --- a/lustre/lov/lov_cl_internal.h +++ b/lustre/lov/lov_cl_internal.h @@ -424,7 +424,6 @@ struct lov_thread_info { struct cl_lock_descr lti_ldescr; struct ost_lvb lti_lvb; struct cl_2queue lti_cl2q; - union lov_layout_state lti_state; struct cl_lock_closure lti_closure; cfs_waitlink_t lti_waiter; }; diff --git a/lustre/lov/lov_object.c b/lustre/lov/lov_object.c index 1941462..f4ce101 100644 --- a/lustre/lov/lov_object.c +++ b/lustre/lov/lov_object.c @@ -107,7 +107,6 @@ static void lov_install_raid0(const struct lu_env *env, struct lov_object *lov, union lov_layout_state *state) { - lov->u = *state; } static struct cl_object *lov_sub_find(const struct lu_env *env, @@ -133,6 +132,11 @@ static int lov_init_sub(const struct lu_env *env, struct lov_object *lov, struct lov_oinfo *oinfo; int result; + if (OBD_FAIL_CHECK(OBD_FAIL_LOV_INIT)) { + cl_object_put(env, stripe); + return -EIO; + } + hdr = cl_object_header(lov2cl(lov)); subhdr = cl_object_header(stripe); parent = subhdr->coh_parent; @@ -286,7 +290,7 @@ static int lov_delete_raid0(const struct lu_env *env, struct lov_object *lov, ENTRY; dump_lsm(D_INODE, lsm); - if (cfs_atomic_read(&lsm->lsm_refc) > 1) + if (lov->lo_lsm_invalid && cfs_atomic_read(&lsm->lsm_refc) > 1) RETURN(-EBUSY); if (r0->lo_sub != NULL) { @@ -519,7 +523,7 @@ static int lov_layout_change(const struct lu_env *env, const struct cl_object_conf *conf) { int result; - union lov_layout_state *state = &lov_env_info(env)->lti_state; + union lov_layout_state *state = &lov->u; const struct lov_layout_operations *old_ops; const struct lov_layout_operations *new_ops; @@ -551,12 +555,17 @@ static int lov_layout_change(const struct lu_env *env, LASSERT(hdr->coh_tree.rnode == NULL); LASSERT(hdr->coh_pages == 0); + lov->lo_type = LLT_EMPTY; result = new_ops->llo_init(env, lu2lov_dev(lov->lo_cl.co_lu.lo_dev), lov, conf, state); if (result == 0) { new_ops->llo_install(env, lov, state); lov->lo_type = llt; + } else { + new_ops->llo_delete(env, lov, state); + new_ops->llo_fini(env, lov, state); + /* this file becomes an EMPTY file. */ } } RETURN(result); @@ -574,7 +583,7 @@ int lov_object_init(const struct lu_env *env, struct lu_object *obj, struct lov_device *dev = lu2lov_dev(obj->lo_dev); struct lov_object *lov = lu2lov(obj); const struct cl_object_conf *cconf = lu2cl_conf(conf); - union lov_layout_state *set = &lov_env_info(env)->lti_state; + union lov_layout_state *set = &lov->u; const struct lov_layout_operations *ops; int result; @@ -588,8 +597,6 @@ int lov_object_init(const struct lu_env *env, struct lu_object *obj, result = ops->llo_init(env, dev, lov, cconf, set); if (result == 0) ops->llo_install(env, lov, set); - else - ops->llo_fini(env, lov, set); RETURN(result); } diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index a960a1c..cb0a589 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -9071,6 +9071,17 @@ test_205() { # Job stats } run_test 205 "Verify job stats" +# LU-1480, LU-1773 and LU-1657 +test_206() { + mkdir -p $DIR/$tdir + lfs setstripe -c -1 $DIR/$tdir +#define OBD_FAIL_LOV_INIT 0x1403 + $LCTL set_param fail_loc=0xa0001403 + $LCTL set_param fail_val=1 + touch $DIR/$tdir/$tfile || true +} +run_test 206 "fail lov_init_raid0() doesn't lbug" + test_212() { size=`date +%s` size=$((size % 8192 + 1))