Whamcloud - gitweb
EX-4463 flr: ensure layout generation is incremented on merge
authorJohn L. Hammond <jhammond@whamcloud.com>
Thu, 6 Jan 2022 15:09:30 +0000 (09:09 -0600)
committerJohn L. Hammond <jhammond@whamcloud.com>
Thu, 20 Jan 2022 14:21:32 +0000 (14:21 +0000)
In lod_declare_layout_merge(), load the striping before we increment
the layout generation. Add sanity-flr:test_51a to check this.

Fixes: 6b5a29c0ac94 (Revert "LU-14642 flr: transfer layout version on layout change")
Test-Parameters: testlist=sanity-flr envdefinitions=FAIL_ON_ERROR=false,ONLY=51a,ONLY_REPEAT=20
Signed-off-by: John L. Hammond <jhammond@whamcloud.com>
Change-Id: I357501edfd2bc0d710be902df9c40aab53c11824
Reviewed-on: https://review.whamcloud.com/46028
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
lustre/lod/lod_object.c
lustre/tests/sanity-flr.sh

index cac183a..e0810e1 100644 (file)
@@ -3414,8 +3414,6 @@ static int lod_declare_layout_merge(const struct lu_env *env,
        }
 
        /* fixup layout information */
-       lod_obj_inc_layout_gen(lo);
-       lcm->lcm_layout_gen = cpu_to_le32(lo->ldo_layout_gen);
        lcm->lcm_size = cpu_to_le32(size);
        lcm->lcm_entry_count = cpu_to_le16(cur_entry_count + merge_entry_count);
        lcm->lcm_mirror_count = cpu_to_le16(mirror_count);
@@ -3426,6 +3424,9 @@ static int lod_declare_layout_merge(const struct lu_env *env,
        if (rc)
                GOTO(out, rc);
 
+       lod_obj_inc_layout_gen(lo);
+       lcm->lcm_layout_gen = cpu_to_le32(lo->ldo_layout_gen);
+
        rc = lod_sub_declare_xattr_set(env, dt_object_child(dt), buf,
                                       XATTR_NAME_LOV, LU_XATTR_REPLACE, th);
 
index c864b99..56c0932 100644 (file)
@@ -2665,6 +2665,51 @@ test_50d() {
 }
 run_test 50d "mirror rsync keep holes"
 
+test_51a() {
+       local file="$DIR/$tdir/$tfile"
+       local mdt_index
+       local gen1
+       local gen2
+
+       test_mkdir $DIR/$tdir
+       rm -f -- "$file"
+
+       $LFS mirror create -N -E 1M -c 1 -E eof -c2 "$file"
+       echo XXX > "$file"
+       mdt_index=$($LFS getstripe --mdt-index "$file")
+       echo "mdt_index = $mdt_index" >&2
+
+       gen1=$($LFS getstripe "$file" | awk '$1 == "lcm_layout_gen:" { print $2; }')
+       # $LFS getstripe "$file"
+       echo "gen1 = '$gen1'" >&2
+       if [[ -z "$gen1" ]]; then
+               error "cannot get layout generation of '$file'"
+       fi
+
+       # I tried do do this with several combinations of sync,
+       # drop_caches, cancel_lru_locks on the client and mds but they
+       # didn't reliably reproduce the issue of incorrect layout
+       # generation after merge.
+       umount_client $MOUNT || error "cannot unmount '$MOUNT'"
+       stop mds$((mdt_index + 1)) || error "cannot stop mds$((mdt_index + 1))"
+       start mds$((mdt_index + 1)) || error "cannot start mds$((mdt_index + 1))"
+       mount_client $MOUNT || error "cannot mount '$MOUNT'"
+
+       $LFS mirror extend -N -c1 "$file"
+       gen2=$($LFS getstripe "$file" | awk '$1 == "lcm_layout_gen:" { print $2; }')
+       echo "gen2 = '$gen2'" >&2
+       # $LFS getstripe "$file"
+
+       if [[ -z "$gen2" ]]; then
+               error "cannot get layout generation of '$file'"
+       fi
+
+       if ! ((gen1 < gen2)); then
+               error "mirror extend did not increase layout generation"
+       fi
+}
+run_test 51a "mirror extend increases layout generation"
+
 test_60a() {
        $LCTL get_param osc.*.import | grep -q 'connect_flags:.*seek' ||
                skip "OST does not support SEEK_HOLE"