Whamcloud - gitweb
LU-18824 utils: Fix lfs migrate with --overstripe-count 72/58672/5
authorPatrick Farrell <pfarrell@whamcloud.com>
Thu, 3 Apr 2025 22:16:46 +0000 (18:16 -0400)
committerOleg Drokin <green@whamcloud.com>
Thu, 12 Jun 2025 06:34:58 +0000 (06:34 +0000)
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 <pfarrell@whamcloud.com>
Change-Id: I734b9d4e3c699e335c9d810bba2e2d2a1c301ed6
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/58672
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Reviewed-by: Marc Vef <mvef@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lustre/tests/sanity.sh
lustre/utils/lfs.c

index e36a1cd..ceb3219 100755 (executable)
@@ -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
index 7ef588b..d97df53 100644 (file)
@@ -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;