On 2024/2/12 21:44, David Sterba wrote:
On Mon, Feb 12, 2024 at 03:46:15PM +1030, Qu Wenruo wrote:
[BUG] There is a bug report that with zoned device and sectorsize is smaller than page size (aka, subpage), btrfs would crash with a very basic workload:
# getconfig PAGESIZE 16384 # mkfs.btrfs -f $dev -s 4k # mount $dev $mnt # $fsstress -w -n 8 -s 1707820327 -v -d $mnt # umount $mnt
The crash would look like this (with CONFIG_BTRFS_ASSERT enabled):
assertion failed: block_start != EXTENT_MAP_HOLE, in fs/btrfs/extent_io.c:1384
This is the same as what Josef fixed in https://github.com/btrfs/linux/commit/400bb013912dac637c7d6826407be580ea8ef9... "btrfs: don't drop extent_map for free space inode on write error" but not on zoned+subpage, is it really a different error you're fixing?
Yes, it's really a different bug.
Although the root cause is a little more complex, it has to be explained through the whole CAUSE section.
[...]
[WORKAROUND] A proper fix requires some big changes to delalloc workload, to allow extent_write_locked_range() to handle multiple different entries with the same @locked_page.
So for now, disable read-write support for subpage zoned btrfs.
The problem can only be solved if subpage btrfs can handle subpage compression, which need quite some work on the delalloc procedure for the @locked_page handling.
Ok, this on itself is a valid reason to disable the support.
But this reminds me that, I have to work on the proper delalloc support for subpage.
My current plan is:
1. Introduce subpage LOCK bitmap Not just only an atomic counter.
2. Make find_lock_delalloc_range() to populate that lock bitmap
3. Make find_lock_delalloc_range() to find all delalloc range of a page and properly lock them This would not change the behavior for page sized sectorsize.
4. Make find_lock_delalloc_range() to skip the page if it's already being locked before. This is also a subpage specific behavior
With above planned work, btrfs should be able to handle subpage unlock, so that we won't need weird @locked_page handling.
Hopefully this would solve both the subpage+zoned and full sector aligned subpage compression support.
Thanks, Qu