From: Jian Yu Date: Wed, 1 Feb 2023 07:11:56 +0000 (-0800) Subject: LU-16500 utils: set default ost index for lfs migrate X-Git-Tag: 2.15.54~1 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=0568f4ca253049d324956e3d89ece0cbd2ff2155;p=fs%2Flustre-release.git LU-16500 utils: set default ost index for lfs migrate Running "lfs migrate " 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 Change-Id: I82e1dc0a11fdda7d555df994cf4e5f6e3dbdcb5c Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/49819 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Zhenyu Xu Reviewed-by: Oleg Drokin --- diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index f7d0741..63b36ac 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -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" } diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh index 64d7f3d..6132d80 100755 --- a/lustre/tests/test-framework.sh +++ b/lustre/tests/test-framework.sh @@ -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" diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index 3a749bc..999e635 100644 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -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);