]> www.infradead.org Git - users/hch/xfstests-dev.git/commitdiff
generic/032: fix unwritten extent checks
authorDarrick J. Wong <darrick.wong@oracle.com>
Wed, 20 Mar 2019 00:45:01 +0000 (17:45 -0700)
committerEryu Guan <guaneryu@gmail.com>
Sat, 23 Mar 2019 13:27:12 +0000 (21:27 +0800)
Fix the unwritten extent detector in this test to ignore post-eof
allocations because those are harmless.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
tests/generic/032

index affde4b79e999f35bb56d417f1c8141618c80ad2..38352a211ca16376142f8d05fd4dcf4f123a0b1f 100755 (executable)
@@ -69,18 +69,21 @@ do
 
        # preallocate the first 64k and overwite, writing past 64k to contend
        # with writeback
+       file_len=0x100000
        $XFS_IO_PROG \
                -c "falloc 0 0x10000"   \
-               -c "pwrite 0 0x100000"  \
+               -c "pwrite 0 $file_len" \
                -c "fsync"              \
                $SCRATCH_MNT/file >> $seqres.full 2>&1
 
-       # Check for unwritten extents. We should have none since we wrote over
-       # the entire preallocated region and ran fsync.
-       $XFS_IO_PROG -c "fiemap -v" $SCRATCH_MNT/file | \
-               tee -a $seqres.full | \
-               _filter_fiemap | grep unwritten
-       [ $? == 0 ] && _fail "Unwritten extents found!"
+       # Check for unwritten extents. We should have none before EOF since we
+       # wrote over the entire preallocated region and ran fsync.
+       eof_sector=$(( file_len / 512 ))
+       $XFS_IO_PROG -c 'fiemap -v' $SCRATCH_MNT/file | \
+               _filter_fiemap | \
+               tr '[.]:' '    ' | \
+               awk "{if (\$2 < $eof_sector) {print \$0}}" | \
+               grep -q unwritten && _fail "Unwritten extents found!"
 done
 
 echo $iters iterations