]> www.infradead.org Git - users/hch/xfstests-dev.git/commit
btrfs/276: make test accurate regarding number of expected extents
authorFilipe Manana <fdmanana@suse.com>
Thu, 3 Aug 2023 11:37:46 +0000 (12:37 +0100)
committerZorro Lang <zlang@kernel.org>
Fri, 4 Aug 2023 16:15:42 +0000 (00:15 +0800)
commit24cfe625794ea0c807d0739291f0a9ce7ddd5a2b
treec0454c7abadcc36125b5df0c6d955f2de49167f8
parent3f86deef7cbd1cf9e4fe6cafc9fb535d038ce010
btrfs/276: make test accurate regarding number of expected extents

btrfs/276 creates a 16G file with compression enabled in order to quickly
and efficiently create a file with many extents and have a fs tree with a
height of 3 (root node at level 2), so that it can test that fiemap is
correctly reporting extent sharedness when we have shared subtrees of the
fs tree due to a snapshot.

Compression results in extents with a maximum size of 128K and the test
is expecting only extents of 128K, which normally happens if the machine
has a large amount of RAM and writeback is not triggered before the xfs_io
command finishes. However if writeback is triggered in the meanwhile, due
to memory pressure for example, then we can get end up with some extents
that are smaller than 128K, therefore increasing the total number of
extents in the test file and make the test fail.

This seems to happen often on test machines with small amounts of RAM,
such as 4G, as reported by Qu in the following thread:

  https://lore.kernel.org/linux-btrfs/20230801065529.50122-1-wqu@suse.com/

So to address this create a file with holes and direct IO to make sure we
always get a specific number of extents in the test file. To speedup the
test create 2000 64K extents, with holes in between them, so that it works
on a fs with any sector size, and then create a bunch of files with large
xattrs to quickly bump the fs tree height to 3 for any node size (4K to
64K). This also guarantees that the file extent items are spread over
multiples leaves, in order to exercise fiemap's correctness when reporting
shared extents due to shared subtrees.

Reported-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Tested-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
tests/btrfs/276
tests/btrfs/276.out