* cleanup block layer sysfs handling v2
@ 2022-06-28 17:18 Christoph Hellwig
2022-06-28 17:18 ` [PATCH 1/6] block: simplify blktrace sysfs attribute creation Christoph Hellwig
` (6 more replies)
0 siblings, 7 replies; 10+ messages in thread
From: Christoph Hellwig @ 2022-06-28 17:18 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-block
Hi Jens,
this series cleans up various loose ends in the block layer sysfs handling.
Changes since v1:
- trivial whitespace and spelling fixes
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] 10+ messages in thread
* [PATCH 1/6] block: simplify blktrace sysfs attribute creation
2022-06-28 17:18 cleanup block layer sysfs handling v2 Christoph Hellwig
@ 2022-06-28 17:18 ` Christoph Hellwig
2022-06-28 17:18 ` [PATCH 2/6] block: remove a superflous queue kobject reference Christoph Hellwig
` (5 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Christoph Hellwig @ 2022-06-28 17:18 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-block, Bart Van Assche
Add the trace attributes to the default gendisk attributes, just like
we already do for partitions.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
---
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 9b211e519de81..5f3f73115988c 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -810,21 +810,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;
@@ -890,7 +883,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;
@@ -931,7 +923,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 1a0d3e6a4a631..74d59435870cb 100644
--- a/block/blk.h
+++ b/block/blk.h
@@ -452,6 +452,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..b1fb7e058b9cc 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] 10+ messages in thread
* [PATCH 2/6] block: remove a superflous queue kobject reference
2022-06-28 17:18 cleanup block layer sysfs handling v2 Christoph Hellwig
2022-06-28 17:18 ` [PATCH 1/6] block: simplify blktrace sysfs attribute creation Christoph Hellwig
@ 2022-06-28 17:18 ` Christoph Hellwig
2022-06-28 17:18 ` [PATCH 3/6] block: use default groups to register the queue attributes Christoph Hellwig
` (4 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Christoph Hellwig @ 2022-06-28 17:18 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-block, Bart Van Assche
kobject_add already adds a reference to the parent that is dropped
on deletion, so don't bother grabbing another one.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
---
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 5f3f73115988c..f9373da591b83 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -812,14 +812,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;
}
@@ -883,7 +882,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;
}
@@ -941,6 +939,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] 10+ messages in thread
* [PATCH 3/6] block: use default groups to register the queue attributes
2022-06-28 17:18 cleanup block layer sysfs handling v2 Christoph Hellwig
2022-06-28 17:18 ` [PATCH 1/6] block: simplify blktrace sysfs attribute creation Christoph Hellwig
2022-06-28 17:18 ` [PATCH 2/6] block: remove a superflous queue kobject reference Christoph Hellwig
@ 2022-06-28 17:18 ` Christoph Hellwig
2022-06-28 17:18 ` [PATCH 4/6] block: remove the extra gendisk reference in __blk_mq_register_dev Christoph Hellwig
` (3 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Christoph Hellwig @ 2022-06-28 17:18 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-block, Bart Van Assche
Set up the default_groups for blk_queue_ktype instead of manually calling
sysfs_create_group.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
---
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 f9373da591b83..b72506770b97e 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -795,7 +795,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,
};
@@ -816,12 +822,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] 10+ messages in thread
* [PATCH 4/6] block: remove the extra gendisk reference in __blk_mq_register_dev
2022-06-28 17:18 cleanup block layer sysfs handling v2 Christoph Hellwig
` (2 preceding siblings ...)
2022-06-28 17:18 ` [PATCH 3/6] block: use default groups to register the queue attributes Christoph Hellwig
@ 2022-06-28 17:18 ` Christoph Hellwig
2022-06-28 17:18 ` [PATCH 5/6] blk-mq: rename blk_mq_sysfs_{,un}register Christoph Hellwig
` (2 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Christoph Hellwig @ 2022-06-28 17:18 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-block, Bart Van Assche
kobject_add already grabs a reference to the parent, no need to have
another one.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
---
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] 10+ messages in thread
* [PATCH 5/6] blk-mq: rename blk_mq_sysfs_{,un}register
2022-06-28 17:18 cleanup block layer sysfs handling v2 Christoph Hellwig
` (3 preceding siblings ...)
2022-06-28 17:18 ` [PATCH 4/6] block: remove the extra gendisk reference in __blk_mq_register_dev Christoph Hellwig
@ 2022-06-28 17:18 ` Christoph Hellwig
2022-06-28 17:18 ` [PATCH 6/6] blk-mq: cleanup disk sysfs registration Christoph Hellwig
2022-06-28 19:06 ` cleanup block layer sysfs handling v2 Jens Axboe
6 siblings, 0 replies; 10+ messages in thread
From: Christoph Hellwig @ 2022-06-28 17:18 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-block, Bart Van Assche
Add a _hctx postfix 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>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
---
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 b1dbc4b2c2c97..15c7c5c4ad222 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -4559,7 +4559,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;
@@ -4590,7 +4590,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 e4c6fe2c8ac8f..a92639f2bfd21 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] 10+ messages in thread
* [PATCH 6/6] blk-mq: cleanup disk sysfs registration
2022-06-28 17:18 cleanup block layer sysfs handling v2 Christoph Hellwig
` (4 preceding siblings ...)
2022-06-28 17:18 ` [PATCH 5/6] blk-mq: rename blk_mq_sysfs_{,un}register Christoph Hellwig
@ 2022-06-28 17:18 ` Christoph Hellwig
2022-06-28 19:06 ` cleanup block layer sysfs handling v2 Jens Axboe
6 siblings, 0 replies; 10+ messages in thread
From: Christoph Hellwig @ 2022-06-28 17:18 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-block, Bart Van Assche
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>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
---
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 a92639f2bfd21..54e20edf0da30 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 b72506770b97e..85ea43eff094c 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -812,18 +812,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);
@@ -919,7 +918,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] 10+ messages in thread
* Re: cleanup block layer sysfs handling v2
2022-06-28 17:18 cleanup block layer sysfs handling v2 Christoph Hellwig
` (5 preceding siblings ...)
2022-06-28 17:18 ` [PATCH 6/6] blk-mq: cleanup disk sysfs registration Christoph Hellwig
@ 2022-06-28 19:06 ` Jens Axboe
6 siblings, 0 replies; 10+ messages in thread
From: Jens Axboe @ 2022-06-28 19:06 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: linux-block
On Tue, 28 Jun 2022 19:18:44 +0200, Christoph Hellwig wrote:
> this series cleans up various loose ends in the block layer sysfs handling.
>
> Changes since v1:
> - trivial whitespace and spelling fixes
>
> 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(-)
>
> [...]
Applied, thanks!
[1/6] block: simplify blktrace sysfs attribute creation
commit: cc5c516df028b221d94c65c47c5ae8d20f61b6f9
[2/6] block: remove a superflous queue kobject reference
commit: 060f131e9c438837f9792e456fae424e621fb881
[3/6] block: use default groups to register the queue attributes
commit: 4a8d14bba486cca6880062f1ef240cf1d45f3367
[4/6] block: remove the extra gendisk reference in __blk_mq_register_dev
commit: 81f0c2ef41b02185928563899cd4d618ffc7eebf
[5/6] blk-mq: rename blk_mq_sysfs_{,un}register
commit: eaa870f97544668025ba1f96ee267abac7b3c73c
[6/6] blk-mq: cleanup disk sysfs registration
commit: 8682b92e5ab852b93739a0f2b261fff4c733be57
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 10+ 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; 10+ 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] 10+ 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 ` Christoph Hellwig
2022-06-25 3:00 ` Bart Van Assche
0 siblings, 1 reply; 10+ 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] 10+ messages in thread
end of thread, other threads:[~2022-06-28 19:07 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-28 17:18 cleanup block layer sysfs handling v2 Christoph Hellwig
2022-06-28 17:18 ` [PATCH 1/6] block: simplify blktrace sysfs attribute creation Christoph Hellwig
2022-06-28 17:18 ` [PATCH 2/6] block: remove a superflous queue kobject reference Christoph Hellwig
2022-06-28 17:18 ` [PATCH 3/6] block: use default groups to register the queue attributes Christoph Hellwig
2022-06-28 17:18 ` [PATCH 4/6] block: remove the extra gendisk reference in __blk_mq_register_dev Christoph Hellwig
2022-06-28 17:18 ` [PATCH 5/6] blk-mq: rename blk_mq_sysfs_{,un}register Christoph Hellwig
2022-06-28 17:18 ` [PATCH 6/6] blk-mq: cleanup disk sysfs registration Christoph Hellwig
2022-06-28 19:06 ` cleanup block layer sysfs handling v2 Jens Axboe
-- strict thread matches above, loose matches on Subject: below --
2022-06-24 5:25 cleanup block layer sysfs handling Christoph Hellwig
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
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.