diff mbox series

[26/26] block: Add zone_active_wplugs debugfs entry

Message ID 20240202073104.2418230-27-dlemoal@kernel.org
State New
Headers show
Series Zone write plugging | expand

Commit Message

Damien Le Moal Feb. 2, 2024, 7:31 a.m. UTC
Add the zone_active_wplugs debugfs entry to list the zone number and
write pointer offset of zones that have an active zone write plug.

This helps ensure that struct blk_zone_active_wplug are reclaimed as
zones become empty or full and allows observing which zones are being
written by the block device user.

Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
---
 block/blk-mq-debugfs.c |  1 +
 block/blk-mq-debugfs.h |  5 +++++
 block/blk-zoned.c      | 27 +++++++++++++++++++++++++++
 3 files changed, 33 insertions(+)

Comments

Hannes Reinecke Feb. 4, 2024, 12:43 p.m. UTC | #1
On 2/2/24 15:31, Damien Le Moal wrote:
> Add the zone_active_wplugs debugfs entry to list the zone number and
> write pointer offset of zones that have an active zone write plug.
> 
> This helps ensure that struct blk_zone_active_wplug are reclaimed as
> zones become empty or full and allows observing which zones are being
> written by the block device user.
> 
> Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
> ---
>   block/blk-mq-debugfs.c |  1 +
>   block/blk-mq-debugfs.h |  5 +++++
>   block/blk-zoned.c      | 27 +++++++++++++++++++++++++++
>   3 files changed, 33 insertions(+)
> 
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
diff mbox series

Patch

diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c
index b803f5b370e9..5390526f2ab0 100644
--- a/block/blk-mq-debugfs.c
+++ b/block/blk-mq-debugfs.c
@@ -161,6 +161,7 @@  static const struct blk_mq_debugfs_attr blk_mq_debugfs_queue_attrs[] = {
 	{ "pm_only", 0600, queue_pm_only_show, NULL },
 	{ "state", 0600, queue_state_show, queue_state_write },
 	{ "zone_plugged_wplugs", 0400, queue_zone_plugged_wplugs_show, NULL },
+	{ "zone_active_wplugs", 0400, queue_zone_active_wplugs_show, NULL },
 	{ },
 };
 
diff --git a/block/blk-mq-debugfs.h b/block/blk-mq-debugfs.h
index 6d3ac4b77d59..ee0e34345ee7 100644
--- a/block/blk-mq-debugfs.h
+++ b/block/blk-mq-debugfs.h
@@ -85,11 +85,16 @@  static inline void blk_mq_debugfs_unregister_rqos(struct rq_qos *rqos)
 
 #if defined(CONFIG_BLK_DEV_ZONED) && defined(CONFIG_BLK_DEBUG_FS)
 int queue_zone_plugged_wplugs_show(void *data, struct seq_file *m);
+int queue_zone_active_wplugs_show(void *data, struct seq_file *m);
 #else
 static inline int queue_zone_plugged_wplugs_show(void *data, struct seq_file *m)
 {
 	return 0;
 }
+static inline int queue_zone_active_wplugs_show(void *data, struct seq_file *m)
+{
+	return 0;
+}
 #endif
 
 #endif
diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index 865fc372f25e..c9b31b28b5a2 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -1526,6 +1526,33 @@  int queue_zone_plugged_wplugs_show(void *data, struct seq_file *m)
 	return 0;
 }
 
+int queue_zone_active_wplugs_show(void *data, struct seq_file *m)
+{
+	struct request_queue *q = data;
+	struct gendisk *disk = q->disk;
+	struct blk_zone_wplug *zwplug;
+	unsigned int i, wp_offset;
+	unsigned long flags;
+	bool active;
+
+	if (!disk->zone_wplugs)
+		return 0;
+
+	for (i = 0; i < disk->nr_zones; i++) {
+		zwplug = &disk->zone_wplugs[i];
+		blk_zone_wplug_lock(zwplug, flags);
+		active = zwplug->flags & BLK_ZONE_WPLUG_ACTIVE;
+		if (active)
+			wp_offset = zwplug->zawplug->wp_offset;
+		blk_zone_wplug_unlock(zwplug, flags);
+
+		if (active)
+			seq_printf(m, "%u %u\n", i, wp_offset);
+	}
+
+	return 0;
+}
+
 #endif
 
 void blk_zone_dev_init(void)