From: Patrick Farrell Date: Thu, 3 Apr 2025 22:16:46 +0000 (-0400) Subject: LU-18824 utils: Fix lfs migrate with --overstripe-count X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=c2b59218e5fba8ca5bcff8a1e01e2f1f2c668426;p=fs%2Flustre-release.git LU-18824 utils: Fix lfs migrate with --overstripe-count The --overstripe-count (-C) option was not being properly honored during file migration. When using lfs migrate with this option, the overstriping flag was set but the LLAPI_LAYOUT_OVERSTRIPING pattern was not applied to the destination file. This was because in lfs_setstripe_internal(), the code only set lsa.lsa_pattern = LLAPI_LAYOUT_OVERSTRIPING when not in migrate mode. Fix this by always setting the pattern when the overstriped flag is true, regardless of whether we're in migrate mode or not. Added a test case (27X) to verify that lfs migrate properly applies overstriping NB: This fix and test were generated and tested by the VS Code Augment Agent after being given the LU URL and some prompting. Signed-off-by: Patrick Farrell Change-Id: I734b9d4e3c699e335c9d810bba2e2d2a1c301ed6 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/58672 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin Reviewed-by: Marc Vef Reviewed-by: Andreas Dilger --- diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index e36a1cd..ceb3219 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -3731,6 +3731,35 @@ test_27W() { } run_test 27W "test enable_setstripe_gid" +test_27X() { + [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] || + skip "server does not support overstriping" + + local file=$DIR/$tfile + local count + local overstripe_count=$((OSTCOUNT * 2)) + + # Create a small file + dd if=/dev/zero of=$file bs=1K count=1 || error "dd failed" + + # Migrate with --overstripe-count=2*OSTCOUNT + $LFS migrate --overstripe-count=$overstripe_count $file || + error "migrate failed" + + # Check that the stripe count is 2*OSTCOUNT + count=$($LFS getstripe -c $file) + [ $count -eq $overstripe_count ] || + error "stripe count is $count, expected $overstripe_count" + + # Check that the file has the overstriping flag set + $LFS getstripe $file | grep -q "overstriped" || + error "overstriping flag not set" + + # Clean up + rm -f $file +} +run_test 27X "lfs migrate honors --overstripe-count option" + # createtest also checks that device nodes are created and # then visible correctly (#2091) test_28() { # bug 2091 diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index 7ef588b..d97df53 100644 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -4096,8 +4096,7 @@ static int lfs_setstripe_internal(int argc, char **argv, goto usage_error; } overstriped = true; - if (!migrate_mode) - lsa.lsa_pattern = LLAPI_LAYOUT_OVERSTRIPING; + lsa.lsa_pattern = LLAPI_LAYOUT_OVERSTRIPING; fallthrough; case 'c': errno = 0;