]> git.ipfire.org Git - people/ms/linux.git/commit - fs/btrfs/zoned.c
btrfs: zoned: wait for extent buffer IOs before finishing a zone
authorNaohiro Aota <naohiro.aota@wdc.com>
Fri, 9 Sep 2022 06:59:55 +0000 (15:59 +0900)
committerDavid Sterba <dsterba@suse.com>
Tue, 13 Sep 2022 12:05:18 +0000 (14:05 +0200)
commit2dd7e7bc02829eded71be2342a93dc035f5223f9
tree6661bb52b0e28ef9df7495d6be04d337add83aa5
parenta362bb864b8db4861977d00bd2c3222503ccc34b
btrfs: zoned: wait for extent buffer IOs before finishing a zone

Before sending REQ_OP_ZONE_FINISH to a zone, we need to ensure that
ongoing IOs already finished. Or, we will see a "Zone Is Full" error for
the IOs, as the ZONE_FINISH command makes the zone full.

We ensure that with btrfs_wait_block_group_reservations() and
btrfs_wait_ordered_roots() for a data block group. And, for a metadata
block group, the comparison of alloc_offset vs meta_write_pointer mostly
ensures IOs for the allocated region already sent. However, there still
can be a little time frame where the IOs are sent but not yet completed.

Introduce wait_eb_writebacks() to ensure such IOs are completed for a
metadata block group. It walks the buffer_radix to find extent buffers in
the block group and calls wait_on_extent_buffer_writeback() on them.

Fixes: afba2bc036b0 ("btrfs: zoned: implement active zone tracking")
CC: stable@vger.kernel.org # 5.19+
Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/zoned.c