All of lore.kernel.org
 help / color / mirror / Atom feed
* cleanup block layer sysfs handling
@ 2022-06-24  5:25 Christoph Hellwig
  2022-06-24  5:25 ` [PATCH 1/6] block: simplify blktrace sysfs attribute creation Christoph Hellwig
                   ` (5 more replies)
  0 siblings, 6 replies; 13+ messages in thread
From: Christoph Hellwig @ 2022-06-24  5:25 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block

Hi Jens,

this series cleans up various loose ends in the block layer sysfs handling.
It sits on top of the "fully tear down the queue in del_gendisk" series
submitted last week.

Diffstat:
 block/blk-mq-sysfs.c         |   45 +++++++++++++++++++++----------------------
 block/blk-mq.c               |    4 +--
 block/blk-mq.h               |    7 +++---
 block/blk-sysfs.c            |   36 ++++++++++------------------------
 block/blk.h                  |    2 +
 block/genhd.c                |    3 ++
 block/partitions/core.c      |    1 
 include/linux/blk-mq.h       |    1 
 include/linux/blktrace_api.h |   10 ---------
 kernel/trace/blktrace.c      |   11 ----------
 10 files changed, 44 insertions(+), 76 deletions(-)

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 1/6] block: simplify blktrace sysfs attribute creation
  2022-06-24  5:25 cleanup block layer sysfs handling Christoph Hellwig
