diff mbox series

[03/40] btrfs: fix direct I/O writes for split bios on zoned devices

Message ID 20220322155606.1267165-4-hch@lst.de (mailing list archive)
State New, archived
Headers show
Series [01/40] btrfs: fix submission hook error handling in btrfs_repair_one_sector | expand

Commit Message

Christoph Hellwig March 22, 2022, 3:55 p.m. UTC
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
icorrect for subsequent bios.

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

Comments

Qu Wenruo March 23, 2022, midnight UTC | #1
On 2022/3/22 23:55, Christoph Hellwig wrote:
> 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
> icorrect for subsequent bios.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Maybe better to be folded with previous patch?

It looks good to me though.

Reviewed-by: Qu Wenruo <wqu@suse.com>

Thanks,
Qu
> ---
>   fs/btrfs/inode.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index 93f00e9150ed0..325e773c6e880 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -7829,6 +7829,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)
> @@ -7839,12 +7840,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);
Christoph Hellwig March 23, 2022, 6:04 a.m. UTC | #2
On Wed, Mar 23, 2022 at 08:00:48AM +0800, Qu Wenruo wrote:
>> 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
>> icorrect for subsequent bios.
>>
>> Signed-off-by: Christoph Hellwig <hch@lst.de>
>
> Maybe better to be folded with previous patch?

Well, it fixes a separate issue.
diff mbox series

Patch

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 93f00e9150ed0..325e773c6e880 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -7829,6 +7829,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)
@@ -7839,12 +7840,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);