btrfs: use file_offset to limit bios size in calc_bio_boundaries
authorChristoph Hellwig <hch@lst.de>
Mon, 12 Dec 2022 07:37:18 +0000 (08:37 +0100)
committerDavid Sterba <dsterba@suse.com>
Wed, 15 Feb 2023 18:38:55 +0000 (19:38 +0100)
btrfs_ordered_extent->disk_bytenr can be rewritten by the zoned I/O
completion handler, and thus in general is not a good idea to limit I/O
size.  But the maximum bio size calculation can easily be done using the
file_offset fields in the btrfs_ordered_extent and btrfs_bio structures,
so switch to that instead.

Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/extent_io.c

index 287e25edb3ef4cea7832669968543b5da97c63e4..d823994cf62a806bee02d16ff5bbcf349436df92 100644 (file)
@@ -964,8 +964,8 @@ static void calc_bio_boundaries(struct btrfs_bio_ctrl *bio_ctrl,
                ordered = btrfs_lookup_ordered_extent(inode, file_offset);
                if (ordered) {
                        bio_ctrl->len_to_oe_boundary = min_t(u32, U32_MAX,
-                                       ordered->disk_bytenr +
-                                       ordered->disk_num_bytes - logical);
+                                       ordered->file_offset +
+                                       ordered->disk_num_bytes - file_offset);
                        btrfs_put_ordered_extent(ordered);
                        return;
                }