@ 2022-06-24  5:25 ` Christoph Hellwig
  2022-06-25  2:57   ` Bart Van Assche
  2022-06-24  5:25 ` [PATCH 2/6] block: remove a superflous queue kobject reference Christoph Hellwig
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 13+ messages in thread
From: Christoph Hellwig @ 2022-06-24  5:25 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block

Add the trace attributes to the default gendisk attributes, just like
we already do for partitions.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/blk-sysfs.c            | 11 +----------
 block/blk.h                  |  2 ++
 block/genhd.c                |  3 +++
 block/partitions/core.c      |  1 -
 include/linux/blktrace_api.h | 10 ----------
 kernel/trace/blktrace.c      | 11 -----------
 6 files changed, 6 insertions(+), 32 deletions(-)

diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index 84d7f87015673..e4df5ccebf0d0 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -803,21 +803,14 @@ int blk_register_queue(struct gendisk *disk)
 	struct device *dev = disk_to_dev(disk);
 	struct request_queue *q = disk->queue;
 
-	ret = blk_trace_init_sysfs(dev);
-	if (ret)
-		return ret;
-
 	mutex_lock(&q->sysfs_dir_lock);
 
 	ret = kobject_add(&q->kobj, kobject_get(&dev->kobj), "%s", "queue");
-	if (ret < 0) {
-		blk_trace_remove_sysfs(dev);
+	if (ret < 0)
 		goto unlock;
-	}
 
 	ret = sysfs_create_group(&q->kobj, &queue_attr_group);
 	if (ret) {
-		blk_trace_remove_sysfs(dev);
 		kobject_del(&q->kobj);
 		kobject_put(&dev->kobj);
 		goto unlock;
@@ -883,7 +876,6 @@ int blk_register_queue(struct gendisk *disk)
 	mutex_unlock(&q->sysfs_lock);
 	mutex_unlock(&q->sysfs_dir_lock);
 	kobject_del(&q->kobj);
-	blk_trace_remove_sysfs(dev);
 	kobject_put(&dev->kobj);
 
 	return ret;
@@ -924,7 +916,6 @@ void blk_unregister_queue(struct gendisk *disk)
 	if (queue_is_mq(q))
 		blk_mq_unregister_dev(disk_to_dev(disk), q);
 	blk_crypto_sysfs_unregister(q);
-	blk_trace_remove_sysfs(disk_to_dev(disk));
 
 	mutex_lock(&q->sysfs_lock);
 	elv_unregister_queue(q);
diff --git a/block/blk.h b/block/blk.h
index 0d6668663ab5d..4b2e0bc5b4a80 100644
--- a/block/blk.h
+++ b/block/blk.h
@@ -439,6 +439,8 @@ extern struct device_attribute dev_attr_events;
 extern struct device_attribute dev_attr_events_async;
 extern struct device_attribute dev_attr_events_poll_msecs;
 
+extern struct attribute_group blk_trace_attr_group;
+
 long blkdev_ioctl(struct file *file, unsigned cmd, unsigned long arg);
 long compat_blkdev_ioctl(struct file *file, unsigned cmd, unsigned long arg);
 
diff --git a/block/genhd.c b/block/genhd.c
index bf9be06af2c8d..12b0eda8d125b 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -1134,6 +1134,9 @@ static struct attribute_group disk_attr_group = {
 
 static const struct attribute_group *disk_attr_groups[] = {
 	&disk_attr_group,
+#ifdef CONFIG_BLK_DEV_IO_TRACE
+        &blk_trace_attr_group,
+#endif
 	NULL
 };
 
diff --git a/block/partitions/core.c b/block/partitions/core.c
index 8a0ec929023bc..7dc487f5b03cd 100644
--- a/block/partitions/core.c
+++ b/block/partitions/core.c
@@ -9,7 +9,6 @@
 #include <linux/slab.h>
 #include <linux/ctype.h>
 #include <linux/vmalloc.h>
-#include <linux/blktrace_api.h>
 #include <linux/raid/detect.h>
 #include "check.h"
 
diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
index 623e22492afa5..f6f9b544365ab 100644
--- a/include/linux/blktrace_api.h
+++ b/include/linux/blktrace_api.h
@@ -77,10 +77,6 @@ extern int blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
 			   char __user *arg);
 extern int blk_trace_startstop(struct request_queue *q, int start);
 extern int blk_trace_remove(struct request_queue *q);
-extern void blk_trace_remove_sysfs(struct device *dev);
-extern int blk_trace_init_sysfs(struct device *dev);
-
-extern struct attribute_group blk_trace_attr_group;
 
 #else /* !CONFIG_BLK_DEV_IO_TRACE */
 # define blk_trace_ioctl(bdev, cmd, arg)		(-ENOTTY)
@@ -91,13 +87,7 @@ extern struct attribute_group blk_trace_attr_group;
 # define blk_trace_remove(q)				(-ENOTTY)
 # define blk_add_trace_msg(q, fmt, ...)			do { } while (0)
 # define blk_add_cgroup_trace_msg(q, cg, fmt, ...)	do { } while (0)
-# define blk_trace_remove_sysfs(dev)			do { } while (0)
 # define blk_trace_note_message_enabled(q)		(false)
-static inline int blk_trace_init_sysfs(struct device *dev)
-{
-	return 0;
-}
-
 #endif /* CONFIG_BLK_DEV_IO_TRACE */
 
 #ifdef CONFIG_COMPAT
diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
index fe04c6f96ca5d..c584effe5fe99 100644
--- a/kernel/trace/blktrace.c
+++ b/kernel/trace/blktrace.c
@@ -1867,17 +1867,6 @@ static ssize_t sysfs_blk_trace_attr_store(struct device *dev,
 out:
 	return ret ? ret : count;
 }
-
-int blk_trace_init_sysfs(struct device *dev)
-{
-	return sysfs_create_group(&dev->kobj, &blk_trace_attr_group);
-}
-
-void blk_trace_remove_sysfs(struct device *dev)
-{
-	sysfs_remove_group(&dev->kobj, &blk_trace_attr_group);
-}
-
 #endif /* CONFIG_BLK_DEV_IO_TRACE */
 
 #ifdef CONFIG_EVENT_TRACING
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 2/6] block: remove a superflous queue kobject reference
  2022-06-24  5:25 cleanup block layer sysfs handling Christoph Hellwig
  2022-06-24  5:25 ` [PATCH 1/6] block: simplify blktrace sysfs attribute creation Christoph Hellwig
