Commit 34a2cf3f authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

bcache: move calculation of stripe_size and io_opt into bcache_device_init

bcache currently calculates the stripe size for the non-cached_dev
case directly in bcache_device_init, but for the cached_dev case it does
it in the caller.  Consolidate it in one places, which also enables
setting the io_opt queue_limit before allocating the gendisk so that it
can be passed in instead of changing the limit just after the allocation.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarColy Li <colyli@suse.de>
Link: https://lore.kernel.org/r/20240226104826.283067-2-hch@lst.deSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 0e46064e
...@@ -913,6 +913,10 @@ static int bcache_device_init(struct bcache_device *d, unsigned int block_size, ...@@ -913,6 +913,10 @@ static int bcache_device_init(struct bcache_device *d, unsigned int block_size,
uint64_t n; uint64_t n;
int idx; int idx;
if (cached_bdev) {
d->stripe_size = bdev_io_opt(cached_bdev) >> SECTOR_SHIFT;
lim.io_opt = umax(block_size, bdev_io_opt(cached_bdev));
}
if (!d->stripe_size) if (!d->stripe_size)
d->stripe_size = 1 << 31; d->stripe_size = 1 << 31;
else if (d->stripe_size < BCH_MIN_STRIPE_SZ) else if (d->stripe_size < BCH_MIN_STRIPE_SZ)
...@@ -1418,9 +1422,7 @@ static int cached_dev_init(struct cached_dev *dc, unsigned int block_size) ...@@ -1418,9 +1422,7 @@ static int cached_dev_init(struct cached_dev *dc, unsigned int block_size)
hlist_add_head(&io->hash, dc->io_hash + RECENT_IO); hlist_add_head(&io->hash, dc->io_hash + RECENT_IO);
} }
dc->disk.stripe_size = q->limits.io_opt >> 9; if (bdev_io_opt(dc->bdev))
if (dc->disk.stripe_size)
dc->partial_stripes_expensive = dc->partial_stripes_expensive =
q->limits.raid_partial_stripes_expensive; q->limits.raid_partial_stripes_expensive;
...@@ -1430,9 +1432,6 @@ static int cached_dev_init(struct cached_dev *dc, unsigned int block_size) ...@@ -1430,9 +1432,6 @@ static int cached_dev_init(struct cached_dev *dc, unsigned int block_size)
if (ret) if (ret)
return ret; return ret;
blk_queue_io_opt(dc->disk.disk->queue,
max(queue_io_opt(dc->disk.disk->queue), queue_io_opt(q)));
atomic_set(&dc->io_errors, 0); atomic_set(&dc->io_errors, 0);
dc->io_disable = false; dc->io_disable = false;
dc->error_limit = DEFAULT_CACHED_DEV_ERROR_LIMIT; dc->error_limit = DEFAULT_CACHED_DEV_ERROR_LIMIT;
......
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