summaryrefslogtreecommitdiff
path: root/block/blk-mq.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2021-06-02 09:53:18 +0300
committerJens Axboe <axboe@kernel.dk>2021-06-11 20:53:02 +0300
commitb461dfc49eb6fbabc60b9dad476e787ada56b7b4 (patch)
tree8858c13ab206fcfaa8bb8828b1e40d84341f788c /block/blk-mq.c
parent26a9750aa875126e4b7fc5ee6de652a529c5b7ee (diff)
downloadlinux-b461dfc49eb6fbabc60b9dad476e787ada56b7b4.tar.xz
blk-mq: add the blk_mq_alloc_disk APIs
Add a new API to allocate a gendisk including the request_queue for use with blk-mq based drivers. This is to avoid boilerplate code in drivers. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com> Link: https://lore.kernel.org/r/20210602065345.355274-4-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/blk-mq.c')
-rw-r--r--block/blk-mq.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 8550ad64982f..b123077a0dc4 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -3137,6 +3137,25 @@ struct request_queue *blk_mq_init_queue(struct blk_mq_tag_set *set)
}
EXPORT_SYMBOL(blk_mq_init_queue);
+struct gendisk *__blk_mq_alloc_disk(struct blk_mq_tag_set *set, void *queuedata)
+{
+ struct request_queue *q;
+ struct gendisk *disk;
+
+ q = blk_mq_init_queue_data(set, queuedata);
+ if (IS_ERR(q))
+ return ERR_CAST(q);
+
+ disk = __alloc_disk_node(0, set->numa_node);
+ if (!disk) {
+ blk_cleanup_queue(q);
+ return ERR_PTR(-ENOMEM);
+ }
+ disk->queue = q;
+ return disk;
+}
+EXPORT_SYMBOL(__blk_mq_alloc_disk);
+
/*
* Helper for setting up a queue with mq ops, given queue depth, and
* the passed in mq ops flags.