@ 2022-06-24  5:25 ` Christoph Hellwig
  2022-06-25  2:59   ` Bart Van Assche
  2022-06-24  5:25 ` [PATCH 3/6] block: use default groups to register the queue attributes Christoph Hellwig
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 13+ messages in thread
From: Christoph Hellwig @ 2022-06-24  5:25 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block

kobject_add already adds a referene to the parent that is dropped
on deletion, so don't bother grabbing another one.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/blk-sysfs.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index e4df5ccebf0d0..520ff9aa6dd45 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -805,14 +805,13 @@ int blk_register_queue(struct gendisk *disk)
 
 	mutex_lock(&q->sysfs_dir_lock);
 
-	ret = kobject_add(&q->kobj, kobject_get(&dev->kobj), "%s", "queue");
+	ret = kobject_add(&q->kobj, &dev->kobj, "%s", "queue");
 	if (ret < 0)
 		goto unlock;
 
 	ret = sysfs_create_group(&q->kobj, &queue_attr_group);
 	if (ret) {
 		kobject_del(&q->kobj);
-		kobject_put(&dev->kobj);
 		goto unlock;
 	}
 
@@ -876,7 +875,6 @@ int blk_register_queue(struct gendisk *disk)
 	mutex_unlock(&q->sysfs_lock);
 	mutex_unlock(&q->sysfs_dir_lock);
 	kobject_del(&q->kobj);
-	kobject_put(&dev->kobj);
 
 	return ret;
 }
@@ -934,6 +932,4 @@ void blk_unregister_queue(struct gendisk *disk)
 	q->sched_debugfs_dir = NULL;
 	q->rqos_debugfs_dir = NULL;
 	mutex_unlock(&q->debugfs_mutex);
-
-	kobject_put(&disk_to_dev(disk)->kobj);
 }
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 3/6] block: use default groups to register the queue attributes
  2022-06-24  5:25 cleanup block layer sysfs handling Christoph Hellwig
  2022-06-24  5:25 ` [PATCH 1/6] block: simplify blktrace sysfs attribute creation Christoph Hellwig
  2022-06-24  5:25 ` [PATCH 2/6] block: remove a superflous queue kobject reference Christoph Hellwig
@ 2022-06-24  5:25 ` Christoph Hellwig
  2022-06-25  3:00   ` Bart Van Assche
  2022-06-24  5:25 ` [PATCH 4/6] block: remove the extra gendisk reference in __blk_mq_register_dev Christoph Hellwig
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 13+ messages in thread
From: Christoph Hellwig @ 2022-06-24  5:25 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block

Set up the default_groups for blk_queue_ktype instead of manually calling
sysfs_create_group.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/blk-sysfs.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index 520ff9aa6dd45..80f506411f92f 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -788,7 +788,13 @@ static const struct sysfs_ops queue_sysfs_ops = {
 	.store	= queue_attr_store,
 };
 
+static const struct attribute_group *blk_queue_attr_groups[] = {
+	&queue_attr_group,
+	NULL
+};
+
 struct kobj_type blk_queue_ktype = {
+	.default_groups = blk_queue_attr_groups,
 	.sysfs_ops	= &queue_sysfs_ops,
 	.release	= blk_release_queue,
 };
@@ -809,12 +815,6 @@ int blk_register_queue(struct gendisk *disk)
 	if (ret < 0)
 		goto unlock;
 
-	ret = sysfs_create_group(&q->kobj, &queue_attr_group);
-	if (ret) {
-		kobject_del(&q->kobj);
-		goto unlock;
-	}
-
 	if (queue_is_mq(q))
 		__blk_mq_register_dev(dev, q);
 	mutex_lock(&q->sysfs_lock);
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 4/6] block: remove the extra gendisk reference in __blk_mq_register_dev
  2022-06-24  5:25 cleanup block layer sysfs handling Christoph Hellwig
                   ` (2 preceding siblings ...)
  2022-06-24  5:25 ` [PATCH 3/6] block: use default groups to register the queue attributes Christoph Hellwig
@ 2022-06-24  5:25 ` Christoph Hellwig
  2022-06-25  3:01   ` Bart Van Assche
  2022-06-24  5:25 ` [PATCH 5/6] blk-mq: rename blk_mq_sysfs_{,un}register Christoph Hellwig
  2022-06-24  5:25 ` [PATCH 6/6] blk-mq: cleanup disk sysfs registration Christoph Hellwig
  5 siblings, 1 reply; 13+ messages in thread
From: Christoph Hellwig @ 2022-06-24  5:25 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block

kobject_add already grabs a reference to the parent, no need to have
another one.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/blk-mq-sysfs.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/block/blk-mq-sysfs.c b/block/blk-mq-sysfs.c
index c08426975856e..f4caaa668e3cf 100644
--- a/block/blk-mq-sysfs.c
+++ b/block/blk-mq-sysfs.c
@@ -215,7 +215,6 @@ void blk_mq_unregister_dev(struct device *dev, struct request_queue *q)
 
 	kobject_uevent(q->mq_kobj, KOBJ_REMOVE);
 	kobject_del(q->mq_kobj);
