|
|
@@ -343,7 +343,7 @@ static void blk_mq_unregister_hctx(struct blk_mq_hw_ctx *hctx)
|
|
|
struct blk_mq_ctx *ctx;
|
|
|
int i;
|
|
|
|
|
|
- if (!hctx->nr_ctx || !(hctx->flags & BLK_MQ_F_SYSFS_UP))
|
|
|
+ if (!hctx->nr_ctx)
|
|
|
return;
|
|
|
|
|
|
hctx_for_each_ctx(hctx, ctx, i)
|
|
|
@@ -358,7 +358,7 @@ static int blk_mq_register_hctx(struct blk_mq_hw_ctx *hctx)
|
|
|
struct blk_mq_ctx *ctx;
|
|
|
int i, ret;
|
|
|
|
|
|
- if (!hctx->nr_ctx || !(hctx->flags & BLK_MQ_F_SYSFS_UP))
|
|
|
+ if (!hctx->nr_ctx)
|
|
|
return 0;
|
|
|
|
|
|
ret = kobject_add(&hctx->kobj, &q->mq_kobj, "%u", hctx->queue_num);
|
|
|
@@ -381,6 +381,8 @@ void blk_mq_unregister_disk(struct gendisk *disk)
|
|
|
struct blk_mq_ctx *ctx;
|
|
|
int i, j;
|
|
|
|
|
|
+ blk_mq_disable_hotplug();
|
|
|
+
|
|
|
queue_for_each_hw_ctx(q, hctx, i) {
|
|
|
blk_mq_unregister_hctx(hctx);
|
|
|
|
|
|
@@ -395,6 +397,9 @@ void blk_mq_unregister_disk(struct gendisk *disk)
|
|
|
kobject_put(&q->mq_kobj);
|
|
|
|
|
|
kobject_put(&disk_to_dev(disk)->kobj);
|
|
|
+
|
|
|
+ q->mq_sysfs_init_done = false;
|
|
|
+ blk_mq_enable_hotplug();
|
|
|
}
|
|
|
|
|
|
static void blk_mq_sysfs_init(struct request_queue *q)
|
|
|
@@ -425,27 +430,30 @@ int blk_mq_register_disk(struct gendisk *disk)
|
|
|
struct blk_mq_hw_ctx *hctx;
|
|
|
int ret, i;
|
|
|
|
|
|
+ blk_mq_disable_hotplug();
|
|
|
+
|
|
|
blk_mq_sysfs_init(q);
|
|
|
|
|
|
ret = kobject_add(&q->mq_kobj, kobject_get(&dev->kobj), "%s", "mq");
|
|
|
if (ret < 0)
|
|
|
- return ret;
|
|
|
+ goto out;
|
|
|
|
|
|
kobject_uevent(&q->mq_kobj, KOBJ_ADD);
|
|
|
|
|
|
queue_for_each_hw_ctx(q, hctx, i) {
|
|
|
- hctx->flags |= BLK_MQ_F_SYSFS_UP;
|
|
|
ret = blk_mq_register_hctx(hctx);
|
|
|
if (ret)
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
- if (ret) {
|
|
|
+ if (ret)
|
|
|
blk_mq_unregister_disk(disk);
|
|
|
- return ret;
|
|
|
- }
|
|
|
+ else
|
|
|
+ q->mq_sysfs_init_done = true;
|
|
|
+out:
|
|
|
+ blk_mq_enable_hotplug();
|
|
|
|
|
|
- return 0;
|
|
|
+ return ret;
|
|
|
}
|
|
|
EXPORT_SYMBOL_GPL(blk_mq_register_disk);
|
|
|
|
|
|
@@ -454,6 +462,9 @@ void blk_mq_sysfs_unregister(struct request_queue *q)
|
|
|
struct blk_mq_hw_ctx *hctx;
|
|
|
int i;
|
|
|
|
|
|
+ if (!q->mq_sysfs_init_done)
|
|
|
+ return;
|
|
|
+
|
|
|
queue_for_each_hw_ctx(q, hctx, i)
|
|
|
blk_mq_unregister_hctx(hctx);
|
|
|
}
|
|
|
@@ -463,6 +474,9 @@ int blk_mq_sysfs_register(struct request_queue *q)
|
|
|
struct blk_mq_hw_ctx *hctx;
|
|
|
int i, ret = 0;
|
|
|
|
|
|
+ if (!q->mq_sysfs_init_done)
|
|
|
+ return ret;
|
|
|
+
|
|
|
queue_for_each_hw_ctx(q, hctx, i) {
|
|
|
ret = blk_mq_register_hctx(hctx);
|
|
|
if (ret)
|