MIPS: mark __fls() and __ffs() as __always_inline
[sfrench/cifs-2.6.git] / block / blk-mq-sysfs.c
index 3f9c3f4ac44ca4632e0f2c25dce8164a08b5b916..d6e1a9bd7131c6d7b5c6027fc000b323934ba901 100644 (file)
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/backing-dev.h>
@@ -10,6 +11,7 @@
 #include <linux/smp.h>
 
 #include <linux/blk-mq.h>
+#include "blk.h"
 #include "blk-mq.h"
 #include "blk-mq-tag.h"
 
@@ -33,6 +35,13 @@ static void blk_mq_hw_sysfs_release(struct kobject *kobj)
 {
        struct blk_mq_hw_ctx *hctx = container_of(kobj, struct blk_mq_hw_ctx,
                                                  kobj);
+
+       cancel_delayed_work_sync(&hctx->run_work);
+
+       if (hctx->flags & BLK_MQ_F_BLOCKING)
+               cleanup_srcu_struct(hctx->srcu);
+       blk_free_flush_queue(hctx->fq);
+       sbitmap_free(&hctx->ctx_map);
        free_cpumask_var(hctx->cpumask);
        kfree(hctx->ctxs);
        kfree(hctx);
@@ -173,10 +182,6 @@ static ssize_t blk_mq_hw_sysfs_cpus_show(struct blk_mq_hw_ctx *hctx, char *page)
        return ret;
 }
 
-static struct attribute *default_ctx_attrs[] = {
-       NULL,
-};
-
 static struct blk_mq_hw_ctx_sysfs_entry blk_mq_hw_sysfs_nr_tags = {
        .attr = {.name = "nr_tags", .mode = 0444 },
        .show = blk_mq_hw_sysfs_nr_tags_show,
@@ -196,6 +201,7 @@ static struct attribute *default_hw_ctx_attrs[] = {
        &blk_mq_hw_sysfs_cpus.attr,
        NULL,
 };
+ATTRIBUTE_GROUPS(default_hw_ctx);
 
 static const struct sysfs_ops blk_mq_sysfs_ops = {
        .show   = blk_mq_sysfs_show,
@@ -214,13 +220,12 @@ static struct kobj_type blk_mq_ktype = {
 
 static struct kobj_type blk_mq_ctx_ktype = {
        .sysfs_ops      = &blk_mq_sysfs_ops,
-       .default_attrs  = default_ctx_attrs,
        .release        = blk_mq_ctx_sysfs_release,
 };
 
 static struct kobj_type blk_mq_hw_ktype = {
        .sysfs_ops      = &blk_mq_hw_sysfs_ops,
-       .default_attrs  = default_hw_ctx_attrs,
+       .default_groups = default_hw_ctx_groups,
        .release        = blk_mq_hw_sysfs_release,
 };