-	kobject_put(&dev->kobj);
 
 	q->mq_sysfs_init_done = false;
 }
@@ -261,7 +260,7 @@ int __blk_mq_register_dev(struct device *dev, struct request_queue *q)
 	WARN_ON_ONCE(!q->kobj.parent);
 	lockdep_assert_held(&q->sysfs_dir_lock);
 
-	ret = kobject_add(q->mq_kobj, kobject_get(&dev->kobj), "%s", "mq");
+	ret = kobject_add(q->mq_kobj, &dev->kobj, "%s", "mq");
 	if (ret < 0)
 		goto out;
 
@@ -286,7 +285,6 @@ int __blk_mq_register_dev(struct device *dev, struct request_queue *q)
 
 	kobject_uevent(q->mq_kobj, KOBJ_REMOVE);
 	kobject_del(q->mq_kobj);
-	kobject_put(&dev->kobj);
 	return ret;
 }
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 5/6] blk-mq: rename blk_mq_sysfs_{,un}register
  2022-06-24  5:25 cleanup block layer sysfs handling Christoph Hellwig
                   ` (3 preceding siblings ...)
  2022-06-24  5:25 ` [PATCH 4/6] block: remove the extra gendisk reference in __blk_mq_register_dev Christoph Hellwig
@ 2022-06-24  5:25 ` Christoph Hellwig
  2022-06-25  3:07   ` Bart Van Assche
  2022-06-24  5:25 ` [PATCH 6/6] blk-mq: cleanup disk sysfs registration Christoph Hellwig
  5 siblings, 1 reply; 13+ messages in thread
From: Christoph Hellwig @ 2022-06-24  5:25 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block

Add a _hctx postifx to better describe what the functions do, match
the debugfs equivalents and release the old names for functions that
should be using them.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/blk-mq-sysfs.c | 4 ++--
 block/blk-mq.c       | 4 ++--
 block/blk-mq.h       | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/block/blk-mq-sysfs.c b/block/blk-mq-sysfs.c
index f4caaa668e3cf..ee6efe2b250d2 100644
--- a/block/blk-mq-sysfs.c
+++ b/block/blk-mq-sysfs.c
@@ -288,7 +288,7 @@ int __blk_mq_register_dev(struct device *dev, struct request_queue *q)
 	return ret;
 }
 
-void blk_mq_sysfs_unregister(struct request_queue *q)
+void blk_mq_sysfs_unregister_hctxs(struct request_queue *q)
 {
 	struct blk_mq_hw_ctx *hctx;
 	unsigned long i;
@@ -304,7 +304,7 @@ void blk_mq_sysfs_unregister(struct request_queue *q)
 	mutex_unlock(&q->sysfs_dir_lock);
 }
 
-int blk_mq_sysfs_register(struct request_queue *q)
+int blk_mq_sysfs_register_hctxs(struct request_queue *q)
 {
 	struct blk_mq_hw_ctx *hctx;
 	unsigned long i;
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 784b8f35edca4..56139db828479 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -4547,7 +4547,7 @@ static void __blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set,
 
 	list_for_each_entry(q, &set->tag_list, tag_set_list) {
 		blk_mq_debugfs_unregister_hctxs(q);
-		blk_mq_sysfs_unregister(q);
+		blk_mq_sysfs_unregister_hctxs(q);
 	}
 
 	prev_nr_hw_queues = set->nr_hw_queues;
@@ -4578,7 +4578,7 @@ static void __blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set,
 
 reregister:
 	list_for_each_entry(q, &set->tag_list, tag_set_list) {
-		blk_mq_sysfs_register(q);
+		blk_mq_sysfs_register_hctxs(q);
 		blk_mq_debugfs_register_hctxs(q);
 	}
 
diff --git a/block/blk-mq.h b/block/blk-mq.h
index 2615bd58bad3c..bed34061c3a0b 100644
--- a/block/blk-mq.h
+++ b/block/blk-mq.h
@@ -119,8 +119,8 @@ static inline struct blk_mq_hw_ctx *blk_mq_map_queue(struct request_queue *q,
 extern void blk_mq_sysfs_init(struct request_queue *q);
 extern void blk_mq_sysfs_deinit(struct request_queue *q);
 extern int __blk_mq_register_dev(struct device *dev, struct request_queue *q);
-extern int blk_mq_sysfs_register(struct request_queue *q);
-extern void blk_mq_sysfs_unregister(struct request_queue *q);
+int blk_mq_sysfs_register_hctxs(struct request_queue *q);
+void blk_mq_sysfs_unregister_hctxs(struct request_queue *q);
 extern void blk_mq_hctx_kobj_init(struct blk_mq_hw_ctx *hctx);
 void blk_mq_free_plug_rqs(struct blk_plug *plug);
 void blk_mq_flush_plug_list(struct blk_plug *plug, bool from_schedule);
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 6/6] blk-mq: cleanup disk sysfs registration
  2022-06-24  5:25 cleanup block layer sysfs handling Christoph Hellwig
                   ` (4 preceding siblings ...)
  2022-06-24  5:25 ` [PATCH 5/6] blk-mq: rename blk_mq_sysfs_{,un}register Christoph Hellwig
@ 2022-06-24  5:25 ` Christoph Hellwig
  2022-06-25  3:09   ` Bart Van Assche
  5 siblings, 1 reply; 13+ messages in thread
From: Christoph Hellwig @ 2022-06-24  5:25 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block

Pass a gendisk to the sysfs register/unregister functions and give
them descriptive names.  Also move the unregistration helper next
to the one doing the registration.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/blk-mq-sysfs.c   | 39 ++++++++++++++++++++-------------------
 block/blk-mq.h         |  3 ++-
 block/blk-sysfs.c      |  9 ++++-----
 include/linux/blk-mq.h |  1 -
 4 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/block/blk-mq-sysfs.c b/block/blk-mq-sysfs.c
index ee6efe2b250d2..93997d297d427 100644
--- a/block/blk-mq-sysfs.c
+++ b/block/blk-mq-sysfs.c
@@ -203,22 +203,6 @@ static int blk_mq_register_hctx(struct blk_mq_hw_ctx *hctx)
 	return ret;
 }
 
-void blk_mq_unregister_dev(struct device *dev, struct request_queue *q)
-{
-	struct blk_mq_hw_ctx *hctx;
-	unsigned long i;
-
-	lockdep_assert_held(&q->sysfs_dir_lock);
-
-	queue_for_each_hw_ctx(q, hctx, i)
-		blk_mq_unregister_hctx(hctx);
-
-	kobject_uevent(q->mq_kobj, KOBJ_REMOVE);
-	kobject_del(q->mq_kobj);
-
-	q->mq_sysfs_init_done = false;
-}
-
 void blk_mq_hctx_kobj_init(struct blk_mq_hw_ctx *hctx)
 {
 	kobject_init(&hctx->kobj, &blk_mq_hw_ktype);
@@ -251,16 +235,16 @@ void blk_mq_sysfs_init(struct request_queue *q)
 	}
 }
 
-int __blk_mq_register_dev(struct device *dev, struct request_queue *q)
+int blk_mq_sysfs_register(struct gendisk *disk)
 {
+	struct request_queue *q = disk->queue;
 	struct blk_mq_hw_ctx *hctx;
 	unsigned long i, j;
 	int ret;
 
-	WARN_ON_ONCE(!q->kobj.parent);
 	lockdep_assert_held(&q->sysfs_dir_lock);
 
-	ret = kobject_add(q->mq_kobj, &dev->kobj, "%s", "mq");
+	ret = kobject_add(q->mq_kobj, &disk_to_dev(disk)->kobj, "mq");
 	if (ret < 0)
 		goto out;
 
@@ -288,6 +272,23 @@ int __blk_mq_register_dev(struct device *dev, struct request_queue *q)
 	return ret;
 }
 
+void blk_mq_sysfs_unregister(struct gendisk *disk)
+{
+	struct request_queue *q = disk->queue;
+	struct blk_mq_hw_ctx *hctx;
+	unsigned long i;
+
+	lockdep_assert_held(&q->sysfs_dir_lock);
+
+	queue_for_each_hw_ctx(q, hctx, i)
+		blk_mq_unregister_hctx(hctx);
+
+	kobject_uevent(q->mq_kobj, KOBJ_REMOVE);
+	kobject_del(q->mq_kobj);
+
+	q->mq_sysfs_init_done = false;
+}
+
 void blk_mq_sysfs_unregister_hctxs(struct request_queue *q)
 {
 	struct blk_mq_hw_ctx *hctx;
diff --git a/block/blk-mq.h b/block/blk-mq.h
index bed34061c3a0b..7145c10932b91 100644
--- a/block/blk-mq.h
+++ b/block/blk-mq.h
@@ -118,7 +118,8 @@ static inline struct blk_mq_hw_ctx *blk_mq_map_queue(struct request_queue *q,
  */
 extern void blk_mq_sysfs_init(struct request_queue *q);
 extern void blk_mq_sysfs_deinit(struct request_queue *q);
-extern int __blk_mq_register_dev(struct device *dev, struct request_queue *q);
+int blk_mq_sysfs_register(struct gendisk *disk);
+void blk_mq_sysfs_unregister(struct gendisk *disk);
 int blk_mq_sysfs_register_hctxs(struct request_queue *q);
 void blk_mq_sysfs_unregister_hctxs(struct request_queue *q);
 extern void blk_mq_hctx_kobj_init(struct blk_mq_hw_ctx *hctx);
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index 80f506411f92f..0415722a4625f 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -805,18 +805,17 @@ struct kobj_type blk_queue_ktype = {
  */
 int blk_register_queue(struct gendisk *disk)
 {
-	int ret;
-	struct device *dev = disk_to_dev(disk);
 	struct request_queue *q = disk->queue;
+	int ret;
 
 	mutex_lock(&q->sysfs_dir_lock);
 
-	ret = kobject_add(&q->kobj, &dev->kobj, "%s", "queue");
+	ret = kobject_add(&q->kobj, &disk_to_dev(disk)->kobj, "queue");
 	if (ret < 0)
 		goto unlock;
 
 	if (queue_is_mq(q))
-		__blk_mq_register_dev(dev, q);
+		blk_mq_sysfs_register(disk);
 	mutex_lock(&q->sysfs_lock);
 
 	mutex_lock(&q->debugfs_mutex);
@@ -912,7 +911,7 @@ void blk_unregister_queue(struct gendisk *disk)
 	 * structures that can be modified through sysfs.
 	 */
 	if (queue_is_mq(q))
-		blk_mq_unregister_dev(disk_to_dev(disk), q);
+		blk_mq_sysfs_unregister(disk);
 	blk_crypto_sysfs_unregister(q);
 
 	mutex_lock(&q->sysfs_lock);
diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index 0fd96e92c6c65..43aad0da3305d 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -691,7 +691,6 @@ struct gendisk *blk_mq_alloc_disk_for_queue(struct request_queue *q,
 struct request_queue *blk_mq_init_queue(struct blk_mq_tag_set *);
 int blk_mq_init_allocated_queue(struct blk_mq_tag_set *set,
 		struct request_queue *q);
-void blk_mq_unregister_dev(struct device *, struct request_queue *);
 void blk_mq_destroy_queue(struct request_queue *);
 
 int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set);
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH 1/6] block: simplify blktrace sysfs attribute creation
  2022-06-24  5:25 ` [PATCH 1/6] block: simplify blktrace sysfs attribute creation Christoph Hellwig
