Whamcloud - gitweb
LU-14268 lod: fix layout generation inc for mirror split
authorBobi Jam <bobijam@whamcloud.com>
Tue, 22 Dec 2020 05:58:41 +0000 (13:58 +0800)
committerLi Xi <lixi@ddn.com>
Wed, 10 Mar 2021 14:37:15 +0000 (14:37 +0000)
Mirror split does not increase the layout generation properly.

Mirror split does not change FLR state of the file, even when it
contains 1 mirror afterwards, and FLR state should be LCM_FL_NONE
instead.

Lustre-commit: ffa858b1657145c7e3d9988291fbb1ef72b3b980
Lustre-change: https://review.whamcloud.com/41068

Signed-off-by: Bobi Jam <bobijam@whamcloud.com>
Change-Id: I9c9621d67d901f2e9ca6ed3e0684cd308c396076
Reviewed-on: https://review.whamcloud.com/41068
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: John L. Hammond <jhammond@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/41962
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Bobi Jam <bobijam@hotmail.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Li Xi <lixi@ddn.com>
lustre/lod/lod_lov.c
lustre/lod/lod_object.c
lustre/lov/lov_ea.c
lustre/lov/lov_object.c
lustre/tests/sanity-flr.sh

index 19f852b..de18c92 100644 (file)
@@ -1138,9 +1138,12 @@ int lod_parse_striping(const struct lu_env *env, struct lod_object *lo,
                        GOTO(out, rc = -EINVAL);
                lo->ldo_layout_gen = le32_to_cpu(comp_v1->lcm_layout_gen);
                lo->ldo_is_composite = 1;
-               lo->ldo_flr_state = le16_to_cpu(comp_v1->lcm_flags) &
-                                       LCM_FL_FLR_MASK;
                mirror_cnt = le16_to_cpu(comp_v1->lcm_mirror_count) + 1;
+               if (mirror_cnt > 1)
+                       lo->ldo_flr_state = le16_to_cpu(comp_v1->lcm_flags) &
+                                                       LCM_FL_FLR_MASK;
+               else
+                       lo->ldo_flr_state = LCM_FL_NONE;
        } else if (magic == LOV_MAGIC_FOREIGN) {
                size_t length;
 
index 751eb6b..9165fe2 100644 (file)
@@ -3409,13 +3409,14 @@ static int lod_declare_layout_split(const struct lu_env *env,
        int rc;
        ENTRY;
 
-       lod_obj_inc_layout_gen(lo);
-       lcm->lcm_layout_gen = cpu_to_le32(lo->ldo_layout_gen);
-
        rc = lod_striping_reload(env, lo, mbuf);
        if (rc)
                RETURN(rc);
 
+       lod_obj_inc_layout_gen(lo);
+       /* fix on-disk layout gen */
+       lcm->lcm_layout_gen = cpu_to_le32(lo->ldo_layout_gen);
+
        rc = lod_sub_declare_xattr_set(env, dt_object_child(dt), mbuf,
                                       XATTR_NAME_LOV, LU_XATTR_REPLACE, th);
        RETURN(rc);
index 19dffc7..15755a6 100644 (file)
@@ -611,10 +611,10 @@ void dump_lsm(unsigned int level, const struct lov_stripe_md *lsm)
        int i, j;
 
        CDEBUG_LIMIT(level,
-                    "lsm %p, objid "DOSTID", maxbytes %#llx, magic 0x%08X, refc: %d, entry: %u, layout_gen %u\n",
+                    "lsm %p, objid "DOSTID", maxbytes %#llx, magic 0x%08X, refc: %d, entry: %u, mirror: %u, flags: %u,layout_gen %u\n",
               lsm, POSTID(&lsm->lsm_oi), lsm->lsm_maxbytes, lsm->lsm_magic,
               atomic_read(&lsm->lsm_refc), lsm->lsm_entry_count,
-              lsm->lsm_layout_gen);
+              lsm->lsm_mirror_count, lsm->lsm_flags, lsm->lsm_layout_gen);
 
        if (lsm->lsm_magic == LOV_MAGIC_FOREIGN) {
                struct lov_foreign_md *lfm = (void *)lsm_foreign(lsm);
index da7bfe6..b096f72 100644 (file)
@@ -1393,6 +1393,7 @@ static int lov_conf_set(const struct lu_env *env, struct cl_object *obj,
        if ((lsm == NULL && lov->lo_lsm == NULL) ||
            ((lsm != NULL && lov->lo_lsm != NULL) &&
             (lov->lo_lsm->lsm_layout_gen == lsm->lsm_layout_gen) &&
+            (lov->lo_lsm->lsm_flags == lsm->lsm_flags) &&
             (lov->lo_lsm->lsm_entries[0]->lsme_pattern ==
              lsm->lsm_entries[0]->lsme_pattern))) {
                /* same version of layout */
index 18f10d4..85f3b86 100644 (file)
@@ -2251,6 +2251,34 @@ test_49a() {
 }
 run_test 49a "FIEMAP upon FLR file"
 
+test_50A() {   # EX-2179
+       mkdir -p $DIR/$tdir
+
+       local file=$DIR/$tdir/$tfile
+
+       $LFS setstripe -c1 -i0 $file || error "setstripe $file failed"
+
+       $LFS mirror extend -N -c1 -i1 $file ||
+               error "extending mirror for $file failed"
+
+       local olv=$($LFS getstripe $file | awk '/lcm_layout_gen/{print $2}')
+
+       fail mds1
+
+       $LFS mirror split -d --mirror-id=1 $file || error "split $file failed"
+
+       local flv=$($LFS getstripe $file | awk '/lcm_layout_gen/{print $2}')
+
+       echo "$file layout generation from $olv to $flv"
+       (( $flv != ($olv + 1) )) &&
+               error "split does not increase layout gen from $olv to $flv"
+
+       dd if=/dev/zero of=$file bs=1M count=1 || error "write $file failed"
+
+       $LFS getstripe -v $file || error "getstripe $file failed"
+}
+run_test 50A "mirror split update layout generation"
+
 test_50a() {
        $LCTL get_param osc.*.import | grep -q 'connect_flags:.*seek' ||
                skip "OST does not support SEEK_HOLE"