btrfs: defer splitting of ordered extents until I/O completion
authorChristoph Hellwig <hch@lst.de>
Wed, 24 May 2023 15:03:16 +0000 (17:03 +0200)
committerDavid Sterba <dsterba@suse.com>
Mon, 19 Jun 2023 11:59:33 +0000 (13:59 +0200)
commit71df088c1cc090d232eb691d8f42284a2c6409eb
treeb2059ca30e4abf09ef53cf1e40d789a2c6566d14
parent52b1fdca23ac0fbcad363a1a5b426bf0d56b715a
btrfs: defer splitting of ordered extents until I/O completion

The btrfs zoned completion code currently needs an ordered_extent and
extent_map per bio so that it can account for the non-predictable
write location from Zone Append.  To archive that it currently splits
the ordered_extent and extent_map at I/O submission time, and then
records the actual physical address in the ->physical field of the
ordered_extent.

This patch instead switches to record the "original" physical address
that the btrfs allocator assigned in spare space in the btrfs_bio,
and then rewrites the logical address in the btrfs_ordered_sum
structure at I/O completion time.  This allows the ordered extent
completion handler to simply walk the list of ordered csums and
split the ordered extent as needed.  This removes an extra ordered
extent and extent_map lookup and manipulation during the I/O
submission path, and instead batches it in the I/O completion path
where we need to touch these anyway.

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/bio.c
fs/btrfs/btrfs_inode.h
fs/btrfs/inode.c
fs/btrfs/ordered-data.h
fs/btrfs/zoned.c
fs/btrfs/zoned.h