@ 2022-06-25  2:57   ` Bart Van Assche
  0 siblings, 0 replies; 13+ messages in thread
From: Bart Van Assche @ 2022-06-25  2:57 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe; +Cc: linux-block

On 6/23/22 22:25, Christoph Hellwig wrote:
> diff --git a/block/genhd.c b/block/genhd.c
> index bf9be06af2c8d..12b0eda8d125b 100644
> --- a/block/genhd.c
> +++ b/block/genhd.c
> @@ -1134,6 +1134,9 @@ static struct attribute_group disk_attr_group = {
>   
>   static const struct attribute_group *disk_attr_groups[] = {
>   	&disk_attr_group,
> +#ifdef CONFIG_BLK_DEV_IO_TRACE
> +        &blk_trace_attr_group,
> +#endif

The space in front of '&' is probably unintended? Anyway:

Reviewed-by: Bart Van Assche <bvanassche@acm.org>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 2/6] block: remove a superflous queue kobject reference
  2022-06-24  5:25 ` [PATCH 2/6] block: remove a superflous queue kobject reference Christoph Hellwig
@ 2022-06-25  2:59   ` Bart Van Assche
  0 siblings, 0 replies; 13+ messages in thread
From: Bart Van Assche @ 2022-06-25  2:59 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe; +Cc: linux-block

On 6/23/22 22:25, Christoph Hellwig wrote:
> kobject_add already adds a referene to the parent that is dropped
                              ^^^^^^^^
reference?

Anyway:

Reviewed-by: Bart Van Assche <bvanassche@acm.org>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 3/6] block: use default groups to register the queue attributes
  2022-06-24  5:25 ` [PATCH 3/6] block: use default groups to register the queue attributes Christoph Hellwig
