* [PATCH v3 0/8] blk-mq debugfs patches for kernel v4.12
@ 2017-04-18 23:29 Bart Van Assche
2017-04-18 23:29 ` [PATCH v3 1/8] blk-mq: Register <dev>/queue/mq after having registered <dev>/queue Bart Van Assche
` (7 more replies)
0 siblings, 8 replies; 21+ messages in thread
From: Bart Van Assche @ 2017-04-18 23:29 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-block, Bart Van Assche
Hello Jens,
Please consider the eight patches in this series for kernel v4.12.
These patches improve blk-mq debugfs support.
Thanks,
Bart.
Changes compared to v2:
- Changed the mutex_lock() calls in registration methods into
mutex_lock_interruptible() since these functions can be called from
the context of a user space process.
- Avoid that the blk_mq_register_dev() changes in patch 1/8 cause a
deadlock.
Changes compared to v1:
- Added two patches and replaced patch 1/6 such that debugfs
attributes are now unregistered before freeing of a blk-mq queue
starts instead of checking the "dead" queue flag.
- Changed "rq->cmd_flags ^ op" into "rq->cmd_flags & ~REQ_OP_MASK" as
proposed by Omar.
- A seq_file pointer is now passed to the new queue_rq callback function
instead of a fixed-size char buffer.
Bart Van Assche (8):
blk-mq: Register <dev>/queue/mq after having registered <dev>/queue
blk-mq: Let blk_mq_debugfs_register() look up the queue name
blk-mq: Unregister debugfs attributes earlier
blk-mq: Move the "state" debugfs attribute one level down
blk-mq: Make blk_flags_show() callers append a newline character
blk-mq: Show operation, cmd_flags and rq_flags names
blk-mq: Add blk_mq_ops.show_rq()
scsi: Implement blk_mq_ops.show_rq()
block/blk-mq-debugfs.c | 94 +++++++++++++++++++++++++++++++++++++++++--------
block/blk-mq-sysfs.c | 66 +++++++++++++++++++---------------
block/blk-mq.h | 6 ++--
block/blk-sysfs.c | 9 +++--
drivers/scsi/scsi_lib.c | 26 ++++++++++++++
include/linux/blk-mq.h | 6 ++++
6 files changed, 156 insertions(+), 51 deletions(-)
--
2.12.2
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH v3 1/8] blk-mq: Register <dev>/queue/mq after having registered <dev>/queue
2017-04-18 23:29 [PATCH v3 0/8] blk-mq debugfs patches for kernel v4.12 Bart Van Assche
@ 2017-04-18 23:29 ` Bart Van Assche
2017-04-21 22:05 ` Omar Sandoval
2017-04-18 23:29 ` [PATCH v3 2/8] blk-mq: Let blk_mq_debugfs_register() look up the queue name Bart Van Assche
` (6 subsequent siblings)
7 siblings, 1 reply; 21+ messages in thread
From: Bart Van Assche @ 2017-04-18 23:29 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-block, Bart Van Assche, Omar Sandoval, Hannes Reinecke
A later patch in this series will modify blk_mq_debugfs_register()
such that it uses q->kobj.parent to determine the name of a
request queue. Hence make sure that that pointer is initialized
before blk_mq_debugfs_register() is called. To avoid lock inversion,
protect sysfs / debugfs registration with the queue sysfs_lock
instead of the global mutex all_q_mutex.
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Cc: Omar Sandoval <osandov@fb.com>
Cc: Hannes Reinecke <hare@suse.com>
---
block/blk-mq-sysfs.c | 43 +++++++++++++++++++++++++++++++++++--------
block/blk-mq.h | 1 +
block/blk-sysfs.c | 6 +++---
3 files changed, 39 insertions(+), 11 deletions(-)
diff --git a/block/blk-mq-sysfs.c b/block/blk-mq-sysfs.c
index d745ab81033a..54ef9402914c 100644
--- a/block/blk-mq-sysfs.c
+++ b/block/blk-mq-sysfs.c
@@ -253,6 +253,8 @@ static void __blk_mq_unregister_dev(struct device *dev, struct request_queue *q)
struct blk_mq_hw_ctx *hctx;
int i;
+ lockdep_assert_held(&q->sysfs_lock);
+
queue_for_each_hw_ctx(q, hctx, i)
blk_mq_unregister_hctx(hctx);
@@ -267,9 +269,9 @@ static void __blk_mq_unregister_dev(struct device *dev, struct request_queue *q)
void blk_mq_unregister_dev(struct device *dev, struct request_queue *q)
{
- blk_mq_disable_hotplug();
+ mutex_lock(&q->sysfs_lock);
__blk_mq_unregister_dev(dev, q);
- blk_mq_enable_hotplug();
+ mutex_unlock(&q->sysfs_lock);
}
void blk_mq_hctx_kobj_init(struct blk_mq_hw_ctx *hctx)
@@ -302,12 +304,13 @@ void blk_mq_sysfs_init(struct request_queue *q)
}
}
-int blk_mq_register_dev(struct device *dev, struct request_queue *q)
+int __blk_mq_register_dev(struct device *dev, struct request_queue *q)
{
struct blk_mq_hw_ctx *hctx;
int ret, i;
- blk_mq_disable_hotplug();
+ WARN_ON_ONCE(!q->kobj.parent);
+ lockdep_assert_held(&q->sysfs_lock);
ret = kobject_add(&q->mq_kobj, kobject_get(&dev->kobj), "%s", "mq");
if (ret < 0)
@@ -327,8 +330,20 @@ int blk_mq_register_dev(struct device *dev, struct request_queue *q)
__blk_mq_unregister_dev(dev, q);
else
q->mq_sysfs_init_done = true;
+
out:
- blk_mq_enable_hotplug();
+ return ret;
+}
+
+int blk_mq_register_dev(struct device *dev, struct request_queue *q)
+{
+ int ret;
+
+ ret = mutex_lock_interruptible(&q->sysfs_lock);
+ if (ret < 0)
+ return ret;
+ ret = __blk_mq_register_dev(dev, q);
+ mutex_unlock(&q->sysfs_lock);
return ret;
}
@@ -339,23 +354,32 @@ void blk_mq_sysfs_unregister(struct request_queue *q)
struct blk_mq_hw_ctx *hctx;
int i;
+ mutex_lock(&q->sysfs_lock);
+
if (!q->mq_sysfs_init_done)
- return;
+ goto unlock;
blk_mq_debugfs_unregister_hctxs(q);
queue_for_each_hw_ctx(q, hctx, i)
blk_mq_unregister_hctx(hctx);
+
+unlock:
+ mutex_unlock(&q->sysfs_lock);
}
int blk_mq_sysfs_register(struct request_queue *q)
{
struct blk_mq_hw_ctx *hctx;
- int i, ret = 0;
+ int i, ret;
- if (!q->mq_sysfs_init_done)
+ ret = mutex_lock_interruptible(&q->sysfs_lock);
+ if (ret < 0)
return ret;
+ if (!q->mq_sysfs_init_done)
+ goto unlock;
+
blk_mq_debugfs_register_hctxs(q);
queue_for_each_hw_ctx(q, hctx, i) {
@@ -364,5 +388,8 @@ int blk_mq_sysfs_register(struct request_queue *q)
break;
}
+unlock:
+ mutex_unlock(&q->sysfs_lock);
+
return ret;
}
diff --git a/block/blk-mq.h b/block/blk-mq.h
index 524f44742816..7d955c756810 100644
--- a/block/blk-mq.h
+++ b/block/blk-mq.h
@@ -78,6 +78,7 @@ 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);
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 fc20489f0d2b..726ca28584dc 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -894,9 +894,6 @@ int blk_register_queue(struct gendisk *disk)
if (ret)
return ret;
- if (q->mq_ops)
- blk_mq_register_dev(dev, q);
-
/* Prevent changes through sysfs until registration is completed. */
mutex_lock(&q->sysfs_lock);
@@ -906,6 +903,9 @@ int blk_register_queue(struct gendisk *disk)
goto unlock;
}
+ if (q->mq_ops)
+ __blk_mq_register_dev(dev, q);
+
kobject_uevent(&q->kobj, KOBJ_ADD);
blk_wb_init(q);
--
2.12.2
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH v3 2/8] blk-mq: Let blk_mq_debugfs_register() look up the queue name
2017-04-18 23:29 [PATCH v3 0/8] blk-mq debugfs patches for kernel v4.12 Bart Van Assche
2017-04-18 23:29 ` [PATCH v3 1/8] blk-mq: Register <dev>/queue/mq after having registered <dev>/queue Bart Van Assche
@ 2017-04-18 23:29 ` Bart Van Assche
2017-04-21 22:06 ` Omar Sandoval
2017-04-18 23:29 ` [PATCH v3 3/8] blk-mq: Unregister debugfs attributes earlier Bart Van Assche
` (5 subsequent siblings)
7 siblings, 1 reply; 21+ messages in thread
From: Bart Van Assche @ 2017-04-18 23:29 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-block, Bart Van Assche, Omar Sandoval, Hannes Reinecke
A later patch will move the call of blk_mq_debugfs_register() to
a function to which the queue name is not passed as an argument.
To avoid having to add a 'name' argument to multiple callers, let
blk_mq_debugfs_register() look up the queue name.
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Cc: Omar Sandoval <osandov@fb.com>
Cc: Hannes Reinecke <hare@suse.com>
---
block/blk-mq-debugfs.c | 5 +++--
block/blk-mq-sysfs.c | 2 +-
block/blk-mq.h | 5 ++---
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c
index df9b688b877c..2a5d6d83d57c 100644
--- a/block/blk-mq-debugfs.c
+++ b/block/blk-mq-debugfs.c
@@ -782,12 +782,13 @@ static const struct blk_mq_debugfs_attr blk_mq_debugfs_ctx_attrs[] = {
{},
};
-int blk_mq_debugfs_register(struct request_queue *q, const char *name)
+int blk_mq_debugfs_register(struct request_queue *q)
{
if (!blk_debugfs_root)
return -ENOENT;
- q->debugfs_dir = debugfs_create_dir(name, blk_debugfs_root);
+ q->debugfs_dir = debugfs_create_dir(kobject_name(q->kobj.parent),
+ blk_debugfs_root);
if (!q->debugfs_dir)
goto err;
diff --git a/block/blk-mq-sysfs.c b/block/blk-mq-sysfs.c
index 54ef9402914c..727e3b675130 100644
--- a/block/blk-mq-sysfs.c
+++ b/block/blk-mq-sysfs.c
@@ -318,7 +318,7 @@ int __blk_mq_register_dev(struct device *dev, struct request_queue *q)
kobject_uevent(&q->mq_kobj, KOBJ_ADD);
- blk_mq_debugfs_register(q, kobject_name(&dev->kobj));
+ blk_mq_debugfs_register(q);
queue_for_each_hw_ctx(q, hctx, i) {
ret = blk_mq_register_hctx(hctx);
diff --git a/block/blk-mq.h b/block/blk-mq.h
index 7d955c756810..9049c0f11505 100644
--- a/block/blk-mq.h
+++ b/block/blk-mq.h
@@ -87,13 +87,12 @@ extern void blk_mq_hctx_kobj_init(struct blk_mq_hw_ctx *hctx);
* debugfs helpers
*/
#ifdef CONFIG_BLK_DEBUG_FS
-int blk_mq_debugfs_register(struct request_queue *q, const char *name);
+int blk_mq_debugfs_register(struct request_queue *q);
void blk_mq_debugfs_unregister(struct request_queue *q);
int blk_mq_debugfs_register_hctxs(struct request_queue *q);
void blk_mq_debugfs_unregister_hctxs(struct request_queue *q);
#else
-static inline int blk_mq_debugfs_register(struct request_queue *q,
- const char *name)
+static inline int blk_mq_debugfs_register(struct request_queue *q)
{
return 0;
}
--
2.12.2
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH v3 3/8] blk-mq: Unregister debugfs attributes earlier
2017-04-18 23:29 [PATCH v3 0/8] blk-mq debugfs patches for kernel v4.12 Bart Van Assche
2017-04-18 23:29 ` [PATCH v3 1/8] blk-mq: Register <dev>/queue/mq after having registered <dev>/queue Bart Van Assche
2017-04-18 23:29 ` [PATCH v3 2/8] blk-mq: Let blk_mq_debugfs_register() look up the queue name Bart Van Assche
@ 2017-04-18 23:29 ` Bart Van Assche
2017-04-21 22:16 ` Omar Sandoval
2017-04-18 23:29 ` [PATCH v3 4/8] blk-mq: Move the "state" debugfs attribute one level down Bart Van Assche
` (4 subsequent siblings)
7 siblings, 1 reply; 21+ messages in thread
From: Bart Van Assche @ 2017-04-18 23:29 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-block, Bart Van Assche, Omar Sandoval, Hannes Reinecke
One of the debugfs attributes allows to run a queue. Since running
a queue after a queue has entered the "dead" state is not allowed
and even can cause a kernel crash, unregister the debugfs attributes
before a queue reaches the "dead" state.
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Cc: Omar Sandoval <osandov@fb.com>
Cc: Hannes Reinecke <hare@suse.com>
---
block/blk-mq-sysfs.c | 31 ++++++-------------------------
block/blk-sysfs.c | 3 +--
2 files changed, 7 insertions(+), 27 deletions(-)
diff --git a/block/blk-mq-sysfs.c b/block/blk-mq-sysfs.c
index 727e3b675130..1b2107f229ee 100644
--- a/block/blk-mq-sysfs.c
+++ b/block/blk-mq-sysfs.c
@@ -258,7 +258,7 @@ static void __blk_mq_unregister_dev(struct device *dev, struct request_queue *q)
queue_for_each_hw_ctx(q, hctx, i)
blk_mq_unregister_hctx(hctx);
- blk_mq_debugfs_unregister_hctxs(q);
+ blk_mq_debugfs_unregister(q);
kobject_uevent(&q->mq_kobj, KOBJ_REMOVE);
kobject_del(&q->mq_kobj);
@@ -306,8 +306,7 @@ void blk_mq_sysfs_init(struct request_queue *q)
int __blk_mq_register_dev(struct device *dev, struct request_queue *q)
{
- struct blk_mq_hw_ctx *hctx;
- int ret, i;
+ int ret;
WARN_ON_ONCE(!q->kobj.parent);
lockdep_assert_held(&q->sysfs_lock);
@@ -318,14 +317,7 @@ int __blk_mq_register_dev(struct device *dev, struct request_queue *q)
kobject_uevent(&q->mq_kobj, KOBJ_ADD);
- blk_mq_debugfs_register(q);
-
- queue_for_each_hw_ctx(q, hctx, i) {
- ret = blk_mq_register_hctx(hctx);
- if (ret)
- break;
- }
-
+ ret = blk_mq_debugfs_register(q);
if (ret)
__blk_mq_unregister_dev(dev, q);
else
@@ -351,20 +343,9 @@ EXPORT_SYMBOL_GPL(blk_mq_register_dev);
void blk_mq_sysfs_unregister(struct request_queue *q)
{
- struct blk_mq_hw_ctx *hctx;
- int i;
-
mutex_lock(&q->sysfs_lock);
-
- if (!q->mq_sysfs_init_done)
- goto unlock;
-
- blk_mq_debugfs_unregister_hctxs(q);
-
- queue_for_each_hw_ctx(q, hctx, i)
- blk_mq_unregister_hctx(hctx);
-
-unlock:
+ if (q->mq_sysfs_init_done)
+ blk_mq_debugfs_unregister(q);
mutex_unlock(&q->sysfs_lock);
}
@@ -380,7 +361,7 @@ int blk_mq_sysfs_register(struct request_queue *q)
if (!q->mq_sysfs_init_done)
goto unlock;
- blk_mq_debugfs_register_hctxs(q);
+ blk_mq_debugfs_register(q);
queue_for_each_hw_ctx(q, hctx, i) {
ret = blk_mq_register_hctx(hctx);
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index 726ca28584dc..3b6eca07b7a4 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -823,8 +823,7 @@ static void blk_release_queue(struct kobject *kobj)
blk_trace_shutdown(q);
- if (q->mq_ops)
- blk_mq_debugfs_unregister(q);
+ WARN_ON_ONCE(q->debugfs_dir);
if (q->bio_split)
bioset_free(q->bio_split);
--
2.12.2
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH v3 4/8] blk-mq: Move the "state" debugfs attribute one level down
2017-04-18 23:29 [PATCH v3 0/8] blk-mq debugfs patches for kernel v4.12 Bart Van Assche
` (2 preceding siblings ...)
2017-04-18 23:29 ` [PATCH v3 3/8] blk-mq: Unregister debugfs attributes earlier Bart Van Assche
@ 2017-04-18 23:29 ` Bart Van Assche
2017-04-18 23:29 ` [PATCH v3 5/8] blk-mq: Make blk_flags_show() callers append a newline character Bart Van Assche
` (3 subsequent siblings)
7 siblings, 0 replies; 21+ messages in thread
From: Bart Van Assche @ 2017-04-18 23:29 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-block, Bart Van Assche, Hannes Reinecke
Move the "state" attribute from the top level to the "mq" directory
as requested by Omar.
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: Omar Sandoval <osandov@fb.com>
Cc: Hannes Reinecke <hare@suse.com>
---
block/blk-mq-debugfs.c | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)
diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c
index 2a5d6d83d57c..34cac9a5fd28 100644
--- a/block/blk-mq-debugfs.c
+++ b/block/blk-mq-debugfs.c
@@ -141,11 +141,6 @@ static const struct file_operations blk_queue_flags_fops = {
.write = blk_queue_flags_store,
};
-static const struct blk_mq_debugfs_attr blk_queue_attrs[] = {
- {"state", 0600, &blk_queue_flags_fops},
- {},
-};
-
static void print_stat(struct seq_file *m, struct blk_rq_stat *stat)
{
if (stat->nr_samples) {
@@ -754,6 +749,7 @@ static const struct file_operations ctx_completed_fops = {
static const struct blk_mq_debugfs_attr blk_mq_debugfs_queue_attrs[] = {
{"poll_stat", 0400, &queue_poll_stat_fops},
+ {"state", 0600, &blk_queue_flags_fops},
{},
};
@@ -870,9 +866,6 @@ int blk_mq_debugfs_register_hctxs(struct request_queue *q)
if (!q->debugfs_dir)
return -ENOENT;
- if (!debugfs_create_files(q->debugfs_dir, q, blk_queue_attrs))
- goto err;
-
q->mq_debugfs_dir = debugfs_create_dir("mq", q->debugfs_dir);
if (!q->mq_debugfs_dir)
goto err;
--
2.12.2
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH v3 5/8] blk-mq: Make blk_flags_show() callers append a newline character
2017-04-18 23:29 [PATCH v3 0/8] blk-mq debugfs patches for kernel v4.12 Bart Van Assche
` (3 preceding siblings ...)
2017-04-18 23:29 ` [PATCH v3 4/8] blk-mq: Move the "state" debugfs attribute one level down Bart Van Assche
@ 2017-04-18 23:29 ` Bart Van Assche
2017-04-18 23:29 ` [PATCH v3 6/8] blk-mq: Show operation, cmd_flags and rq_flags names Bart Van Assche
` (2 subsequent siblings)
7 siblings, 0 replies; 21+ messages in thread
From: Bart Van Assche @ 2017-04-18 23:29 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-block, Bart Van Assche, Hannes Reinecke
This patch does not change any functionality but makes it possible
to produce a single line of output with multiple flag-to-name
translations.
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: Omar Sandoval <osandov@fb.com>
Cc: Hannes Reinecke <hare@suse.com>
---
block/blk-mq-debugfs.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c
index 34cac9a5fd28..27054293b37b 100644
--- a/block/blk-mq-debugfs.c
+++ b/block/blk-mq-debugfs.c
@@ -60,7 +60,6 @@ static int blk_flags_show(struct seq_file *m, const unsigned long flags,
else
seq_printf(m, "%d", i);
}
- seq_puts(m, "\n");
return 0;
}
@@ -102,6 +101,7 @@ static int blk_queue_flags_show(struct seq_file *m, void *v)
blk_flags_show(m, q->queue_flags, blk_queue_flag_name,
ARRAY_SIZE(blk_queue_flag_name));
+ seq_puts(m, "\n");
return 0;
}
@@ -190,6 +190,7 @@ static int hctx_state_show(struct seq_file *m, void *v)
blk_flags_show(m, hctx->state, hctx_state_name,
ARRAY_SIZE(hctx_state_name));
+ seq_puts(m, "\n");
return 0;
}
@@ -233,6 +234,7 @@ static int hctx_flags_show(struct seq_file *m, void *v)
blk_flags_show(m,
hctx->flags ^ BLK_ALLOC_POLICY_TO_MQ_FLAG(alloc_policy),
hctx_flag_name, ARRAY_SIZE(hctx_flag_name));
+ seq_puts(m, "\n");
return 0;
}
--
2.12.2
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH v3 6/8] blk-mq: Show operation, cmd_flags and rq_flags names
2017-04-18 23:29 [PATCH v3 0/8] blk-mq debugfs patches for kernel v4.12 Bart Van Assche
` (4 preceding siblings ...)
2017-04-18 23:29 ` [PATCH v3 5/8] blk-mq: Make blk_flags_show() callers append a newline character Bart Van Assche
@ 2017-04-18 23:29 ` Bart Van Assche
2017-04-18 23:29 ` [PATCH v3 7/8] blk-mq: Add blk_mq_ops.show_rq() Bart Van Assche
2017-04-18 23:29 ` Bart Van Assche
7 siblings, 0 replies; 21+ messages in thread
From: Bart Van Assche @ 2017-04-18 23:29 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-block, Bart Van Assche, Hannes Reinecke
Show the operation name, .cmd_flags and .rq_flags as names instead
of numbers.
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: Omar Sandoval <osandov@fb.com>
Cc: Hannes Reinecke <hare@suse.com>
---
block/blk-mq-debugfs.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 69 insertions(+), 3 deletions(-)
diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c
index 27054293b37b..64b584ba576a 100644
--- a/block/blk-mq-debugfs.c
+++ b/block/blk-mq-debugfs.c
@@ -250,13 +250,79 @@ static const struct file_operations hctx_flags_fops = {
.release = single_release,
};
+static const char *const op_name[] = {
+ [REQ_OP_READ] = "READ",
+ [REQ_OP_WRITE] = "WRITE",
+ [REQ_OP_FLUSH] = "FLUSH",
+ [REQ_OP_DISCARD] = "DISCARD",
+ [REQ_OP_ZONE_REPORT] = "ZONE_REPORT",
+ [REQ_OP_SECURE_ERASE] = "SECURE_ERASE",
+ [REQ_OP_ZONE_RESET] = "ZONE_RESET",
+ [REQ_OP_WRITE_SAME] = "WRITE_SAME",
+ [REQ_OP_WRITE_ZEROES] = "WRITE_ZEROES",
+ [REQ_OP_SCSI_IN] = "SCSI_IN",
+ [REQ_OP_SCSI_OUT] = "SCSI_OUT",
+ [REQ_OP_DRV_IN] = "DRV_IN",
+ [REQ_OP_DRV_OUT] = "DRV_OUT",
+};
+
+static const char *const cmd_flag_name[] = {
+ [__REQ_FAILFAST_DEV] = "FAILFAST_DEV",
+ [__REQ_FAILFAST_TRANSPORT] = "FAILFAST_TRANSPORT",
+ [__REQ_FAILFAST_DRIVER] = "FAILFAST_DRIVER",
+ [__REQ_SYNC] = "SYNC",
+ [__REQ_META] = "META",
+ [__REQ_PRIO] = "PRIO",
+ [__REQ_NOMERGE] = "NOMERGE",
+ [__REQ_IDLE] = "IDLE",
+ [__REQ_INTEGRITY] = "INTEGRITY",
+ [__REQ_FUA] = "FUA",
+ [__REQ_PREFLUSH] = "PREFLUSH",
+ [__REQ_RAHEAD] = "RAHEAD",
+ [__REQ_BACKGROUND] = "BACKGROUND",
+ [__REQ_NR_BITS] = "NR_BITS",
+};
+
+static const char *const rqf_name[] = {
+ [ilog2(RQF_SORTED)] = "SORTED",
+ [ilog2(RQF_STARTED)] = "STARTED",
+ [ilog2(RQF_QUEUED)] = "QUEUED",
+ [ilog2(RQF_SOFTBARRIER)] = "SOFTBARRIER",
+ [ilog2(RQF_FLUSH_SEQ)] = "FLUSH_SEQ",
+ [ilog2(RQF_MIXED_MERGE)] = "MIXED_MERGE",
+ [ilog2(RQF_MQ_INFLIGHT)] = "MQ_INFLIGHT",
+ [ilog2(RQF_DONTPREP)] = "DONTPREP",
+ [ilog2(RQF_PREEMPT)] = "PREEMPT",
+ [ilog2(RQF_COPY_USER)] = "COPY_USER",
+ [ilog2(RQF_FAILED)] = "FAILED",
+ [ilog2(RQF_QUIET)] = "QUIET",
+ [ilog2(RQF_ELVPRIV)] = "ELVPRIV",
+ [ilog2(RQF_IO_STAT)] = "IO_STAT",
+ [ilog2(RQF_ALLOCED)] = "ALLOCED",
+ [ilog2(RQF_PM)] = "PM",
+ [ilog2(RQF_HASHED)] = "HASHED",
+ [ilog2(RQF_STATS)] = "STATS",
+ [ilog2(RQF_SPECIAL_PAYLOAD)] = "SPECIAL_PAYLOAD",
+};
+
static int blk_mq_debugfs_rq_show(struct seq_file *m, void *v)
{
struct request *rq = list_entry_rq(v);
+ const unsigned int op = rq->cmd_flags & REQ_OP_MASK;
- seq_printf(m, "%p {.cmd_flags=0x%x, .rq_flags=0x%x, .tag=%d, .internal_tag=%d}\n",
- rq, rq->cmd_flags, (__force unsigned int)rq->rq_flags,
- rq->tag, rq->internal_tag);
+ seq_printf(m, "%p {.op=", rq);
+ if (op < ARRAY_SIZE(op_name) && op_name[op])
+ seq_printf(m, "%s", op_name[op]);
+ else
+ seq_printf(m, "%d", op);
+ seq_puts(m, ", .cmd_flags=");
+ blk_flags_show(m, rq->cmd_flags & ~REQ_OP_MASK, cmd_flag_name,
+ ARRAY_SIZE(cmd_flag_name));
+ seq_puts(m, ", .rq_flags=");
+ blk_flags_show(m, (__force unsigned int)rq->rq_flags, rqf_name,
+ ARRAY_SIZE(rqf_name));
+ seq_printf(m, ", .tag=%d, .internal_tag=%d}\n", rq->tag,
+ rq->internal_tag);
return 0;
}
--
2.12.2
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH v3 7/8] blk-mq: Add blk_mq_ops.show_rq()
2017-04-18 23:29 [PATCH v3 0/8] blk-mq debugfs patches for kernel v4.12 Bart Van Assche
` (5 preceding siblings ...)
2017-04-18 23:29 ` [PATCH v3 6/8] blk-mq: Show operation, cmd_flags and rq_flags names Bart Van Assche
@ 2017-04-18 23:29 ` Bart Van Assche
2017-04-20 20:49 ` Omar Sandoval
2017-04-18 23:29 ` Bart Van Assche
7 siblings, 1 reply; 21+ messages in thread
From: Bart Van Assche @ 2017-04-18 23:29 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-block, Bart Van Assche, Omar Sandoval, Hannes Reinecke
This new callback function will be used in the next patch to show
more information about SCSI requests.
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Cc: Omar Sandoval <osandov@fb.com>
Cc: Hannes Reinecke <hare@suse.com>
---
block/blk-mq-debugfs.c | 6 +++++-
include/linux/blk-mq.h | 6 ++++++
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c
index 64b584ba576a..b1b669f98ea0 100644
--- a/block/blk-mq-debugfs.c
+++ b/block/blk-mq-debugfs.c
@@ -308,6 +308,7 @@ static const char *const rqf_name[] = {
static int blk_mq_debugfs_rq_show(struct seq_file *m, void *v)
{
struct request *rq = list_entry_rq(v);
+ const struct blk_mq_ops *const mq_ops = rq->q->mq_ops;
const unsigned int op = rq->cmd_flags & REQ_OP_MASK;
seq_printf(m, "%p {.op=", rq);
@@ -321,8 +322,11 @@ static int blk_mq_debugfs_rq_show(struct seq_file *m, void *v)
seq_puts(m, ", .rq_flags=");
blk_flags_show(m, (__force unsigned int)rq->rq_flags, rqf_name,
ARRAY_SIZE(rqf_name));
- seq_printf(m, ", .tag=%d, .internal_tag=%d}\n", rq->tag,
+ seq_printf(m, ", .tag=%d, .internal_tag=%d", rq->tag,
rq->internal_tag);
+ if (mq_ops->show_rq)
+ mq_ops->show_rq(m, rq);
+ seq_puts(m, "}\n");
return 0;
}
diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index d75de612845d..a761d275cb44 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -121,6 +121,12 @@ struct blk_mq_ops {
softirq_done_fn *complete;
/*
+ * Used by the debugfs implementation to show driver-specific
+ * information about a request.
+ */
+ void (*show_rq)(struct seq_file *m, struct request *rq);
+
+ /*
* Called when the block layer side of a hardware queue has been
* set up, allowing the driver to allocate/init matching structures.
* Ditto for exit/teardown.
--
2.12.2
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH v3 8/8] scsi: Implement blk_mq_ops.show_rq()
2017-04-18 23:29 [PATCH v3 0/8] blk-mq debugfs patches for kernel v4.12 Bart Van Assche
@ 2017-04-18 23:29 ` Bart Van Assche
2017-04-18 23:29 ` [PATCH v3 2/8] blk-mq: Let blk_mq_debugfs_register() look up the queue name Bart Van Assche
` (6 subsequent siblings)
7 siblings, 0 replies; 21+ messages in thread
From: Bart Van Assche @ 2017-04-18 23:29 UTC (permalink / raw)
To: Jens Axboe
Cc: linux-block, Bart Van Assche, Martin K . Petersen,
James Bottomley, Omar Sandoval, Hannes Reinecke, linux-scsi
Show the SCSI CDB, .eh_eflags and .result for pending SCSI commands
in /sys/kernel/debug/block/*/mq/*/dispatch and */rq_list.
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Cc: Martin K. Petersen <martin.petersen@oracle.com>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
Cc: Omar Sandoval <osandov@fb.com>
Cc: Hannes Reinecke <hare@suse.com>
Cc: <linux-scsi@vger.kernel.org>
---
drivers/scsi/scsi_lib.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 7bc4513bf4e4..52604573e4b6 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -2126,6 +2126,31 @@ static void scsi_exit_rq(struct request_queue *q, struct request *rq)
scsi_free_sense_buffer(shost, cmd->sense_buffer);
}
+static const char *const ehflag_name[] = {
+ [ilog2(SCSI_EH_CANCEL_CMD)] = "CANCEL_CMD",
+ [ilog2(SCSI_EH_ABORT_SCHEDULED)] = "ABORT_SCHEDULED",
+};
+
+static void scsi_show_rq(struct seq_file *m, struct request *rq)
+{
+ struct scsi_cmnd *cmd = container_of(scsi_req(rq), typeof(*cmd), req);
+ unsigned int i;
+
+ seq_puts(m, ", .cmd =");
+ for (i = 0; i < cmd->cmd_len; i++)
+ seq_printf(m, " %02x", cmd->cmnd[i]);
+ seq_puts(m, ", .eh_eflags =");
+ for (i = 0; i < sizeof(cmd->eh_eflags) * BITS_PER_BYTE; i++) {
+ if (!(cmd->eh_eflags & BIT(i)))
+ continue;
+ if (i < ARRAY_SIZE(ehflag_name) && ehflag_name[i])
+ seq_printf(m, " %s", ehflag_name[i]);
+ else
+ seq_printf(m, " %d", i);
+ }
+ seq_printf(m, ", .result = %#06x", cmd->result);
+}
+
struct request_queue *scsi_alloc_queue(struct scsi_device *sdev)
{
struct Scsi_Host *shost = sdev->host;
@@ -2158,6 +2183,7 @@ static const struct blk_mq_ops scsi_mq_ops = {
.queue_rq = scsi_queue_rq,
.complete = scsi_softirq_done,
.timeout = scsi_timeout,
+ .show_rq = scsi_show_rq,
.init_request = scsi_init_request,
.exit_request = scsi_exit_request,
.map_queues = scsi_map_queues,
--
2.12.2
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH v3 8/8] scsi: Implement blk_mq_ops.show_rq()
@ 2017-04-18 23:29 ` Bart Van Assche
0 siblings, 0 replies; 21+ messages in thread
From: Bart Van Assche @ 2017-04-18 23:29 UTC (permalink / raw)
To: Jens Axboe
Cc: linux-block, Bart Van Assche, Martin K . Petersen,
James Bottomley, Omar Sandoval, Hannes Reinecke, linux-scsi
Show the SCSI CDB, .eh_eflags and .result for pending SCSI commands
in /sys/kernel/debug/block/*/mq/*/dispatch and */rq_list.
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Cc: Martin K. Petersen <martin.petersen@oracle.com>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
Cc: Omar Sandoval <osandov@fb.com>
Cc: Hannes Reinecke <hare@suse.com>
Cc: <linux-scsi@vger.kernel.org>
---
drivers/scsi/scsi_lib.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 7bc4513bf4e4..52604573e4b6 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -2126,6 +2126,31 @@ static void scsi_exit_rq(struct request_queue *q, struct request *rq)
scsi_free_sense_buffer(shost, cmd->sense_buffer);
}
+static const char *const ehflag_name[] = {
+ [ilog2(SCSI_EH_CANCEL_CMD)] = "CANCEL_CMD",
+ [ilog2(SCSI_EH_ABORT_SCHEDULED)] = "ABORT_SCHEDULED",
+};
+
+static void scsi_show_rq(struct seq_file *m, struct request *rq)
+{
+ struct scsi_cmnd *cmd = container_of(scsi_req(rq), typeof(*cmd), req);
+ unsigned int i;
+
+ seq_puts(m, ", .cmd =");
+ for (i = 0; i < cmd->cmd_len; i++)
+ seq_printf(m, " %02x", cmd->cmnd[i]);
+ seq_puts(m, ", .eh_eflags =");
+ for (i = 0; i < sizeof(cmd->eh_eflags) * BITS_PER_BYTE; i++) {
+ if (!(cmd->eh_eflags & BIT(i)))
+ continue;
+ if (i < ARRAY_SIZE(ehflag_name) && ehflag_name[i])
+ seq_printf(m, " %s", ehflag_name[i]);
+ else
+ seq_printf(m, " %d", i);
+ }
+ seq_printf(m, ", .result = %#06x", cmd->result);
+}
+
struct request_queue *scsi_alloc_queue(struct scsi_device *sdev)
{
struct Scsi_Host *shost = sdev->host;
@@ -2158,6 +2183,7 @@ static const struct blk_mq_ops scsi_mq_ops = {
.queue_rq = scsi_queue_rq,
.complete = scsi_softirq_done,
.timeout = scsi_timeout,
+ .show_rq = scsi_show_rq,
.init_request = scsi_init_request,
.exit_request = scsi_exit_request,
.map_queues = scsi_map_queues,
--
2.12.2
^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATCH v3 8/8] scsi: Implement blk_mq_ops.show_rq()
2017-04-18 23:29 ` Bart Van Assche
@ 2017-04-19 23:25 ` Martin K. Petersen
-1 siblings, 0 replies; 21+ messages in thread
From: Martin K. Petersen @ 2017-04-19 23:25 UTC (permalink / raw)
To: Bart Van Assche
Cc: Jens Axboe, linux-block, Martin K . Petersen, James Bottomley,
Omar Sandoval, Hannes Reinecke, linux-scsi
Bart Van Assche <bart.vanassche@sandisk.com> writes:
Bart,
> Show the SCSI CDB, .eh_eflags and .result for pending SCSI commands
> in /sys/kernel/debug/block/*/mq/*/dispatch and */rq_list.
SCSI_EH_CANCEL_CMD is no more (as of a06586325f37).
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v3 8/8] scsi: Implement blk_mq_ops.show_rq()
@ 2017-04-19 23:25 ` Martin K. Petersen
0 siblings, 0 replies; 21+ messages in thread
From: Martin K. Petersen @ 2017-04-19 23:25 UTC (permalink / raw)
To: Bart Van Assche
Cc: Jens Axboe, linux-block, Martin K . Petersen, James Bottomley,
Omar Sandoval, Hannes Reinecke, linux-scsi
Bart Van Assche <bart.vanassche@sandisk.com> writes:
Bart,
> Show the SCSI CDB, .eh_eflags and .result for pending SCSI commands
> in /sys/kernel/debug/block/*/mq/*/dispatch and */rq_list.
SCSI_EH_CANCEL_CMD is no more (as of a06586325f37).
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v3 8/8] scsi: Implement blk_mq_ops.show_rq()
2017-04-19 23:25 ` Martin K. Petersen
@ 2017-04-19 23:29 ` Bart Van Assche
-1 siblings, 0 replies; 21+ messages in thread
From: Bart Van Assche @ 2017-04-19 23:29 UTC (permalink / raw)
To: martin.petersen
Cc: linux-scsi, James.Bottomley, linux-block, osandov, hare, axboe
On Wed, 2017-04-19 at 19:25 -0400, Martin K. Petersen wrote:
> Bart Van Assche <bart.vanassche@sandisk.com> writes:
> > Show the SCSI CDB, .eh_eflags and .result for pending SCSI commands
> > in /sys/kernel/debug/block/*/mq/*/dispatch and */rq_list.
>=20
> SCSI_EH_CANCEL_CMD is no more (as of a06586325f37).
Thanks Martin. I will remove that flag when I repost this patch series.
Bart.=
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v3 8/8] scsi: Implement blk_mq_ops.show_rq()
@ 2017-04-19 23:29 ` Bart Van Assche
0 siblings, 0 replies; 21+ messages in thread
From: Bart Van Assche @ 2017-04-19 23:29 UTC (permalink / raw)
To: martin.petersen
Cc: linux-scsi, James.Bottomley, linux-block, osandov, hare, axboe
On Wed, 2017-04-19 at 19:25 -0400, Martin K. Petersen wrote:
> Bart Van Assche <bart.vanassche@sandisk.com> writes:
> > Show the SCSI CDB, .eh_eflags and .result for pending SCSI commands
> > in /sys/kernel/debug/block/*/mq/*/dispatch and */rq_list.
>
> SCSI_EH_CANCEL_CMD is no more (as of a06586325f37).
Thanks Martin. I will remove that flag when I repost this patch series.
Bart.
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v3 7/8] blk-mq: Add blk_mq_ops.show_rq()
2017-04-18 23:29 ` [PATCH v3 7/8] blk-mq: Add blk_mq_ops.show_rq() Bart Van Assche
@ 2017-04-20 20:49 ` Omar Sandoval
0 siblings, 0 replies; 21+ messages in thread
From: Omar Sandoval @ 2017-04-20 20:49 UTC (permalink / raw)
To: Bart Van Assche; +Cc: Jens Axboe, linux-block, Omar Sandoval, Hannes Reinecke
On Tue, Apr 18, 2017 at 04:29:48PM -0700, Bart Van Assche wrote:
> This new callback function will be used in the next patch to show
> more information about SCSI requests.
Reviewed-by: Omar Sandoval <osandov@fb.com>
> Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
> Cc: Omar Sandoval <osandov@fb.com>
> Cc: Hannes Reinecke <hare@suse.com>
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v3 1/8] blk-mq: Register <dev>/queue/mq after having registered <dev>/queue
2017-04-18 23:29 ` [PATCH v3 1/8] blk-mq: Register <dev>/queue/mq after having registered <dev>/queue Bart Van Assche
@ 2017-04-21 22:05 ` Omar Sandoval
2017-04-21 22:09 ` Bart Van Assche
0 siblings, 1 reply; 21+ messages in thread
From: Omar Sandoval @ 2017-04-21 22:05 UTC (permalink / raw)
To: Bart Van Assche; +Cc: Jens Axboe, linux-block, Omar Sandoval, Hannes Reinecke
On Tue, Apr 18, 2017 at 04:29:42PM -0700, Bart Van Assche wrote:
> A later patch in this series will modify blk_mq_debugfs_register()
> such that it uses q->kobj.parent to determine the name of a
> request queue. Hence make sure that that pointer is initialized
> before blk_mq_debugfs_register() is called. To avoid lock inversion,
> protect sysfs / debugfs registration with the queue sysfs_lock
> instead of the global mutex all_q_mutex.
I think this is sane, I don't see why we would need all_q_mutex for
this. One comment below, however.
> Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
> Cc: Omar Sandoval <osandov@fb.com>
> Cc: Hannes Reinecke <hare@suse.com>
> ---
> block/blk-mq-sysfs.c | 43 +++++++++++++++++++++++++++++++++++--------
> block/blk-mq.h | 1 +
> block/blk-sysfs.c | 6 +++---
> 3 files changed, 39 insertions(+), 11 deletions(-)
>
> diff --git a/block/blk-mq-sysfs.c b/block/blk-mq-sysfs.c
> index d745ab81033a..54ef9402914c 100644
> --- a/block/blk-mq-sysfs.c
> +++ b/block/blk-mq-sysfs.c
> @@ -253,6 +253,8 @@ static void __blk_mq_unregister_dev(struct device *dev, struct request_queue *q)
> struct blk_mq_hw_ctx *hctx;
> int i;
>
> + lockdep_assert_held(&q->sysfs_lock);
> +
> queue_for_each_hw_ctx(q, hctx, i)
> blk_mq_unregister_hctx(hctx);
>
> @@ -267,9 +269,9 @@ static void __blk_mq_unregister_dev(struct device *dev, struct request_queue *q)
>
> void blk_mq_unregister_dev(struct device *dev, struct request_queue *q)
> {
> - blk_mq_disable_hotplug();
> + mutex_lock(&q->sysfs_lock);
> __blk_mq_unregister_dev(dev, q);
> - blk_mq_enable_hotplug();
> + mutex_unlock(&q->sysfs_lock);
> }
>
> void blk_mq_hctx_kobj_init(struct blk_mq_hw_ctx *hctx)
> @@ -302,12 +304,13 @@ void blk_mq_sysfs_init(struct request_queue *q)
> }
> }
>
> -int blk_mq_register_dev(struct device *dev, struct request_queue *q)
> +int __blk_mq_register_dev(struct device *dev, struct request_queue *q)
> {
> struct blk_mq_hw_ctx *hctx;
> int ret, i;
>
> - blk_mq_disable_hotplug();
> + WARN_ON_ONCE(!q->kobj.parent);
> + lockdep_assert_held(&q->sysfs_lock);
>
> ret = kobject_add(&q->mq_kobj, kobject_get(&dev->kobj), "%s", "mq");
> if (ret < 0)
> @@ -327,8 +330,20 @@ int blk_mq_register_dev(struct device *dev, struct request_queue *q)
> __blk_mq_unregister_dev(dev, q);
> else
> q->mq_sysfs_init_done = true;
> +
> out:
> - blk_mq_enable_hotplug();
> + return ret;
> +}
> +
> +int blk_mq_register_dev(struct device *dev, struct request_queue *q)
> +{
> + int ret;
> +
> + ret = mutex_lock_interruptible(&q->sysfs_lock);
Why did you make this interruptible? blk_mq_disable_hotplug() wasn't
interruptible before, so now dm_mq_init_request_queue() can fail
silently if it is interrupted.
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v3 2/8] blk-mq: Let blk_mq_debugfs_register() look up the queue name
2017-04-18 23:29 ` [PATCH v3 2/8] blk-mq: Let blk_mq_debugfs_register() look up the queue name Bart Van Assche
@ 2017-04-21 22:06 ` Omar Sandoval
0 siblings, 0 replies; 21+ messages in thread
From: Omar Sandoval @ 2017-04-21 22:06 UTC (permalink / raw)
To: Bart Van Assche; +Cc: Jens Axboe, linux-block, Omar Sandoval, Hannes Reinecke
On Tue, Apr 18, 2017 at 04:29:43PM -0700, Bart Van Assche wrote:
> A later patch will move the call of blk_mq_debugfs_register() to
> a function to which the queue name is not passed as an argument.
> To avoid having to add a 'name' argument to multiple callers, let
> blk_mq_debugfs_register() look up the queue name.
Reviewed-by: Omar Sandoval <osandov@fb.com>
> Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
> Cc: Omar Sandoval <osandov@fb.com>
> Cc: Hannes Reinecke <hare@suse.com>
> ---
> block/blk-mq-debugfs.c | 5 +++--
> block/blk-mq-sysfs.c | 2 +-
> block/blk-mq.h | 5 ++---
> 3 files changed, 6 insertions(+), 6 deletions(-)
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v3 1/8] blk-mq: Register <dev>/queue/mq after having registered <dev>/queue
2017-04-21 22:05 ` Omar Sandoval
@ 2017-04-21 22:09 ` Bart Van Assche
2017-04-21 22:11 ` Omar Sandoval
0 siblings, 1 reply; 21+ messages in thread
From: Bart Van Assche @ 2017-04-21 22:09 UTC (permalink / raw)
To: osandov; +Cc: hare, linux-block, osandov, axboe
On Fri, 2017-04-21 at 15:05 -0700, Omar Sandoval wrote:
> On Tue, Apr 18, 2017 at 04:29:42PM -0700, Bart Van Assche wrote:
> > +int blk_mq_register_dev(struct device *dev, struct request_queue *q)
> > +{
> > + int ret;
> > +
> > + ret =3D mutex_lock_interruptible(&q->sysfs_lock);
>=20
> Why did you make this interruptible? blk_mq_disable_hotplug() wasn't
> interruptible before, so now dm_mq_init_request_queue() can fail
> silently if it is interrupted.
Hello Omar,
Whether or not blk_mq_register_dev() should be interruptible is not that
important to me. I can change this function such that it again ignores
signals.
Bart.=
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v3 1/8] blk-mq: Register <dev>/queue/mq after having registered <dev>/queue
2017-04-21 22:09 ` Bart Van Assche
@ 2017-04-21 22:11 ` Omar Sandoval
0 siblings, 0 replies; 21+ messages in thread
From: Omar Sandoval @ 2017-04-21 22:11 UTC (permalink / raw)
To: Bart Van Assche; +Cc: hare, linux-block, osandov, axboe
On Fri, Apr 21, 2017 at 10:09:14PM +0000, Bart Van Assche wrote:
> On Fri, 2017-04-21 at 15:05 -0700, Omar Sandoval wrote:
> > On Tue, Apr 18, 2017 at 04:29:42PM -0700, Bart Van Assche wrote:
> > > +int blk_mq_register_dev(struct device *dev, struct request_queue *q)
> > > +{
> > > + int ret;
> > > +
> > > + ret = mutex_lock_interruptible(&q->sysfs_lock);
> >
> > Why did you make this interruptible? blk_mq_disable_hotplug() wasn't
> > interruptible before, so now dm_mq_init_request_queue() can fail
> > silently if it is interrupted.
>
> Hello Omar,
>
> Whether or not blk_mq_register_dev() should be interruptible is not that
> important to me. I can change this function such that it again ignores
> signals.
>
> Bart.
Keeping the old behavior is safer, let's do that.
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v3 3/8] blk-mq: Unregister debugfs attributes earlier
2017-04-18 23:29 ` [PATCH v3 3/8] blk-mq: Unregister debugfs attributes earlier Bart Van Assche
@ 2017-04-21 22:16 ` Omar Sandoval
2017-04-21 22:17 ` Omar Sandoval
0 siblings, 1 reply; 21+ messages in thread
From: Omar Sandoval @ 2017-04-21 22:16 UTC (permalink / raw)
To: Bart Van Assche; +Cc: Jens Axboe, linux-block, Omar Sandoval, Hannes Reinecke
On Tue, Apr 18, 2017 at 04:29:44PM -0700, Bart Van Assche wrote:
> One of the debugfs attributes allows to run a queue. Since running
> a queue after a queue has entered the "dead" state is not allowed
> and even can cause a kernel crash, unregister the debugfs attributes
> before a queue reaches the "dead" state.
>
> Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
> Cc: Omar Sandoval <osandov@fb.com>
> Cc: Hannes Reinecke <hare@suse.com>
> ---
> block/blk-mq-sysfs.c | 31 ++++++-------------------------
> block/blk-sysfs.c | 3 +--
> 2 files changed, 7 insertions(+), 27 deletions(-)
>
> diff --git a/block/blk-mq-sysfs.c b/block/blk-mq-sysfs.c
> index 727e3b675130..1b2107f229ee 100644
> --- a/block/blk-mq-sysfs.c
> +++ b/block/blk-mq-sysfs.c
> @@ -258,7 +258,7 @@ static void __blk_mq_unregister_dev(struct device *dev, struct request_queue *q)
> queue_for_each_hw_ctx(q, hctx, i)
> blk_mq_unregister_hctx(hctx);
>
> - blk_mq_debugfs_unregister_hctxs(q);
> + blk_mq_debugfs_unregister(q);
This isn't what we want to do. First of all, we can't get remove the
/sys/kernel/debug/block/$dev directory until after we shutdown blktrace.
You unregister the top-level directory in other places, too. That should
only be done in the blk_release_queue() like it was originally.
More importantly, this doesn't actually fix the issue at hand. The
blk_mq_debugfs_unregister_hctxs() call needs to be moved earlier.
Actually, can you please rename blk_mq_debugfs_unregister_mq() to make
it more obvious that it removes the /sys/kernel/debug/block/$dev/mq
directory.
> kobject_uevent(&q->mq_kobj, KOBJ_REMOVE);
> kobject_del(&q->mq_kobj);
> @@ -306,8 +306,7 @@ void blk_mq_sysfs_init(struct request_queue *q)
>
> int __blk_mq_register_dev(struct device *dev, struct request_queue *q)
> {
> - struct blk_mq_hw_ctx *hctx;
> - int ret, i;
> + int ret;
>
> WARN_ON_ONCE(!q->kobj.parent);
> lockdep_assert_held(&q->sysfs_lock);
> @@ -318,14 +317,7 @@ int __blk_mq_register_dev(struct device *dev, struct request_queue *q)
>
> kobject_uevent(&q->mq_kobj, KOBJ_ADD);
>
> - blk_mq_debugfs_register(q);
> -
> - queue_for_each_hw_ctx(q, hctx, i) {
> - ret = blk_mq_register_hctx(hctx);
> - if (ret)
> - break;
> - }
> -
This gets rid of the /sys/block/$dev/mq/* entries in sysfs?
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v3 3/8] blk-mq: Unregister debugfs attributes earlier
2017-04-21 22:16 ` Omar Sandoval
@ 2017-04-21 22:17 ` Omar Sandoval
0 siblings, 0 replies; 21+ messages in thread
From: Omar Sandoval @ 2017-04-21 22:17 UTC (permalink / raw)
To: Bart Van Assche; +Cc: Jens Axboe, linux-block, Omar Sandoval, Hannes Reinecke
On Fri, Apr 21, 2017 at 03:16:28PM -0700, Omar Sandoval wrote:
> On Tue, Apr 18, 2017 at 04:29:44PM -0700, Bart Van Assche wrote:
> > One of the debugfs attributes allows to run a queue. Since running
> > a queue after a queue has entered the "dead" state is not allowed
> > and even can cause a kernel crash, unregister the debugfs attributes
> > before a queue reaches the "dead" state.
> >
> > Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
> > Cc: Omar Sandoval <osandov@fb.com>
> > Cc: Hannes Reinecke <hare@suse.com>
> > ---
> > block/blk-mq-sysfs.c | 31 ++++++-------------------------
> > block/blk-sysfs.c | 3 +--
> > 2 files changed, 7 insertions(+), 27 deletions(-)
> >
> > diff --git a/block/blk-mq-sysfs.c b/block/blk-mq-sysfs.c
> > index 727e3b675130..1b2107f229ee 100644
> > --- a/block/blk-mq-sysfs.c
> > +++ b/block/blk-mq-sysfs.c
> > @@ -258,7 +258,7 @@ static void __blk_mq_unregister_dev(struct device *dev, struct request_queue *q)
> > queue_for_each_hw_ctx(q, hctx, i)
> > blk_mq_unregister_hctx(hctx);
> >
> > - blk_mq_debugfs_unregister_hctxs(q);
> > + blk_mq_debugfs_unregister(q);
>
> This isn't what we want to do. First of all, we can't get remove the
> /sys/kernel/debug/block/$dev directory until after we shutdown blktrace.
> You unregister the top-level directory in other places, too. That should
> only be done in the blk_release_queue() like it was originally.
>
> More importantly, this doesn't actually fix the issue at hand. The
> blk_mq_debugfs_unregister_hctxs() call needs to be moved earlier.
> Actually, can you please rename blk_mq_debugfs_unregister_mq() to make
I meant can you please rename blk_mq_debugfs_unregister_hctxs() to
blk_mq_debugfs_unregister_mq().
^ permalink raw reply [flat|nested] 21+ messages in thread
end of thread, other threads:[~2017-04-21 22:17 UTC | newest]
Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-18 23:29 [PATCH v3 0/8] blk-mq debugfs patches for kernel v4.12 Bart Van Assche
2017-04-18 23:29 ` [PATCH v3 1/8] blk-mq: Register <dev>/queue/mq after having registered <dev>/queue Bart Van Assche
2017-04-21 22:05 ` Omar Sandoval
2017-04-21 22:09 ` Bart Van Assche
2017-04-21 22:11 ` Omar Sandoval
2017-04-18 23:29 ` [PATCH v3 2/8] blk-mq: Let blk_mq_debugfs_register() look up the queue name Bart Van Assche
2017-04-21 22:06 ` Omar Sandoval
2017-04-18 23:29 ` [PATCH v3 3/8] blk-mq: Unregister debugfs attributes earlier Bart Van Assche
2017-04-21 22:16 ` Omar Sandoval
2017-04-21 22:17 ` Omar Sandoval
2017-04-18 23:29 ` [PATCH v3 4/8] blk-mq: Move the "state" debugfs attribute one level down Bart Van Assche
2017-04-18 23:29 ` [PATCH v3 5/8] blk-mq: Make blk_flags_show() callers append a newline character Bart Van Assche
2017-04-18 23:29 ` [PATCH v3 6/8] blk-mq: Show operation, cmd_flags and rq_flags names Bart Van Assche
2017-04-18 23:29 ` [PATCH v3 7/8] blk-mq: Add blk_mq_ops.show_rq() Bart Van Assche
2017-04-20 20:49 ` Omar Sandoval
2017-04-18 23:29 ` [PATCH v3 8/8] scsi: Implement blk_mq_ops.show_rq() Bart Van Assche
2017-04-18 23:29 ` Bart Van Assche
2017-04-19 23:25 ` Martin K. Petersen
2017-04-19 23:25 ` Martin K. Petersen
2017-04-19 23:29 ` Bart Van Assche
2017-04-19 23:29 ` 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.