Whamcloud - gitweb
LU-16500 utils: set default ost index for lfs migrate 19/49819/3
authorJian Yu <yujian@whamcloud.com>
Wed, 1 Feb 2023 07:11:56 +0000 (23:11 -0800)
committerOleg Drokin <green@whamcloud.com>
Wed, 8 Feb 2023 06:28:08 +0000 (06:28 +0000)
Running "lfs migrate <file>" without any SETSTRIPE arguments
to balance space usage keeps the PFL file layout, but preserves
the OST selection exactly, which makes the migration virtually
useless for space balancing.

This patch fixes the above issue by clearing the specific
OST indices from the source layout before using the layout to
create the volatile file in lfs_migrate().

Signed-off-by: Jian Yu <yujian@whamcloud.com>
Change-Id: I82e1dc0a11fdda7d555df994cf4e5f6e3dbdcb5c
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/49819
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Zhenyu Xu <bobijam@hotmail.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/tests/sanity.sh
lustre/tests/test-framework.sh
lustre/utils/lfs.c

index f7d0741..63b36ac 100755 (executable)
@@ -7948,8 +7948,8 @@ test_56xd() {
        # 2. test option --copy
        $LFS_MIGRATE -y --copy $f_copy $f_mgrt ||
                error "cannot migrate $f_mgrt with --copy $f_copy"
-       layout_before=$(get_layout_param $f_copy)
-       layout_after=$(get_layout_param $f_mgrt)
+       layout_before=$(SKIP_INDEX=yes get_layout_param $f_copy)
+       layout_after=$(SKIP_INDEX=yes get_layout_param $f_mgrt)
        [ "$layout_after" == "$layout_before" ] ||
                error "lfs_migrate --copy: $layout_after != $layout_before"
 }
@@ -7967,18 +7967,18 @@ test_56xe() {
        test_mkdir "$dir" || error "cannot create dir $dir"
        $LFS setstripe $layout $f_comp ||
                error "cannot setstripe $f_comp with layout $layout"
-       layout_before=$(get_layout_param $f_comp)
+       layout_before=$(SKIP_INDEX=yes get_layout_param $f_comp)
        dd if=/dev/zero of=$f_comp bs=1M count=4
 
        # 1. migrate a comp layout file by lfs_migrate
        $LFS_MIGRATE -y $f_comp || error "cannot migrate $f_comp by lfs_migrate"
-       layout_after=$(get_layout_param $f_comp)
+       layout_after=$(SKIP_INDEX=yes get_layout_param $f_comp)
        [ "$layout_before" == "$layout_after" ] ||
                error "lfs_migrate: $layout_before != $layout_after"
 
        # 2. migrate a comp layout file by lfs migrate
        $LFS migrate $f_comp || error "cannot migrate $f_comp by lfs migrate"
-       layout_after=$(get_layout_param $f_comp)
+       layout_after=$(SKIP_INDEX=yes get_layout_param $f_comp)
        [ "$layout_before" == "$layout_after" ] ||
                error "lfs migrate: $layout_before != $layout_after"
 }
index 64d7f3d..6132d80 100755 (executable)
@@ -9737,7 +9737,7 @@ parse_plain_param()
                echo "-c $val"
        elif [[ $line =~ ^"lmm_stripe_size:" ]]; then
                echo "-S $val"
-       elif [[ $line =~ ^"lmm_stripe_offset:" ]]; then
+       elif [[ $line =~ ^"lmm_stripe_offset:" && $SKIP_INDEX != yes ]]; then
                echo "-i $val"
        elif [[ $line =~ ^"lmm_pattern:" ]]; then
                echo "-L $val"
index 3a749bc..999e635 100644 (file)
@@ -4511,6 +4511,22 @@ static int lfs_setstripe_internal(int argc, char **argv,
                if (migrate_mdt_mode) {
                        result = llapi_migrate_mdt(fname, &migrate_mdt_param);
                } else if (migrate_mode) {
+                       if (from_copy) {
+                               /*
+                                * Strip the source layout of specific
+                                * OST object/index values.
+                                */
+                               result = llapi_layout_ost_index_set(layout, 0,
+                                               LLAPI_LAYOUT_DEFAULT);
+                               if (result) {
+                                       fprintf(stderr,
+                                               "%s: set default ost index failed: %s\n",
+                                               progname, strerror(errno));
+                                       result = -errno;
+                                       goto error;
+                               }
+                       }
+
                        result = lfs_migrate(fname, migration_flags, param,
                                             layout, bandwidth_bytes_sec,
                                             stats_flag, stats_interval_sec);