summaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorPavel Begunkov <asml.silence@gmail.com>2021-10-14 17:03:26 +0300
committerJens Axboe <axboe@kernel.dk>2021-10-18 15:17:36 +0300
commit17220ca5ce9606c1b015c4316fca18734c2df0bb (patch)
tree97ed1d00b00c850cc3f1cd08bf110418ccc0fd0b /block
parentabd45c159df5fcb7ac820e2825dac85de7c01c21 (diff)
downloadlinux-17220ca5ce9606c1b015c4316fca18734c2df0bb.tar.xz
block: cache request queue in bdev
There are tons of places where we need to get a request_queue only having bdev, which turns into bdev->bd_disk->queue. There are probably a hundred of such places considering inline helpers, and enough of them are in hot paths. Cache queue pointer in struct block_device and make use of it in bdev_get_queue(). Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Link: https://lore.kernel.org/r/a3bfaecdd28956f03629d0ca5c63ebc096e1c809.1634219547.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block')
-rw-r--r--block/bdev.c1
-rw-r--r--block/genhd.c4
2 files changed, 4 insertions, 1 deletions
diff --git a/block/bdev.c b/block/bdev.c
index 93b1188d7e58..fed8d0c041c7 100644
--- a/block/bdev.c
+++ b/block/bdev.c
@@ -493,6 +493,7 @@ struct block_device *bdev_alloc(struct gendisk *disk, u8 partno)
spin_lock_init(&bdev->bd_size_lock);
bdev->bd_partno = partno;
bdev->bd_inode = inode;
+ bdev->bd_queue = disk->queue;
bdev->bd_stats = alloc_percpu(struct disk_stats);
if (!bdev->bd_stats) {
iput(inode);
diff --git a/block/genhd.c b/block/genhd.c
index ffbdb9b24555..d148c38450d7 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -1267,6 +1267,9 @@ struct gendisk *__alloc_disk_node(struct request_queue *q, int node_id,
if (!disk->bdi)
goto out_free_disk;
+ /* bdev_alloc() might need the queue, set before the first call */
+ disk->queue = q;
+
disk->part0 = bdev_alloc(disk, 0);
if (!disk->part0)
goto out_free_bdi;
@@ -1282,7 +1285,6 @@ struct gendisk *__alloc_disk_node(struct request_queue *q, int node_id,
disk_to_dev(disk)->type = &disk_type;
device_initialize(disk_to_dev(disk));
inc_diskseq(disk);
- disk->queue = q;
q->disk = disk;
lockdep_init_map(&disk->lockdep_map, "(bio completion)", lkclass, 0);
#ifdef CONFIG_BLOCK_HOLDER_DEPRECATED