block: Replace zone_wlock debugfs entry with zone_wplugs entry
authorDamien Le Moal <dlemoal@kernel.org>
Mon, 8 Apr 2024 01:41:25 +0000 (10:41 +0900)
committerJens Axboe <axboe@kernel.dk>
Wed, 17 Apr 2024 14:44:03 +0000 (08:44 -0600)
In preparation to completely remove zone write locking, replace the
"zone_wlock" mq-debugfs entry that was listing zones that are
write-locked with the zone_wplugs entry which lists the zones that
currently have a write plug allocated.

The write plug information provided is: the zone number, the zone write
plug flags, the zone write plug write pointer offset and the number of
BIOs currently waiting for execution in the zone write plug BIO list.

Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Tested-by: Hans Holmberg <hans.holmberg@wdc.com>
Tested-by: Dennis Maisenbacher <dennis.maisenbacher@wdc.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Link: https://lore.kernel.org/r/20240408014128.205141-26-dlemoal@kernel.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-mq-debugfs.c
block/blk-mq-debugfs.h
block/blk-zoned.c

index 94668e72ab09bf0922c8d79846a87d91fdbeb1ba..ca1f2b9422d55d38e41f6fb81c9d6853f30ddaab 100644 (file)
@@ -160,7 +160,7 @@ static const struct blk_mq_debugfs_attr blk_mq_debugfs_queue_attrs[] = {
        { "requeue_list", 0400, .seq_ops = &queue_requeue_list_seq_ops },
        { "pm_only", 0600, queue_pm_only_show, NULL },
        { "state", 0600, queue_state_show, queue_state_write },
-       { "zone_wlock", 0400, queue_zone_wlock_show, NULL },
+       { "zone_wplugs", 0400, queue_zone_wplugs_show, NULL },
        { },
 };
 
index 3ebe2c29b624b38c3fb6189ecda38fa6e33f4340..c80e453e301453a67873fa55d4374f96b64947c7 100644 (file)
@@ -84,9 +84,9 @@ static inline void blk_mq_debugfs_unregister_rqos(struct rq_qos *rqos)
 #endif
 
 #if defined(CONFIG_BLK_DEV_ZONED) && defined(CONFIG_BLK_DEBUG_FS)
-int queue_zone_wlock_show(void *data, struct seq_file *m);
+int queue_zone_wplugs_show(void *data, struct seq_file *m);
 #else
-static inline int queue_zone_wlock_show(void *data, struct seq_file *m)
+static inline int queue_zone_wplugs_show(void *data, struct seq_file *m)
 {
        return 0;
 }
index a06d7f7a54c74a1edc00eb00fae51e15951004ef..44699b431ad0449b8750b5b8ae459b952aa7c69f 100644 (file)
@@ -1808,17 +1808,34 @@ EXPORT_SYMBOL_GPL(blk_revalidate_disk_zones);
 
 #ifdef CONFIG_BLK_DEBUG_FS
 
-int queue_zone_wlock_show(void *data, struct seq_file *m)
+int queue_zone_wplugs_show(void *data, struct seq_file *m)
 {
        struct request_queue *q = data;
-       unsigned int i;
+       struct gendisk *disk = q->disk;
+       struct blk_zone_wplug *zwplug;
+       unsigned int zwp_wp_offset, zwp_flags;
+       unsigned int zwp_zone_no, zwp_ref;
+       unsigned int zwp_bio_list_size, i;
+       unsigned long flags;
 
-       if (!q->disk->seq_zones_wlock)
-               return 0;
+       rcu_read_lock();
+       for (i = 0; i < disk_zone_wplugs_hash_size(disk); i++) {
+               hlist_for_each_entry_rcu(zwplug,
+                                        &disk->zone_wplugs_hash[i], node) {
+                       spin_lock_irqsave(&zwplug->lock, flags);
+                       zwp_zone_no = zwplug->zone_no;
+                       zwp_flags = zwplug->flags;
+                       zwp_ref = atomic_read(&zwplug->ref);
+                       zwp_wp_offset = zwplug->wp_offset;
+                       zwp_bio_list_size = bio_list_size(&zwplug->bio_list);
+                       spin_unlock_irqrestore(&zwplug->lock, flags);
 
-       for (i = 0; i < q->disk->nr_zones; i++)
-               if (test_bit(i, q->disk->seq_zones_wlock))
-                       seq_printf(m, "%u\n", i);
+                       seq_printf(m, "%u 0x%x %u %u %u\n",
+                                  zwp_zone_no, zwp_flags, zwp_ref,
+                                  zwp_wp_offset, zwp_bio_list_size);
+               }
+       }
+       rcu_read_unlock();
 
        return 0;
 }