]> git.apps.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
generic/064: allow room for unexpected allocation behavior
authorEric Whitney <enwlinux@gmail.com>
Mon, 21 Sep 2015 01:05:26 +0000 (11:05 +1000)
committerDave Chinner <david@fromorbit.com>
Mon, 21 Sep 2015 01:05:26 +0000 (11:05 +1000)
Per Dave Chinner's suggestion, modify generic/064 so that it won't fail
if it finds a few more extents than it expects in its test file after
inserting ranges.  When 064's test file is first created, some file
systems may use more than the ideal minimum single extent to represent
it, and this can lead to a mismatch between the actual and expected
extent count after the ranges have been inserted.  Ext4 file systems
mounted with delayed allocation disabled can exhibit this behavior
if a test file's blocks happen to be allocated across regions of file
system metadata.

Also, replace the open coded counting of extents and holes with a
simpler call to _count_extents(), and clarify some comments.

Signed-off-by: Eric Whitney <enwlinux@gmail.com>
Reviewed-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
tests/generic/064 [changed mode: 0644->0755]
tests/generic/064.out

old mode 100644 (file)
new mode 100755 (executable)
index 760539a..d384a9a
@@ -2,9 +2,9 @@
 # FS QA Test No. generic/064
 #
 # Test multiple fallocate insert/collapse range calls on same file.
-# Call insert range a single alternate block multiple times until the file
-# is left with 100 extents and as much number of extents. And Call collapse
-# range about the previously inserted ranges to test merge code of collapse
+# Call insert range on alternate blocks multiple times until the file
+# is left with 50 extents and as many holes. Then call collapse range
+# on the previously inserted ranges to test merge code of collapse
 # range. Also check for data integrity and file system consistency.
 #-----------------------------------------------------------------------
 # Copyright (c) 2015 Samsung Electronics.  All Rights Reserved.
@@ -59,7 +59,7 @@ length=$(($BLOCKS * $BSIZE))
 # Write file
 _do "$XFS_IO_PROG -f -c \"pwrite 0 $length\" -c fsync $src"
 cp $src $dest
-extent_before=`$XFS_IO_PROG -c "fiemap -v" $dest | grep "^ *[0-9]*:" |wc -l`
+extent_before=`_count_extents $dest`
 
 # Insert alternate blocks
 for (( j=0; j < $(($BLOCKS/2)); j++ )); do
@@ -67,8 +67,10 @@ for (( j=0; j < $(($BLOCKS/2)); j++ )); do
        _do "$XFS_IO_PROG -c \"finsert $offset $BSIZE\" $dest"
 done
 
-# Check if 100 extents are present
-$XFS_IO_PROG -c "fiemap -v" $dest | grep "^ *[0-9]*:" |wc -l
+# Check if 50 extents are present, allowing some slop for file systems
+# that don't have ideal allocation behavior
+num_extents=`_count_extents $dest`
+_within_tolerance "Extent count after inserts" $num_extents 50 0 6% -v
 
 _check_scratch_fs
 if [ $? -ne 0 ]; then
@@ -82,7 +84,7 @@ for (( j=0; j < $(($BLOCKS/2)); j++ )); do
        _do "$XFS_IO_PROG -c \"fcollapse $offset $BSIZE\" $dest"
 done
 
-extent_after=`$XFS_IO_PROG -c "fiemap -v" $dest | grep "^ *[0-9]*:" |wc -l`
+extent_after=`_count_extents $dest`
 if [ $extent_before -ne $extent_after ]; then
        echo "extents mismatched before = $extent_before after = $extent_after"
 fi
index b217df5626c02d37d21eae676526fea8ae2ccf60..329e447e92dee48de36111c7175b0c292cbf564b 100644 (file)
@@ -1,2 +1,2 @@
 QA output created by 064
-100
+Extent count after inserts is in range