Skip to content

Commit 34a2cf3

Browse files
Christoph Hellwigaxboe
authored andcommitted
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: Christoph Hellwig <[email protected]> Reviewed-by: Coly Li <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 0e46064 commit 34a2cf3

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

drivers/md/bcache/super.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,10 @@ static int bcache_device_init(struct bcache_device *d, unsigned int block_size,
913913
uint64_t n;
914914
int idx;
915915

916+
if (cached_bdev) {
917+
d->stripe_size = bdev_io_opt(cached_bdev) >> SECTOR_SHIFT;
918+
lim.io_opt = umax(block_size, bdev_io_opt(cached_bdev));
919+
}
916920
if (!d->stripe_size)
917921
d->stripe_size = 1 << 31;
918922
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)
14181422
hlist_add_head(&io->hash, dc->io_hash + RECENT_IO);
14191423
}
14201424

1421-
dc->disk.stripe_size = q->limits.io_opt >> 9;
1422-
1423-
if (dc->disk.stripe_size)
1425+
if (bdev_io_opt(dc->bdev))
14241426
dc->partial_stripes_expensive =
14251427
q->limits.raid_partial_stripes_expensive;
14261428

@@ -1430,9 +1432,6 @@ static int cached_dev_init(struct cached_dev *dc, unsigned int block_size)
14301432
if (ret)
14311433
return ret;
14321434

1433-
blk_queue_io_opt(dc->disk.disk->queue,
1434-
max(queue_io_opt(dc->disk.disk->queue), queue_io_opt(q)));
1435-
14361435
atomic_set(&dc->io_errors, 0);
14371436
dc->io_disable = false;
14381437
dc->error_limit = DEFAULT_CACHED_DEV_ERROR_LIMIT;

0 commit comments

Comments
 (0)