diff mbox series

btrfs: record orig_physical only for the original bio

Message ID 20230609052704.329148-1-hch@lst.de (mailing list archive)
State New, archived
Headers show
Series btrfs: record orig_physical only for the original bio | expand

Commit Message

Christoph Hellwig June 9, 2023, 5:27 a.m. UTC
btrfs_submit_dev_bio is also called for clone bios that aren't embeeded
into a btrfs_bio structure, but commit 177b0eb2c180 ("btrfs: optimize the
logical to physical mapping for zoned writes") added code to assign
btrfs_bio.orig_physical in it.  This is harmless right now as only the
single data profile can be used on zoned devices, but will blow up when
the RAID stripe tree is added.  Move it out into the single I/O specific
branch in the caller.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/btrfs/bio.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

David Sterba June 12, 2023, 2:13 p.m. UTC | #1
On Fri, Jun 09, 2023 at 07:27:04AM +0200, Christoph Hellwig wrote:
> btrfs_submit_dev_bio is also called for clone bios that aren't embeeded
> into a btrfs_bio structure, but commit 177b0eb2c180 ("btrfs: optimize the
> logical to physical mapping for zoned writes") added code to assign
> btrfs_bio.orig_physical in it.  This is harmless right now as only the
> single data profile can be used on zoned devices, but will blow up when
> the RAID stripe tree is added.  Move it out into the single I/O specific
> branch in the caller.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

This is another fixup to the patch ("btrfs: optimize the
logical to physical mapping for zoned writes") but as this is harmless I
haven't folded it to it but rather reordered right after it. It's better
to have the change explained separately. Added to misc-next, thanks.
diff mbox series

Patch

diff --git a/fs/btrfs/bio.c b/fs/btrfs/bio.c
index 8c30febc46ef8f..12b12443efaabb 100644
--- a/fs/btrfs/bio.c
+++ b/fs/btrfs/bio.c
@@ -455,7 +455,6 @@  static void btrfs_submit_dev_bio(struct btrfs_device *dev, struct bio *bio)
 		u64 zone_start = round_down(physical, dev->fs_info->zone_size);
 
 		ASSERT(btrfs_dev_is_sequential(dev, physical));
-		btrfs_bio(bio)->orig_physical = physical;
 		bio->bi_iter.bi_sector = zone_start >> SECTOR_SHIFT;
 	}
 	btrfs_debug_in_rcu(dev->fs_info,
@@ -501,6 +500,8 @@  static void __btrfs_submit_bio(struct bio *bio, struct btrfs_io_context *bioc,
 		/* Single mirror read/write fast path. */
 		btrfs_bio(bio)->mirror_num = mirror_num;
 		bio->bi_iter.bi_sector = smap->physical >> SECTOR_SHIFT;
+		if (bio_op(bio) != REQ_OP_READ)
+			btrfs_bio(bio)->orig_physical = smap->physical;
 		bio->bi_private = smap->dev;
 		bio->bi_end_io = btrfs_simple_end_io;
 		btrfs_submit_dev_bio(smap->dev, bio);