[PATCH v2 3/4] btrfs/137: Make this test compatible with all supported block sizes

Nirjhar Roy (IBM)
2025-08-19T12:02:15Z

For large block sizes like 64k it failed simply because this
test was written with 4k block size in mind.
The first few lines of the error logs are as follows:

d3dc847171f9081bd75d7a2d3b53d322 SCRATCH_MNT/snap2/bar

File snap1/foo fiemap results in the original filesystem:
-0: [0..7]: data
+0: [0..127]: data

File snap1/bar fiemap results in the original filesystem:
...

Fix this by making the test choose offsets and block size as 64k
which is aligned with all the underlying supported fs block sizes.

Reported-by: Disha Goel <disgoel@linux.ibm.com>
Signed-off-by: Nirjhar Roy (IBM) <nirjhar.roy.lists@gmail.com>
---
tests/btrfs/137 | 11 ++++----
tests/btrfs/137.out | 66 ++++++++++++++++++++++-----------------------
2 files changed, 39 insertions(+), 38 deletions(-)

diff --git a/tests/btrfs/137 b/tests/btrfs/137
index 7710dc18..c1d498bd 100755
--- a/tests/btrfs/137
+++ b/tests/btrfs/137
@@ -23,6 +23,7 @@ _cleanup()
_require_test
_require_scratch
_require_xfs_io_command "fiemap"
+_require_btrfs_no_compress

send_files_dir=$TEST_DIR/btrfs-test-$seq

@@ -33,12 +34,12 @@ _scratch_mkfs >>$seqres.full 2>&1
_scratch_mount

# Create the first test file.
-$XFS_IO_PROG -f -c "pwrite -S 0xaa 0 4K" $SCRATCH_MNT/foo | _filter_xfs_io
+$XFS_IO_PROG -f -c "pwrite -S 0xaa -b 64k 0 64K" $SCRATCH_MNT/foo | _filter_xfs_io

# Create a second test file with a 1Mb hole.
$XFS_IO_PROG -f \
- -c "pwrite -S 0xaa 0 4K" \
- -c "pwrite -S 0xbb 1028K 4K" \
+ -c "pwrite -S 0xaa -b 64k 0 64K" \
+ -c "pwrite -S 0xbb -b 64k 1088K 64K" \
$SCRATCH_MNT/bar | _filter_xfs_io

$BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT \
@@ -46,10 +47,10 @@ $BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT \

# Now add one new extent to our first test file, increasing its size and leaving
# a 1Mb hole between the first extent and this new extent.
-$XFS_IO_PROG -c "pwrite -S 0xbb 1028K 4K" $SCRATCH_MNT/foo | _filter_xfs_io
+$XFS_IO_PROG -c "pwrite -S 0xbb -b 64k 1088K 64K" $SCRATCH_MNT/foo | _filter_xfs_io

# Now overwrite the last extent of our second test file.
-$XFS_IO_PROG -c "pwrite -S 0xcc 1028K 4K" $SCRATCH_MNT/bar | _filter_xfs_io
+$XFS_IO_PROG -c "pwrite -S 0xcc -b 64k 1088K 64K" $SCRATCH_MNT/bar | _filter_xfs_io

$BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT \
$SCRATCH_MNT/snap2 >/dev/null
diff --git a/tests/btrfs/137.out b/tests/btrfs/137.out
index 8554399f..e863dd51 100644
--- a/tests/btrfs/137.out
+++ b/tests/btrfs/137.out
@@ -1,63 +1,63 @@
QA output created by 137
-wrote 4096/4096 bytes at offset 0
+wrote 65536/65536 bytes at offset 0
XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-wrote 4096/4096 bytes at offset 0
+wrote 65536/65536 bytes at offset 0
XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-wrote 4096/4096 bytes at offset 1052672
+wrote 65536/65536 bytes at offset 1114112
XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-wrote 4096/4096 bytes at offset 1052672
+wrote 65536/65536 bytes at offset 1114112
XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-wrote 4096/4096 bytes at offset 1052672
+wrote 65536/65536 bytes at offset 1114112
XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)

File digests in the original filesystem:
-3e4309c7cc81f23d45e260a8f13ca860 SCRATCH_MNT/snap1/foo
-f3934f0cf164e2efa1bab71f2f164990 SCRATCH_MNT/snap1/bar
-f3934f0cf164e2efa1bab71f2f164990 SCRATCH_MNT/snap2/foo
-d3dc847171f9081bd75d7a2d3b53d322 SCRATCH_MNT/snap2/bar
+9802287a6faa01a1fd0e01732b732fca SCRATCH_MNT/snap1/foo
+fe93f68ad1d8d5e47feba666ee6d3c47 SCRATCH_MNT/snap1/bar
+fe93f68ad1d8d5e47feba666ee6d3c47 SCRATCH_MNT/snap2/foo
+8d06f9b5841190b586a7526d0dd356f3 SCRATCH_MNT/snap2/bar

File snap1/foo fiemap results in the original filesystem:
-0: [0..7]: data
+0: [0..127]: data

File snap1/bar fiemap results in the original filesystem:
-0: [0..7]: data
-1: [8..2055]: hole
-2: [2056..2063]: data
+0: [0..127]: data
+1: [128..2175]: hole
+2: [2176..2303]: data

File snap2/foo fiemap results in the original filesystem:
-0: [0..7]: data
-1: [8..2055]: hole
-2: [2056..2063]: data
+0: [0..127]: data
+1: [128..2175]: hole
+2: [2176..2303]: data

File snap2/bar fiemap results in the original filesystem:
-0: [0..7]: data
-1: [8..2055]: hole
-2: [2056..2063]: data
+0: [0..127]: data
+1: [128..2175]: hole
+2: [2176..2303]: data

At subvol SCRATCH_MNT/snap1
At subvol SCRATCH_MNT/snap2
At subvol snap1

File digests in the new filesystem:
-3e4309c7cc81f23d45e260a8f13ca860 SCRATCH_MNT/snap1/foo
-f3934f0cf164e2efa1bab71f2f164990 SCRATCH_MNT/snap1/bar
-f3934f0cf164e2efa1bab71f2f164990 SCRATCH_MNT/snap2/foo
-d3dc847171f9081bd75d7a2d3b53d322 SCRATCH_MNT/snap2/bar
+9802287a6faa01a1fd0e01732b732fca SCRATCH_MNT/snap1/foo
+fe93f68ad1d8d5e47feba666ee6d3c47 SCRATCH_MNT/snap1/bar
+fe93f68ad1d8d5e47feba666ee6d3c47 SCRATCH_MNT/snap2/foo
+8d06f9b5841190b586a7526d0dd356f3 SCRATCH_MNT/snap2/bar

File snap1/foo fiemap results in the new filesystem:
-0: [0..7]: data
+0: [0..127]: data

File snap1/bar fiemap results in the new filesystem:
-0: [0..7]: data
-1: [8..2055]: hole
-2: [2056..2063]: data
+0: [0..127]: data
+1: [128..2175]: hole
+2: [2176..2303]: data

File snap2/foo fiemap results in the new filesystem:
-0: [0..7]: data
-1: [8..2055]: hole
-2: [2056..2063]: data
+0: [0..127]: data
+1: [128..2175]: hole
+2: [2176..2303]: data

File snap2/bar fiemap results in the new filesystem:
-0: [0..7]: data
-1: [8..2055]: hole
-2: [2056..2063]: data
+0: [0..127]: data
+1: [128..2175]: hole
+2: [2176..2303]: data
--
2.34.1