Remove the pointless goto just to return err and clean up the code flow to be a little more straight forward. Signed-off-by: Christoph Hellwig <hch@xxxxxx> --- fs/btrfs/inode.c | 59 ++++++++++++++++++++++-------------------------- 1 file changed, 27 insertions(+), 32 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index a54b7fd4658d0..5c9d8e8a98466 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -7844,47 +7844,42 @@ static inline blk_status_t btrfs_submit_dio_bio(struct bio *bio, struct inode *inode, u64 file_offset, int async_submit) { struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); + struct btrfs_inode *bi = BTRFS_I(inode); struct btrfs_dio_private *dip = bio->bi_private; - bool write = btrfs_op(bio) == BTRFS_MAP_WRITE; blk_status_t ret; - /* Check btrfs_submit_bio_hook() for rules about async submit. */ - if (async_submit) - async_submit = !atomic_read(&BTRFS_I(inode)->sync_writers); + if (btrfs_op(bio) == BTRFS_MAP_WRITE) { + if (!(bi->flags & BTRFS_INODE_NODATASUM)) { + /* See btrfs_submit_data_bio for async submit rules */ + if (async_submit && !atomic_read(&bi->sync_writers)) + return btrfs_wq_submit_bio(inode, bio, 0, 0, + file_offset, + btrfs_submit_bio_start_direct_io); - if (!write) { + /* + * If we aren't doing async submit, calculate the csum of the + * bio now. + */ + ret = btrfs_csum_one_bio(bi, bio, file_offset, 1); + if (ret) + return ret; + } + } else { ret = btrfs_bio_wq_end_io(fs_info, bio, BTRFS_WQ_ENDIO_DATA); if (ret) - goto err; - } - - if (BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM) - goto map; + return ret; - if (write && async_submit) { - ret = btrfs_wq_submit_bio(inode, bio, 0, 0, file_offset, - btrfs_submit_bio_start_direct_io); - goto err; - } else if (write) { - /* - * If we aren't doing async submit, calculate the csum of the - * bio now. - */ - ret = btrfs_csum_one_bio(BTRFS_I(inode), bio, file_offset, 1); - if (ret) - goto err; - } else { - u64 csum_offset; + if (!(bi->flags & BTRFS_INODE_NODATASUM)) { + u64 csum_offset; - csum_offset = file_offset - dip->file_offset; - csum_offset >>= fs_info->sectorsize_bits; - csum_offset *= fs_info->csum_size; - btrfs_bio(bio)->csum = dip->csums + csum_offset; + csum_offset = file_offset - dip->file_offset; + csum_offset >>= fs_info->sectorsize_bits; + csum_offset *= fs_info->csum_size; + btrfs_bio(bio)->csum = dip->csums + csum_offset; + } } -map: - ret = btrfs_map_bio(fs_info, bio, 0); -err: - return ret; + + return btrfs_map_bio(fs_info, bio, 0); } /* -- 2.30.2