Whamcloud - gitweb
LU-17013 lov: fill FIEMAP_EXTENT_LAST flag 63/51863/9
authorLei Feng <flei@whamcloud.com>
Thu, 3 Aug 2023 09:44:15 +0000 (17:44 +0800)
committerOleg Drokin <green@whamcloud.com>
Thu, 31 Aug 2023 06:37:39 +0000 (06:37 +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.

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

index 82673f3..1aeb6a8 100644 (file)
@@ -2188,7 +2188,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 fb77297..f7230e4 100755 (executable)
@@ -1464,7 +1464,7 @@ test_33d() {
                        touch $DIR/$tdir/d1/tgt" \
                        "ln $DIR2/$tdir/d1/tgt $DIR2/$tdir/d2/src"
        fi
-       
+
        op_trigger_cos "remote directory create" "$LFS mkdir -i 0 $DIR/$tdir" \
                "$LFS mkdir -i 1 $DIR2/$tdir/subdir"
        op_trigger_cos "cross-MDT rename" \
@@ -3858,6 +3858,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.57) )) ||
+               skip "Need client version >= 2.15.57"
+       [ $(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