From: John Garry <john.g.garry@oracle.com>
To: axboe@kernel.dk, kbusch@kernel.org, hch@lst.de, sagi@grimberg.me
Cc: linux-block@vger.kernel.org, linux-nvme@lists.infradead.org,
John Garry <john.garry@linux.dev>,
John Garry <john.g.garry@oracle.com>
Subject: [PATCH RFC v2 1/2] block: scan partitions for hidden disks
Date: Tue, 18 Aug 2026 12:08:53 +0000 [thread overview]
Message-ID: <20260818120854.3151628-2-john.g.garry@oracle.com> (raw)
In-Reply-To: <20260818120854.3151628-1-john.g.garry@oracle.com>
From: John Garry <john.garry@linux.dev>
If a disk is hidden (GENHD_FL_HIDDEN flags set), we currently do not scan
the disk partition table.
GENHD_FL_HIDDEN is used in NVMe multipath support to hide the per-path
disk.
However, it would be useful there to actually have the per-path disk
partition table available for situations where we want to send bios to
a specific per-path disk partition.
Change GENHD_FL_HIDDEN to scan partitions. For anyone wanting to avoid
scanning the partition, flag GENHD_FL_NO_PART can still be used.
In diskstats_show(), don't show per-path partitions as this info is not
too interesting and can just bloat the output.
Signed-off-by: John Garry <john.g.garry@oracle.com>
---
block/genhd.c | 20 ++++++++++----------
block/partitions/core.c | 5 +++--
drivers/nvme/host/core.c | 4 ----
include/linux/blkdev.h | 2 +-
4 files changed, 14 insertions(+), 17 deletions(-)
diff --git a/block/genhd.c b/block/genhd.c
index 30ac0ffe65174..05301ee5d4ca5 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -406,15 +406,15 @@ static void add_disk_final(struct gendisk *disk)
{
struct device *ddev = disk_to_dev(disk);
- if (!(disk->flags & GENHD_FL_HIDDEN)) {
- /* Make sure the first partition scan will be proceed */
- if (get_capacity(disk) && disk_has_partscan(disk))
- set_bit(GD_NEED_PART_SCAN, &disk->state);
+ /* Make sure the first partition scan will be proceed */
+ if (get_capacity(disk) && disk_has_partscan(disk))
+ set_bit(GD_NEED_PART_SCAN, &disk->state);
- bdev_add(disk->part0, ddev->devt);
- if (get_capacity(disk))
- disk_scan_partitions(disk, BLK_OPEN_READ);
+ bdev_add(disk->part0, ddev->devt);
+ if (get_capacity(disk))
+ disk_scan_partitions(disk, BLK_OPEN_READ);
+ if (!(disk->flags & GENHD_FL_HIDDEN)) {
/*
* Announce the disk and partitions after all partitions are
* created. (for hidden disks uevents remain suppressed forever)
@@ -491,8 +491,7 @@ static int __add_disk(struct device *parent, struct gendisk *disk,
dev_set_name(ddev, "%s", disk->disk_name);
if (fwnode)
device_set_node(ddev, fwnode);
- if (!(disk->flags & GENHD_FL_HIDDEN))
- ddev->devt = MKDEV(disk->major, disk->first_minor);
+ ddev->devt = MKDEV(disk->major, disk->first_minor);
ret = device_add(ddev);
if (ret)
goto out_free_ext_minor;
@@ -1368,7 +1367,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);
diff --git a/block/partitions/core.c b/block/partitions/core.c
index b5c59b79ca7cb..a48896c6c791d 100644
--- a/block/partitions/core.c
+++ b/block/partitions/core.c
@@ -152,7 +152,8 @@ static struct parsed_partitions *check_partition(struct gendisk *hd)
}
if (res > 0) {
- printk(KERN_INFO "%s", seq_buf_str(&state->pp_buf));
+ if (!(hd->flags & GENHD_FL_HIDDEN))
+ printk(KERN_INFO "%s", seq_buf_str(&state->pp_buf));
kfree(state->pp_buf.buffer);
return state;
@@ -164,7 +165,7 @@ static struct parsed_partitions *check_partition(struct gendisk *hd)
*/
if (err)
res = err;
- if (res) {
+ if (res && !(hd->flags & GENHD_FL_HIDDEN)) {
seq_buf_puts(&state->pp_buf,
" unable to read partition table\n");
printk(KERN_INFO "%s", seq_buf_str(&state->pp_buf));
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 1322c678f4eb8..ed21f4ef36c9a 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1808,10 +1808,6 @@ static void nvme_enable_aen(struct nvme_ctrl *ctrl)
static int nvme_ns_open(struct nvme_ns *ns)
{
-
- /* should never be called due to GENHD_FL_HIDDEN */
- if (WARN_ON_ONCE(nvme_ns_head_multipath(ns->head)))
- goto fail;
if (!nvme_get_ns(ns))
goto fail;
if (!try_module_get(ns->ctrl->ops->module))
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 9213a5716f95a..a270cf1394c7a 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -260,7 +260,7 @@ static inline unsigned int disk_openers(struct gendisk *disk)
*/
static inline bool disk_has_partscan(struct gendisk *disk)
{
- return !(disk->flags & (GENHD_FL_NO_PART | GENHD_FL_HIDDEN)) &&
+ return !(disk->flags & GENHD_FL_NO_PART) &&
!test_bit(GD_SUPPRESS_PART_SCAN, &disk->state);
}
--
2.43.7
next prev parent reply other threads:[~2026-08-18 12:09 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-18 12:08 [PATCH RFC v2 0/2] fix NVMe multipath partition diskstats John Garry
2026-08-18 12:08 ` John Garry [this message]
2026-08-19 9:00 ` [PATCH RFC v2 1/2] block: scan partitions for hidden disks Christoph Hellwig
2026-08-19 9:12 ` John Garry
2026-08-19 9:13 ` Christoph Hellwig
2026-08-19 9:43 ` John Garry
2026-08-18 12:08 ` [PATCH RFC v2 2/2] nvme-multipath: fix diskstats for partitions John Garry
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260818120854.3151628-2-john.g.garry@oracle.com \
--to=john.g.garry@oracle.com \
--cc=axboe@kernel.dk \
--cc=hch@lst.de \
--cc=john.garry@linux.dev \
--cc=kbusch@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=sagi@grimberg.me \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox