summaryrefslogtreecommitdiff
path: root/tools/lib/python
diff options
context:
space:
mode:
authorFilipe Manana <fdmanana@suse.com>2026-10-15 15:55:55 +0100
committerDavid Sterba <dsterba@suse.com>2026-10-30 23:14:47 +0100
commit980fbbd041ac2538fdbe7cfda4253dfc28fdcad1 (patch)
tree0eb28332d2c1cd80cde4e1a808a3db63da1b3af5 /tools/lib/python
parent254e15591ee4590064e0c55285cdcb4f4519133c (diff)
btrfs: fix fiemap merging compressed extents
Compressed extents are never supposed to be merged by the fiemap code and reported as a single extent, as each extent's content comes from a different compression stream and has its own header and context. We currently rely on checking the logical and physical address adjacency to prevent merging compressed extents but that is broken. Consider the following reproducer which explains why the merging happens: $ cat test.sh #!/bin/bash DEV=/dev/sdi MNT=/mnt/sdi mkfs.btrfs -s 4K -f $DEV mount -o compress $DEV $MNT # Do a write that compresses to a single 4K extent and represents the # maximum compressed chunk size (128K). xfs_io -f -c "pwrite 0 128K" $MNT/foo # Sync to flush delalloc and allocate the 4K extent. sync -f $MNT # Now allocate a 124K extent in some other file, which will be adjacent # (to the right) of the 4K extent previously allocated. xfs_io -f -c "falloc 0 124K" $MNT/filler # Do another write to the main file at its current EOF that is # compressible and fits in a 4K extent. xfs_io -c "pwrite 128K 128K" $MNT/foo # Sync to flush delalloc and allocate the 4K extent. sync -f $MNT # Run fiemap which should report 2 encoded extents, each with a # logical size of 128K. xfs_io -c "fiemap -v" $MNT/foo umount $MNT Running this, fiemap will report a single extent: $ ./test.sh (...) /mnt/sdi/foo: EXT: FILE-OFFSET BLOCK-RANGE TOTAL FLAGS 0: [0..511]: 26624..27135 512 0x9 Fix this by never attempting to merge extents if the flags contain FIEMAP_EXTENT_ENCODED. Fixes: 4751832da990 ("btrfs: fiemap: Cache and merge fiemap extent before submit it to user") Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: Filipe Manana <fdmanana@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'tools/lib/python')
0 files changed, 0 insertions, 0 deletions