btrfs: optimize simple reads in btrfsic_map_block
Pass a smap into __btrfs_map_block so that the usual case of a read that doesn't require parity raid recovery doesn't need an extra memory allocation for the btrfs_io_context. Reviewed-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
3965a4c793
commit
78a213a05d
|
@ -1459,13 +1459,13 @@ static int btrfsic_map_block(struct btrfsic_state *state, u64 bytenr, u32 len,
|
|||
struct btrfs_fs_info *fs_info = state->fs_info;
|
||||
int ret;
|
||||
u64 length;
|
||||
struct btrfs_io_context *multi = NULL;
|
||||
struct btrfs_io_context *bioc = NULL;
|
||||
struct btrfs_io_stripe smap, *map;
|
||||
struct btrfs_device *device;
|
||||
|
||||
length = len;
|
||||
ret = btrfs_map_block(fs_info, BTRFS_MAP_READ,
|
||||
bytenr, &length, &multi, mirror_num);
|
||||
|
||||
ret = __btrfs_map_block(fs_info, BTRFS_MAP_READ, bytenr, &length, &bioc,
|
||||
NULL, &mirror_num, 0);
|
||||
if (ret) {
|
||||
block_ctx_out->start = 0;
|
||||
block_ctx_out->dev_bytenr = 0;
|
||||
|
@ -1478,21 +1478,26 @@ static int btrfsic_map_block(struct btrfsic_state *state, u64 bytenr, u32 len,
|
|||
return ret;
|
||||
}
|
||||
|
||||
device = multi->stripes[0].dev;
|
||||
if (bioc)
|
||||
map = &bioc->stripes[0];
|
||||
else
|
||||
map = &smap;
|
||||
|
||||
device = map->dev;
|
||||
if (test_bit(BTRFS_DEV_STATE_MISSING, &device->dev_state) ||
|
||||
!device->bdev || !device->name)
|
||||
block_ctx_out->dev = NULL;
|
||||
else
|
||||
block_ctx_out->dev = btrfsic_dev_state_lookup(
|
||||
device->bdev->bd_dev);
|
||||
block_ctx_out->dev_bytenr = multi->stripes[0].physical;
|
||||
block_ctx_out->dev_bytenr = map->physical;
|
||||
block_ctx_out->start = bytenr;
|
||||
block_ctx_out->len = len;
|
||||
block_ctx_out->datav = NULL;
|
||||
block_ctx_out->pagev = NULL;
|
||||
block_ctx_out->mem_to_free = NULL;
|
||||
|
||||
kfree(multi);
|
||||
kfree(bioc);
|
||||
if (NULL == block_ctx_out->dev) {
|
||||
ret = -ENXIO;
|
||||
pr_info("btrfsic: error, cannot lookup dev (#1)!\n");
|
||||
|
|
Loading…
Reference in New Issue