Re: [PATCH] btrfs: zoned: limit ordered extent to zoned append size
From: Damien Le Moal <hidden>
Date: 2021-05-21 09:46:53
On 2021/05/21 18:11, Johannes Thumshirn wrote:
Damien reported a test failure with btrfs/209. The test itself ran fine,
but the fsck run afterwards reported a corrupted filesystem.
The filesystem corruption happens because we're splitting an extent and
then writing the extent twice. We have to split the extent though, because
we're creating too large extents for a REQ_OP_ZONE_APPEND operation.
When dumping the extent tree, we can see two EXTENT_ITEMs at the same
start address but different lengths.
$ btrfs inspect dump-tree /dev/nullb1 -t extent
...
item 19 key (269484032 EXTENT_ITEM 126976) itemoff 15470 itemsize 53
refs 1 gen 7 flags DATA
extent data backref root FS_TREE objectid 257 offset 786432 count 1
item 20 key (269484032 EXTENT_ITEM 262144) itemoff 15417 itemsize 53
refs 1 gen 7 flags DATA
extent data backref root FS_TREE objectid 257 offset 786432 count 1
On a zoned filesystem, limit the size of an ordered extent to the maximum
size that can be issued as a single REQ_OP_ZONE_APPEND operation.
Note: This patch breaks fstests btrfs/079, as it increases the number of
on-disk extents from 80 to 83 per 10M write.Can this test case be fixed by calculating the number of extents that will be written using sysfs zone_append_max_bytes ? That would avoid hard-coding a value for the zoned case...
quoted hunk ↗ jump to hunk
Reported-by: Damien Le Moal <redacted> Signed-off-by: Johannes Thumshirn <redacted> --- fs/btrfs/extent_io.c | 4 ++++ 1 file changed, 4 insertions(+)diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 78d3f2ec90e0..e823b2c74af5 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c@@ -1860,6 +1860,7 @@ noinline_for_stack bool find_lock_delalloc_range(struct inode *inode, u64 *end) { struct extent_io_tree *tree = &BTRFS_I(inode)->io_tree; + struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); u64 max_bytes = BTRFS_MAX_EXTENT_SIZE; u64 delalloc_start; u64 delalloc_end;@@ -1868,6 +1869,9 @@ noinline_for_stack bool find_lock_delalloc_range(struct inode *inode, int ret; int loops = 0; + if (fs_info && fs_info->max_zone_append_size) + max_bytes = ALIGN_DOWN(fs_info->max_zone_append_size, + PAGE_SIZE); again: /* step one, find a bunch of delalloc bytes starting at start */ delalloc_start = *start;
-- Damien Le Moal Western Digital Research