Whamcloud - gitweb
LU-17013 lov: fill FIEMAP_EXTENT_LAST flag 94/52494/5
authorLei Feng <flei@whamcloud.com>
Thu, 3 Aug 2023 09:44:15 +0000 (17:44 +0800)
committerOleg Drokin <green@whamcloud.com>
Sun, 16 Jun 2024 03:35:51 +0000 (03:35 +0000)
If file has N extents and get the fiemap with exactly N
extent slots, the last extent will miss FIEMAP_EXTENT_LAST
flag. Fix it.

Lustre-change: https://review.whamcloud.com/51863
Lustre-commit: b1739ba3fadcc7cf0f330f6984bd51d3d801247d

Signed-off-by: Lei Feng <flei@whamcloud.com>
Test-Parameters: testlist=sanityn env=ONLY="71a 71b 71c"
Change-Id: I4556b31f0d04bdf8e83f323e83b871b093beaa5e
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Zhenyu Xu <bobijam@hotmail.com>
Signed-off-by: Etienne AUJAMES <eaujames@ddn.com>
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/52494
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/lov/lov_object.c
lustre/tests/sanityn.sh

index db3c284..37bfaee 100644 (file)
@@ -2124,7 +2124,8 @@ finish:
                cur_ext = 0;
 
        /* done all the processing */
-       if (entry > end_entry)
+       if (entry > end_entry ||
+           (fs.fs_enough && fs.fs_finish_stripe && entry == end_entry))
                fiemap->fm_extents[cur_ext].fe_flags |= FIEMAP_EXTENT_LAST;
 
        /* Indicate that we are returning device offsets unless file just has
index e7aaa9b..2c8b7ab 100755 (executable)
@@ -3607,6 +3607,47 @@ test_71b() {
 }
 run_test 71b "check fiemap support for stripecount > 1"
 
+_check_last_flag_with_filefrag()
+{
+       local file=$1
+       local count=$2
+       local i
+       local offset
+
+       echo "check last flag for file with $count extents"
+       rm -f $file
+       for ((i=0; i<$count; i++)); do
+               offset=$((i * 256))
+               dd if=/dev/zero of=$file bs=4K count=1 seek=$offset 2> /dev/null
+       done
+
+       filefrag -s -v $file | grep "last" ||
+               error "test file with $i extents failed"
+
+       rm -f $file
+}
+
+test_71c() {
+       local file="$DIR1/$tdir/$tfile"
+
+       (( $CLIENT_VERSION >= $(version_code 2.15.3) )) ||
+               skip "Need client version >= 2.15.3"
+       [ $(facet_fstype ost1) = "ldiskfs" ] ||
+               skip "support only ldiskfs ost"
+       filefrag -V | grep wc ||
+               skip "need whamcloud version of e2fsprogs"
+
+       mkdir -p $DIR1/$tdir
+
+       # filefrag uses u64[2028] buffer to fetch fiemap. The number of extents
+       # in the buffer is (8 * 2048 - 32) / 56 = 292. Test file with 291, 292
+       # and 293 extents
+       _check_last_flag_with_filefrag $file 291
+       _check_last_flag_with_filefrag $file 292
+       _check_last_flag_with_filefrag $file 293
+}
+run_test 71c "check FIEMAP_EXTENT_LAST flag with different extents number"
+
 test_72() {
        local p="$TMP/sanityN-$TESTNAME.parameters"
        local tlink1