Whamcloud - gitweb
LU-1773 lov: lov_delete_raid0() need heed lov_fini_raid0()
authorBobi Jam <bobijam@whamcloud.com>
Tue, 21 Aug 2012 02:42:51 +0000 (10:42 +0800)
committerOleg Drokin <green@whamcloud.com>
Sun, 26 Aug 2012 03:21:33 +0000 (23:21 -0400)
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 <jinshan.xiong@whamcloud.com>
Signed-off-by: Bobi Jam <bobijam@whamcloud.com>
Change-Id: If900cb854846f778c74d0368d64cb7a9d5189406
Reviewed-on: http://review.whamcloud.com/3732
Tested-by: Hudson
Reviewed-by: Fan Yong <yong.fan@whamcloud.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/include/obd_support.h
lustre/lov/lov_cl_internal.h
lustre/lov/lov_object.c
lustre/tests/sanity.sh

index 9649e49..6a36343 100644 (file)
@@ -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)
index 3870ddf..627abb2 100644 (file)
@@ -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;
 };
index 1941462..f4ce101 100644 (file)
@@ -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);
 }
 
index a960a1c..cb0a589 100644 (file)
@@ -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))