blk-mq-sched: (un)register elevator when (un)registering queue
authorOmar Sandoval <osandov@fb.com>
Mon, 6 Feb 2017 20:52:24 +0000 (12:52 -0800)
committerJens Axboe <axboe@fb.com>
Mon, 6 Feb 2017 20:55:36 +0000 (13:55 -0700)
I noticed that when booting with a default blk-mq I/O scheduler, the
/sys/block/*/queue/iosched directory was missing. However, switching
after boot did create the directory. This is because we skip the initial
elevator register/unregister when we don't have a ->request_fn(), but we
should still do it for the ->mq_ops case.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
block/blk-sysfs.c

index 3ce1217778f4493f5c6ab4a9e90c42f4c60b71f7..48032c4759a7d800028329b7785d96870cb16c9c 100644 (file)
@@ -903,16 +903,15 @@ int blk_register_queue(struct gendisk *disk)
 
        blk_wb_init(q);
 
-       if (!q->request_fn)
-               return 0;
-
-       ret = elv_register_queue(q);
-       if (ret) {
-               kobject_uevent(&q->kobj, KOBJ_REMOVE);
-               kobject_del(&q->kobj);
-               blk_trace_remove_sysfs(dev);
-               kobject_put(&dev->kobj);
-               return ret;
+       if (q->request_fn || (q->mq_ops && q->elevator)) {
+               ret = elv_register_queue(q);
+               if (ret) {
+                       kobject_uevent(&q->kobj, KOBJ_REMOVE);
+                       kobject_del(&q->kobj);
+                       blk_trace_remove_sysfs(dev);
+                       kobject_put(&dev->kobj);
+                       return ret;
+               }
        }
 
        return 0;
@@ -928,7 +927,7 @@ void blk_unregister_queue(struct gendisk *disk)
        if (q->mq_ops)
                blk_mq_unregister_dev(disk_to_dev(disk), q);
 
-       if (q->request_fn)
+       if (q->request_fn || (q->mq_ops && q->elevator))
                elv_unregister_queue(q);
 
        kobject_uevent(&q->kobj, KOBJ_REMOVE);