Skip to content

Commit

Permalink
btrfs: fix direct I/O writes for split bios on zoned devices
Browse files Browse the repository at this point in the history
When a bio is split in btrfs_submit_direct, dip->file_offset contains
the file offset for the first bio.  But this means the start value used
in btrfs_end_dio_bio to record the write location for zone devices is
incorrect for subsequent bios.

CC: stable@vger.kernel.org # 5.16+
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Naohiro Aota <naohiro.aota@wdc.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David Sterba <dsterba@suse.com>
  • Loading branch information
Christoph Hellwig authored and David Sterba committed Apr 19, 2022
1 parent 00d8252 commit 0fdf977
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions fs/btrfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -7865,6 +7865,7 @@ static blk_status_t btrfs_submit_bio_start_direct_io(struct inode *inode,
static void btrfs_end_dio_bio(struct bio *bio)
{
struct btrfs_dio_private *dip = bio->bi_private;
struct btrfs_bio *bbio = btrfs_bio(bio);
blk_status_t err = bio->bi_status;

if (err)
Expand All @@ -7875,12 +7876,12 @@ static void btrfs_end_dio_bio(struct bio *bio)
bio->bi_iter.bi_size, err);

if (bio_op(bio) == REQ_OP_READ)
err = btrfs_check_read_dio_bio(dip, btrfs_bio(bio), !err);
err = btrfs_check_read_dio_bio(dip, bbio, !err);

if (err)
dip->dio_bio->bi_status = err;

btrfs_record_physical_zoned(dip->inode, dip->file_offset, bio);
btrfs_record_physical_zoned(dip->inode, bbio->file_offset, bio);

bio_put(bio);
btrfs_dio_private_put(dip);
Expand Down

0 comments on commit 0fdf977

Please sign in to comment.