Commit 5fa35653 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by David Sterba

btrfs: remove the direct I/O read checksum lookup optimization

To prepare for pending changes drop the optimization to only look up
csums once per bio that is submitted from the iomap layer.  In the
short run this does cause additional lookups for fragmented direct
reads, but later in the series, the bio based lookup will be used on
the entire bio submitted from iomap, restoring the old behavior
in common code.
Reviewed-by: default avatarAnand Jain <anand.jain@oracle.com>
Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent d0e5cb2b
...@@ -100,9 +100,6 @@ struct btrfs_dio_private { ...@@ -100,9 +100,6 @@ struct btrfs_dio_private {
*/ */
refcount_t refs; refcount_t refs;
/* Array of checksums */
u8 *csums;
/* This must be last */ /* This must be last */
struct bio bio; struct bio bio;
}; };
...@@ -7907,7 +7904,6 @@ static void btrfs_dio_private_put(struct btrfs_dio_private *dip) ...@@ -7907,7 +7904,6 @@ static void btrfs_dio_private_put(struct btrfs_dio_private *dip)
dip->file_offset + dip->bytes - 1, NULL); dip->file_offset + dip->bytes - 1, NULL);
} }
kfree(dip->csums);
bio_endio(&dip->bio); bio_endio(&dip->bio);
} }
...@@ -7990,7 +7986,6 @@ static void btrfs_submit_dio_bio(struct bio *bio, struct btrfs_inode *inode, ...@@ -7990,7 +7986,6 @@ static void btrfs_submit_dio_bio(struct bio *bio, struct btrfs_inode *inode,
u64 file_offset, int async_submit) u64 file_offset, int async_submit)
{ {
struct btrfs_fs_info *fs_info = inode->root->fs_info; struct btrfs_fs_info *fs_info = inode->root->fs_info;
struct btrfs_dio_private *dip = btrfs_bio(bio)->private;
blk_status_t ret; blk_status_t ret;
/* Save the original iter for read repair */ /* Save the original iter for read repair */
...@@ -8017,8 +8012,11 @@ static void btrfs_submit_dio_bio(struct bio *bio, struct btrfs_inode *inode, ...@@ -8017,8 +8012,11 @@ static void btrfs_submit_dio_bio(struct bio *bio, struct btrfs_inode *inode,
return; return;
} }
} else { } else {
btrfs_bio(bio)->csum = btrfs_csum_ptr(fs_info, dip->csums, ret = btrfs_lookup_bio_sums(&inode->vfs_inode, bio, NULL);
file_offset - dip->file_offset); if (ret) {
btrfs_bio_end_io(btrfs_bio(bio), ret);
return;
}
} }
map: map:
btrfs_submit_bio(fs_info, bio, 0); btrfs_submit_bio(fs_info, bio, 0);
...@@ -8030,7 +8028,6 @@ static void btrfs_submit_direct(const struct iomap_iter *iter, ...@@ -8030,7 +8028,6 @@ static void btrfs_submit_direct(const struct iomap_iter *iter,
struct btrfs_dio_private *dip = struct btrfs_dio_private *dip =
container_of(dio_bio, struct btrfs_dio_private, bio); container_of(dio_bio, struct btrfs_dio_private, bio);
struct inode *inode = iter->inode; struct inode *inode = iter->inode;
const bool write = (btrfs_op(dio_bio) == BTRFS_MAP_WRITE);
struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
const bool raid56 = (btrfs_data_alloc_profile(fs_info) & const bool raid56 = (btrfs_data_alloc_profile(fs_info) &
BTRFS_BLOCK_GROUP_RAID56_MASK); BTRFS_BLOCK_GROUP_RAID56_MASK);
...@@ -8051,25 +8048,6 @@ static void btrfs_submit_direct(const struct iomap_iter *iter, ...@@ -8051,25 +8048,6 @@ static void btrfs_submit_direct(const struct iomap_iter *iter,
dip->file_offset = file_offset; dip->file_offset = file_offset;
dip->bytes = dio_bio->bi_iter.bi_size; dip->bytes = dio_bio->bi_iter.bi_size;
refcount_set(&dip->refs, 1); refcount_set(&dip->refs, 1);
dip->csums = NULL;
if (!write && !(BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM)) {
unsigned int nr_sectors =
(dio_bio->bi_iter.bi_size >> fs_info->sectorsize_bits);
/*
* Load the csums up front to reduce csum tree searches and
* contention when submitting bios.
*/
status = BLK_STS_RESOURCE;
dip->csums = kcalloc(nr_sectors, fs_info->csum_size, GFP_NOFS);
if (!dip->csums)
goto out_err;
status = btrfs_lookup_bio_sums(inode, dio_bio, dip->csums);
if (status != BLK_STS_OK)
goto out_err;
}
start_sector = dio_bio->bi_iter.bi_sector; start_sector = dio_bio->bi_iter.bi_sector;
submit_len = dio_bio->bi_iter.bi_size; submit_len = dio_bio->bi_iter.bi_size;
......
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