blk-mq: register device instead of disk
Enable devices without a gendisk instance to register itself with blk-mq and expose the associated multi-queue sysfs entries. Signed-off-by: Matias Bjørling <m@bjorling.me> Signed-off-by: Jens Axboe <axboe@fb.com>
This commit is contained in:
parent
9ae2d0aa50
commit
b21d5b3017
|
@ -393,9 +393,8 @@ static int blk_mq_register_hctx(struct blk_mq_hw_ctx *hctx)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static void __blk_mq_unregister_disk(struct gendisk *disk)
|
||||
static void __blk_mq_unregister_dev(struct device *dev, struct request_queue *q)
|
||||
{
|
||||
struct request_queue *q = disk->queue;
|
||||
struct blk_mq_hw_ctx *hctx;
|
||||
struct blk_mq_ctx *ctx;
|
||||
int i, j;
|
||||
|
@ -413,15 +412,15 @@ static void __blk_mq_unregister_disk(struct gendisk *disk)
|
|||
kobject_del(&q->mq_kobj);
|
||||
kobject_put(&q->mq_kobj);
|
||||
|
||||
kobject_put(&disk_to_dev(disk)->kobj);
|
||||
kobject_put(&dev->kobj);
|
||||
|
||||
q->mq_sysfs_init_done = false;
|
||||
}
|
||||
|
||||
void blk_mq_unregister_disk(struct gendisk *disk)
|
||||
void blk_mq_unregister_dev(struct device *dev, struct request_queue *q)
|
||||
{
|
||||
blk_mq_disable_hotplug();
|
||||
__blk_mq_unregister_disk(disk);
|
||||
__blk_mq_unregister_dev(dev, q);
|
||||
blk_mq_enable_hotplug();
|
||||
}
|
||||
|
||||
|
@ -443,10 +442,8 @@ static void blk_mq_sysfs_init(struct request_queue *q)
|
|||
}
|
||||
}
|
||||
|
||||
int blk_mq_register_disk(struct gendisk *disk)
|
||||
int blk_mq_register_dev(struct device *dev, struct request_queue *q)
|
||||
{
|
||||
struct device *dev = disk_to_dev(disk);
|
||||
struct request_queue *q = disk->queue;
|
||||
struct blk_mq_hw_ctx *hctx;
|
||||
int ret, i;
|
||||
|
||||
|
@ -467,7 +464,7 @@ int blk_mq_register_disk(struct gendisk *disk)
|
|||
}
|
||||
|
||||
if (ret)
|
||||
__blk_mq_unregister_disk(disk);
|
||||
__blk_mq_unregister_dev(dev, q);
|
||||
else
|
||||
q->mq_sysfs_init_done = true;
|
||||
out:
|
||||
|
@ -475,7 +472,7 @@ out:
|
|||
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(blk_mq_register_disk);
|
||||
EXPORT_SYMBOL_GPL(blk_mq_register_dev);
|
||||
|
||||
void blk_mq_sysfs_unregister(struct request_queue *q)
|
||||
{
|
||||
|
|
|
@ -704,7 +704,7 @@ int blk_register_queue(struct gendisk *disk)
|
|||
kobject_uevent(&q->kobj, KOBJ_ADD);
|
||||
|
||||
if (q->mq_ops)
|
||||
blk_mq_register_disk(disk);
|
||||
blk_mq_register_dev(dev, q);
|
||||
|
||||
if (!q->request_fn)
|
||||
return 0;
|
||||
|
@ -729,7 +729,7 @@ void blk_unregister_queue(struct gendisk *disk)
|
|||
return;
|
||||
|
||||
if (q->mq_ops)
|
||||
blk_mq_unregister_disk(disk);
|
||||
blk_mq_unregister_dev(disk_to_dev(disk), q);
|
||||
|
||||
if (q->request_fn)
|
||||
elv_unregister_queue(q);
|
||||
|
|
|
@ -955,7 +955,7 @@ int dm_mq_init_request_queue(struct mapped_device *md, struct dm_table *t)
|
|||
dm_init_md_queue(md);
|
||||
|
||||
/* backfill 'mq' sysfs registration normally done in blk_register_queue */
|
||||
blk_mq_register_disk(md->disk);
|
||||
blk_mq_register_dev(disk_to_dev(md->disk), q);
|
||||
|
||||
return 0;
|
||||
|
||||
|
|
|
@ -175,8 +175,8 @@ enum {
|
|||
struct request_queue *blk_mq_init_queue(struct blk_mq_tag_set *);
|
||||
struct request_queue *blk_mq_init_allocated_queue(struct blk_mq_tag_set *set,
|
||||
struct request_queue *q);
|
||||
int blk_mq_register_disk(struct gendisk *);
|
||||
void blk_mq_unregister_disk(struct gendisk *);
|
||||
int blk_mq_register_dev(struct device *, struct request_queue *);
|
||||
void blk_mq_unregister_dev(struct device *, struct request_queue *);
|
||||
|
||||
int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set);
|
||||
void blk_mq_free_tag_set(struct blk_mq_tag_set *set);
|
||||
|
|
Loading…
Reference in New Issue