[PATCH v4 2/4] block: don't show partition diskstats for GENHD_FL_HIDDEN

John Garry john.garry at linux.dev
Mon Sep 21 01:37:50 PDT 2026


When flag GENHD_FL_HIDDEN is set for a disk, normally the partition table
is not available and so we won't get its partitions showing in diskstats.

However, now hidden disks may partition tables.

The diskstats for partitions on disks with GENHD_FL_HIDDEN can bloat
the output and is not too interesting, so always hide it.

Signed-off-by: John Garry <john.garry at linux.dev>
---
 block/genhd.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/block/genhd.c b/block/genhd.c
index 10ca8b4d6eea..60dc7a61ea8a 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -1376,7 +1376,8 @@ static int diskstats_show(struct seq_file *seqf, void *v)
 
 	rcu_read_lock();
 	xa_for_each(&gp->part_tbl, idx, hd) {
-		if (bdev_is_partition(hd) && !bdev_nr_sectors(hd))
+		if (bdev_is_partition(hd) &&
+		    (!bdev_nr_sectors(hd) || (gp->flags & GENHD_FL_HIDDEN)))
 			continue;
 
 		inflight = bdev_count_inflight(hd);
-- 
2.43.0




More information about the Linux-nvme mailing list