@ 2022-06-25  3:00   ` Bart Van Assche
  0 siblings, 0 replies; 13+ messages in thread
From: Bart Van Assche @ 2022-06-25  3:00 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe; +Cc: linux-block

On 6/23/22 22:25, Christoph Hellwig wrote:
> Set up the default_groups for blk_queue_ktype instead of manually calling
> sysfs_create_group.

Reviewed-by: Bart Van Assche <bvanassche@acm.org>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 4/6] block: remove the extra gendisk reference in __blk_mq_register_dev
  2022-06-24  5:25 ` [PATCH 4/6] block: remove the extra gendisk reference in __blk_mq_register_dev Christoph Hellwig
@ 2022-06-25  3:01   ` Bart Van Assche
  0 siblings, 0 replies; 13+ messages in thread
From: Bart Van Assche @ 2022-06-25  3:01 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe; +Cc: linux-block

On 6/23/22 22:25, Christoph Hellwig wrote:
> kobject_add already grabs a reference to the parent, no need to have
> another one.

Reviewed-by: Bart Van Assche <bvanassche@acm.org>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 5/6] blk-mq: rename blk_mq_sysfs_{,un}register
  2022-06-24  5:25 ` [PATCH 5/6] blk-mq: rename blk_mq_sysfs_{,un}register Christoph Hellwig
