Commit 37899117 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by David Sterba

btrfs: do not return errors from btrfs_submit_dio_bio

Always consume the bio and call the end_io handler on error instead of
returning an error and letting the caller handle it.  This matches what
the block layer submission and the other btrfs bio submission handlers do
and avoids any confusion on who needs to handle errors.
Reviewed-by: default avatarNikolay Borisov <nborisov@suse.com>
Tested-by: default avatarNikolay Borisov <nborisov@suse.com>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent ea1f0ced
...@@ -8014,8 +8014,8 @@ static void btrfs_end_dio_bio(struct bio *bio) ...@@ -8014,8 +8014,8 @@ static void btrfs_end_dio_bio(struct bio *bio)
btrfs_dio_private_put(dip); btrfs_dio_private_put(dip);
} }
static inline blk_status_t btrfs_submit_dio_bio(struct bio *bio, static void btrfs_submit_dio_bio(struct bio *bio, struct inode *inode,
struct inode *inode, u64 file_offset, int async_submit) u64 file_offset, int async_submit)
{ {
struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
struct btrfs_dio_private *dip = bio->bi_private; struct btrfs_dio_private *dip = bio->bi_private;
...@@ -8029,22 +8029,24 @@ static inline blk_status_t btrfs_submit_dio_bio(struct bio *bio, ...@@ -8029,22 +8029,24 @@ static inline blk_status_t btrfs_submit_dio_bio(struct bio *bio,
if (async_submit && !atomic_read(&BTRFS_I(inode)->sync_writers) && if (async_submit && !atomic_read(&BTRFS_I(inode)->sync_writers) &&
btrfs_wq_submit_bio(inode, bio, 0, file_offset, btrfs_wq_submit_bio(inode, bio, 0, file_offset,
btrfs_submit_bio_start_direct_io)) btrfs_submit_bio_start_direct_io))
return BLK_STS_OK; return;
/* /*
* If we aren't doing async submit, calculate the csum of the * If we aren't doing async submit, calculate the csum of the
* bio now. * bio now.
*/ */
ret = btrfs_csum_one_bio(BTRFS_I(inode), bio, file_offset, false); ret = btrfs_csum_one_bio(BTRFS_I(inode), bio, file_offset, false);
if (ret) if (ret) {
return ret; bio->bi_status = ret;
bio_endio(bio);
return;
}
} else { } else {
btrfs_bio(bio)->csum = btrfs_csum_ptr(fs_info, dip->csums, btrfs_bio(bio)->csum = btrfs_csum_ptr(fs_info, dip->csums,
file_offset - dip->file_offset); file_offset - dip->file_offset);
} }
map: map:
btrfs_submit_bio(fs_info, bio, 0); btrfs_submit_bio(fs_info, bio, 0);
return BLK_STS_OK;
} }
static void btrfs_submit_direct(const struct iomap_iter *iter, static void btrfs_submit_direct(const struct iomap_iter *iter,
...@@ -8157,14 +8159,7 @@ static void btrfs_submit_direct(const struct iomap_iter *iter, ...@@ -8157,14 +8159,7 @@ static void btrfs_submit_direct(const struct iomap_iter *iter,
async_submit = 1; async_submit = 1;
} }
status = btrfs_submit_dio_bio(bio, inode, file_offset, btrfs_submit_dio_bio(bio, inode, file_offset, async_submit);
async_submit);
if (status) {
bio_put(bio);
if (submit_len > 0)
refcount_dec(&dip->refs);
goto out_err_em;
}
dio_data->submitted += clone_len; dio_data->submitted += clone_len;
clone_offset += clone_len; clone_offset += clone_len;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment