Whamcloud - gitweb
LU-11279 lod: reset ostlist properly in lod_get_default_lov_striping 69/33069/7
authorWang Shilong <wshilong@ddn.com>
Fri, 24 Aug 2018 06:49:06 +0000 (14:49 +0800)
committerOleg Drokin <green@whamcloud.com>
Tue, 4 Sep 2018 03:49:29 +0000 (03:49 +0000)
Ostlist might be allocated previously, and we should
reset them properly, otherwise, it will pollute new
default setting and cause unexpected behavior.

Test-Parameters: trivial testlist=sanity,sanity,sanity,sanity,sanity,sanity,sanity,sanity,sanity
Change-Id: I9b7acb5f05ec4b371da99f68b9647f0b75cd7021
Signed-off-by: Wang Shilong <wshilong@ddn.com>
Reviewed-on: https://review.whamcloud.com/33069
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Bobi Jam <bobijam@hotmail.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/lod/lod_lov.c
lustre/lod/lod_object.c
lustre/lod/lod_qos.c
lustre/tests/sanity.sh

index 2849beb..9e25dc4 100644 (file)
@@ -896,7 +896,8 @@ static int lod_gen_component_ea(const struct lu_env *env,
                                       PFID(&info->lti_fid), rc);
                                RETURN(rc);
                        }
-               } else if (lod_comp->llc_ostlist.op_array) {
+               } else if (lod_comp->llc_ostlist.op_array &&
+                          lod_comp->llc_ostlist.op_count) {
                        /* user specified ost list */
                        ost_idx = lod_comp->llc_ostlist.op_array[i];
                }
index f41b6e2..908f675 100644 (file)
@@ -4031,9 +4031,12 @@ int lod_comp_copy_ost_lists(struct lod_layout_component *lod_comp,
                v3->lmm_stripe_offset = v3->lmm_objects[0].l_ost_idx;
 
        if (lod_comp->llc_ostlist.op_array) {
-               if (lod_comp->llc_ostlist.op_count ==
-                                       v3->lmm_stripe_count)
+               if (lod_comp->llc_ostlist.op_size >=
+                   v3->lmm_stripe_count * sizeof(__u32))  {
+                       lod_comp->llc_ostlist.op_count =
+                                       v3->lmm_stripe_count;
                        goto skip;
+               }
                OBD_FREE(lod_comp->llc_ostlist.op_array,
                         lod_comp->llc_ostlist.op_size);
        }
@@ -4076,7 +4079,7 @@ static int lod_get_default_lov_striping(const struct lu_env *env,
        __u16   comp_cnt;
        __u16   mirror_cnt;
        bool    composite;
-       int     rc, i;
+       int     rc, i, j;
        ENTRY;
 
        lds->lds_def_striping_set = 0;
@@ -4182,6 +4185,11 @@ static int lod_get_default_lov_striping(const struct lu_env *env,
                        rc = lod_comp_copy_ost_lists(lod_comp, v3);
                        if (rc)
                                RETURN(rc);
+               } else if (lod_comp->llc_ostlist.op_array &&
+                          lod_comp->llc_ostlist.op_count) {
+                       for (j = 0; j < lod_comp->llc_ostlist.op_count; j++)
+                               lod_comp->llc_ostlist.op_array[j] = -1;
+                       lod_comp->llc_ostlist.op_count = 0;
                }
        }
 
@@ -4302,7 +4310,8 @@ static void lod_striping_from_default(struct lod_object *lo,
                        }
 
                        /* copy ost list */
-                       if (def_comp->llc_ostlist.op_array) {
+                       if (def_comp->llc_ostlist.op_array &&
+                           def_comp->llc_ostlist.op_count) {
                                OBD_ALLOC(obj_comp->llc_ostlist.op_array,
                                          obj_comp->llc_ostlist.op_size);
                                if (!obj_comp->llc_ostlist.op_array)
@@ -4310,6 +4319,8 @@ static void lod_striping_from_default(struct lod_object *lo,
                                memcpy(obj_comp->llc_ostlist.op_array,
                                       def_comp->llc_ostlist.op_array,
                                       obj_comp->llc_ostlist.op_size);
+                       } else if (def_comp->llc_ostlist.op_array) {
+                               obj_comp->llc_ostlist.op_array = NULL;
                        }
 
                        /*
index 4ab9643..cf578b5 100644 (file)
@@ -1216,6 +1216,7 @@ static int lod_alloc_ost_list(const struct lu_env *env, struct lod_object *lo,
        LASSERT(lo->ldo_comp_cnt > comp_idx && lo->ldo_comp_entries != NULL);
        lod_comp = &lo->ldo_comp_entries[comp_idx];
        LASSERT(lod_comp->llc_ostlist.op_array);
+       LASSERT(lod_comp->llc_ostlist.op_count);
 
        rc = lod_qos_ost_in_use_clear(env, lod_comp->llc_stripe_count);
        if (rc < 0)
@@ -2333,7 +2334,8 @@ int lod_qos_prep_create(const struct lu_env *env, struct lod_object *lo,
                CDEBUG(D_OTHER, "tgt_count %d stripe_count %d\n",
                                d->lod_desc.ld_tgt_count, stripe_len);
 
-               if (lod_comp->llc_ostlist.op_array) {
+               if (lod_comp->llc_ostlist.op_array &&
+                   lod_comp->llc_ostlist.op_count) {
                        rc = lod_alloc_ost_list(env, lo, stripe, ost_indices,
                                                th, comp_idx);
                } else if (lod_comp->llc_stripe_offset == LOV_OFFSET_DEFAULT) {
index c3713b0..2876399 100755 (executable)
@@ -2298,8 +2298,8 @@ test_27G() { #LU-10629
 run_test 27G "Clear OST pool from stripe"
 
 test_27H() {
-       [[ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.11.53) ]] &&
-               skip "Need MDS version newer than 2.11.53"
+       [[ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.11.54) ]] &&
+               skip "Need MDS version newer than 2.11.54"
        [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
        test_mkdir $DIR/$tdir
        $LFS setstripe -o 0 -o 2 $DIR/$tdir || error "setstripe failed"
@@ -2313,6 +2313,13 @@ test_27H() {
        (( $($LFS getstripe -y $DIR/$tdir/$tfile |
             egrep -c "l_ost_idx: [02]$") == "2" )) ||
                error "expected l_ost_idx: [02]$ not matched"
+
+       # make sure ost list have been cleared
+       local stripesize=$($GETSTRIPE -S $DIR/$tdir)
+       $LFS setstripe -S $((stripesize * 4)) -i 1 \
+               -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
+       touch $DIR/$tdir/f3
+       $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
 }
 run_test 27H "Set specific OSTs stripe"