Whamcloud - gitweb
LU-14268 lod: fix layout generation inc for mirror split 68/41068/4
authorBobi Jam <bobijam@whamcloud.com>
Tue, 22 Dec 2020 05:58:41 +0000 (13:58 +0800)
committerOleg Drokin <green@whamcloud.com>
Fri, 26 Feb 2021 08:22:46 +0000 (08:22 +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.

Signed-off-by: Bobi Jam <bobijam@whamcloud.com>
Change-Id: I9c9621d67d901f2e9ca6ed3e0684cd308c396076
Reviewed-on: https://review.whamcloud.com/41068
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: John L. Hammond <jhammond@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.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 76f41f1..e011f7a 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;
                        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;
                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;
 
        } else if (magic == LOV_MAGIC_FOREIGN) {
                size_t length;
 
index 7851961..876f8b4 100644 (file)
@@ -3404,13 +3404,14 @@ static int lod_declare_layout_split(const struct lu_env *env,
        int rc;
        ENTRY;
 
        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);
 
        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);
        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,
        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, 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);
 
        if (lsm->lsm_magic == LOV_MAGIC_FOREIGN) {
                struct lov_foreign_md *lfm = (void *)lsm_foreign(lsm);
index 2561ae1..fac827e 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) &&
        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 */
             (lov->lo_lsm->lsm_entries[0]->lsme_pattern ==
              lsm->lsm_entries[0]->lsme_pattern))) {
                /* same version of layout */
index 6f089c9..1cfe663 100644 (file)
@@ -2323,6 +2323,34 @@ test_49a() {
 }
 run_test 49a "FIEMAP upon FLR file"
 
 }
 run_test 49a "FIEMAP upon FLR file"
 
+test_50() {    # 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 50 "mirror split update layout generation"
+
 ctrl_file=$(mktemp /tmp/CTRL.XXXXXX)
 lock_file=$(mktemp /var/lock/FLR.XXXXXX)
 
 ctrl_file=$(mktemp /tmp/CTRL.XXXXXX)
 lock_file=$(mktemp /var/lock/FLR.XXXXXX)