]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blobdiff - block/blk-mq-sched.c
blk-mq-debugfs: allow schedulers to register debugfs attributes
[mirror_ubuntu-artful-kernel.git] / block / blk-mq-sched.c
index e79e9f18d7c25885a70ec0c793e41125f0493ff3..1f5b692526ae1a7199ee9bbaef305c4b0a42e696 100644 (file)
@@ -11,6 +11,7 @@
 
 #include "blk.h"
 #include "blk-mq.h"
+#include "blk-mq-debugfs.h"
 #include "blk-mq-sched.h"
 #include "blk-mq-tag.h"
 #include "blk-wbt.h"
@@ -472,6 +473,8 @@ int blk_mq_sched_init_hctx(struct request_queue *q, struct blk_mq_hw_ctx *hctx,
                }
        }
 
+       blk_mq_debugfs_register_sched_hctx(q, hctx);
+
        return 0;
 }
 
@@ -483,6 +486,8 @@ void blk_mq_sched_exit_hctx(struct request_queue *q, struct blk_mq_hw_ctx *hctx,
        if (!e)
                return;
 
+       blk_mq_debugfs_unregister_sched_hctx(hctx);
+
        if (e->type->ops.mq.exit_hctx && hctx->sched_data) {
                e->type->ops.mq.exit_hctx(hctx, hctx_idx);
                hctx->sched_data = NULL;
@@ -519,8 +524,10 @@ int blk_mq_init_sched(struct request_queue *q, struct elevator_type *e)
        if (ret)
                goto err;
 
-       if (e->ops.mq.init_hctx) {
-               queue_for_each_hw_ctx(q, hctx, i) {
+       blk_mq_debugfs_register_sched(q);
+
+       queue_for_each_hw_ctx(q, hctx, i) {
+               if (e->ops.mq.init_hctx) {
                        ret = e->ops.mq.init_hctx(hctx, i);
                        if (ret) {
                                eq = q->elevator;
@@ -529,6 +536,7 @@ int blk_mq_init_sched(struct request_queue *q, struct elevator_type *e)
                                return ret;
                        }
                }
+               blk_mq_debugfs_register_sched_hctx(q, hctx);
        }
 
        return 0;
@@ -544,14 +552,14 @@ void blk_mq_exit_sched(struct request_queue *q, struct elevator_queue *e)
        struct blk_mq_hw_ctx *hctx;
        unsigned int i;
 
-       if (e->type->ops.mq.exit_hctx) {
-               queue_for_each_hw_ctx(q, hctx, i) {
-                       if (hctx->sched_data) {
-                               e->type->ops.mq.exit_hctx(hctx, i);
-                               hctx->sched_data = NULL;
-                       }
+       queue_for_each_hw_ctx(q, hctx, i) {
+               blk_mq_debugfs_unregister_sched_hctx(hctx);
+               if (e->type->ops.mq.exit_hctx && hctx->sched_data) {
+                       e->type->ops.mq.exit_hctx(hctx, i);
+                       hctx->sched_data = NULL;
                }
        }
+       blk_mq_debugfs_unregister_sched(q);
        if (e->type->ops.mq.exit_sched)
                e->type->ops.mq.exit_sched(e);
        blk_mq_sched_tags_teardown(q);