@ 2022-06-25  3:07   ` Bart Van Assche
  0 siblings, 0 replies; 13+ messages in thread
From: Bart Van Assche @ 2022-06-25  3:07 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe; +Cc: linux-block

On 6/23/22 22:25, Christoph Hellwig wrote:
> Add a _hctx postifx to better describe what the functions do, match
               ^^^^^^^
postfix? Anyway:

Reviewed-by: Bart Van Assche <bvanassche@acm.org>


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 6/6] blk-mq: cleanup disk sysfs registration
  2022-06-24  5:25 ` [PATCH 6/6] blk-mq: cleanup disk sysfs registration Christoph Hellwig
@ 2022-06-25  3:09   ` Bart Van Assche
  0 siblings, 0 replies; 13+ messages in thread
From: Bart Van Assche @ 2022-06-25  3:09 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe; +Cc: linux-block

On 6/23/22 22:25, Christoph Hellwig wrote:
> Pass a gendisk to the sysfs register/unregister functions and give
> them descriptive names.  Also move the unregistration helper next
> to the one doing the registration.

Reviewed-by: Bart Van Assche <bvanassche@acm.org>

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2022-06-25  3:09 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-24  5:25 cleanup block layer sysfs handling Christoph Hellwig
2022-06-24  5:25 ` [PATCH 1/6] block: simplify blktrace sysfs attribute creation Christoph Hellwig
2022-06-25  2:57   ` Bart Van Assche
2022-06-24  5:25 ` [PATCH 2/6] block: remove a superflous queue kobject reference Christoph Hellwig
2022-06-25  2:59   ` Bart Van Assche
2022-06-24  5:25 ` [PATCH 3/6] block: use default groups to register the queue attributes Christoph Hellwig
2022-06-25  3:00   ` Bart Van Assche
2022-06-24  5:25 ` [PATCH 4/6] block: remove the extra gendisk reference in __blk_mq_register_dev Christoph Hellwig
2022-06-25  3:01   ` Bart Van Assche
2022-06-24  5:25 ` [PATCH 5/6] blk-mq: rename blk_mq_sysfs_{,un}register Christoph Hellwig
2022-06-25  3:07   ` Bart Van Assche
2022-06-24  5:25 ` [PATCH 6/6] blk-mq: cleanup disk sysfs registration Christoph Hellwig
2022-06-25  3:09   ` Bart Van Assche

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.