* [PATCH 5.10.y 2/7] block: rename GENHD_FL_NO_PART_SCAN to GENHD_FL_NO_PART
2026-09-10 19:08 ` [PATCH 5.10.y 1/7] block: remove a dead check in show_partition Sasha Levin
@ 2026-09-10 19:08 ` Sasha Levin
2026-09-10 19:08 ` [PATCH 5.10.y 3/7] null_blk: don't suppress partitioning information Sasha Levin
` (4 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Sasha Levin @ 2026-09-10 19:08 UTC (permalink / raw)
To: stable; +Cc: Christoph Hellwig, Ulf Hansson, Jens Axboe, Sasha Levin
From: Christoph Hellwig <hch@lst.de>
[ Upstream commit 46e7eac647b34ed4106a8262f8bedbb90801fadd ]
The GENHD_FL_NO_PART_SCAN controls more than just partitions canning,
so rename it to GENHD_FL_NO_PART.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Ulf Hansson <ulf.hansson@linaro.org>
Link: https://lore.kernel.org/r/20211122130625.1136848-7-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Adapt the dependency for 5.10 and prepare for 3f9c7a108c0e
("block: flag zoned disks with GENHD_FL_NO_PART"):
Keep the loop_set_status() block-device assignment and the native-capacity
and exclusive-write event flags, which are still needed on this branch.
Drop the n64cart hunk because that driver does not exist in 5.10.
Move the existing register_disk() definition below __device_add_disk(),
with a forward declaration, and align the device-number comment with
upstream. This preserves the existing registration logic while allowing
the target's three-way cherry-pick to insert its zoned-disk check in
__device_add_disk(), before partition scanning. No functions are added.
Make ext_range report one for GENHD_FL_NO_PART disks, as expected by the
target, while retaining disk_max_parts() for other disks. Keep the
existing partition allocation limits and extended device-number handling.
[ sashal: Reduced backport -- upstream 46e7eac647b34 touches 5 file(s), this
backport carries 4. Not backported here:
drivers/block/n64cart.c
This note is generated from the file lists only; see the resolution record
for the reasoning. ]
Stable-dep-of: 3f9c7a108c0e ("block: flag zoned disks with GENHD_FL_NO_PART")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
block/genhd.c | 137 +++++++++++++++++++++------------------
drivers/block/loop.c | 8 +--
drivers/mmc/core/block.c | 4 +-
include/linux/genhd.h | 13 ++--
4 files changed, 85 insertions(+), 77 deletions(-)
diff --git a/block/genhd.c b/block/genhd.c
index 01a7b81eca751..fef31a2f50a80 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -690,67 +690,7 @@ static void disk_scan_partitions(struct gendisk *disk)
}
static void register_disk(struct device *parent, struct gendisk *disk,
- const struct attribute_group **groups)
-{
- struct device *ddev = disk_to_dev(disk);
- struct disk_part_iter piter;
- struct hd_struct *part;
- int err;
-
- ddev->parent = parent;
-
- dev_set_name(ddev, "%s", disk->disk_name);
-
- /* delay uevents, until we scanned partition table */
- dev_set_uevent_suppress(ddev, 1);
-
- if (groups) {
- WARN_ON(ddev->groups);
- ddev->groups = groups;
- }
- if (device_add(ddev))
- return;
- if (!sysfs_deprecated) {
- err = sysfs_create_link(block_depr, &ddev->kobj,
- kobject_name(&ddev->kobj));
- if (err) {
- device_del(ddev);
- return;
- }
- }
-
- /*
- * avoid probable deadlock caused by allocating memory with
- * GFP_KERNEL in runtime_resume callback of its all ancestor
- * devices
- */
- pm_runtime_set_memalloc_noio(ddev, true);
-
- disk->part0.holder_dir = kobject_create_and_add("holders", &ddev->kobj);
- disk->slave_dir = kobject_create_and_add("slaves", &ddev->kobj);
-
- if (disk->flags & GENHD_FL_HIDDEN)
- return;
-
- disk_scan_partitions(disk);
-
- /* announce disk after possible partitions are created */
- dev_set_uevent_suppress(ddev, 0);
- kobject_uevent(&ddev->kobj, KOBJ_ADD);
-
- /* announce possible partitions */
- disk_part_iter_init(&piter, disk, 0);
- while ((part = disk_part_iter_next(&piter)))
- kobject_uevent(&part_to_dev(part)->kobj, KOBJ_ADD);
- disk_part_iter_exit(&piter);
-
- if (disk->queue->backing_dev_info->dev) {
- err = sysfs_create_link(&ddev->kobj,
- &disk->queue->backing_dev_info->dev->kobj,
- "bdi");
- WARN_ON(err);
- }
-}
+ const struct attribute_group **groups);
/**
* __device_add_disk - add disk information to kernel list
@@ -780,7 +720,12 @@ static void __device_add_disk(struct device *parent, struct gendisk *disk,
if (register_queue)
elevator_init_mq(disk->queue);
- /* minors == 0 indicates to use ext devt from part0 and should
+ /*
+ * If the driver provides an explicit major number it also must provide
+ * the number of minors numbers supported, and those will be used to
+ * setup the gendisk.
+ *
+ * minors == 0 indicates to use ext devt from part0 and should
* be accompanied with EXT_DEVT flag. Make sure all
* parameters make sense.
*/
@@ -806,7 +751,7 @@ static void __device_add_disk(struct device *parent, struct gendisk *disk,
* and don't bother scanning for partitions either.
*/
disk->flags |= GENHD_FL_SUPPRESS_PARTITION_INFO;
- disk->flags |= GENHD_FL_NO_PART_SCAN;
+ disk->flags |= GENHD_FL_NO_PART;
} else {
struct backing_dev_info *bdi = disk->queue->backing_dev_info;
struct device *dev = disk_to_dev(disk);
@@ -834,6 +779,69 @@ static void __device_add_disk(struct device *parent, struct gendisk *disk,
blk_integrity_add(disk);
}
+static void register_disk(struct device *parent, struct gendisk *disk,
+ const struct attribute_group **groups)
+{
+ struct device *ddev = disk_to_dev(disk);
+ struct disk_part_iter piter;
+ struct hd_struct *part;
+ int err;
+
+ ddev->parent = parent;
+
+ dev_set_name(ddev, "%s", disk->disk_name);
+
+ /* delay uevents, until we scanned partition table */
+ dev_set_uevent_suppress(ddev, 1);
+
+ if (groups) {
+ WARN_ON(ddev->groups);
+ ddev->groups = groups;
+ }
+ if (device_add(ddev))
+ return;
+ if (!sysfs_deprecated) {
+ err = sysfs_create_link(block_depr, &ddev->kobj,
+ kobject_name(&ddev->kobj));
+ if (err) {
+ device_del(ddev);
+ return;
+ }
+ }
+
+ /*
+ * avoid probable deadlock caused by allocating memory with
+ * GFP_KERNEL in runtime_resume callback of its all ancestor
+ * devices
+ */
+ pm_runtime_set_memalloc_noio(ddev, true);
+
+ disk->part0.holder_dir = kobject_create_and_add("holders", &ddev->kobj);
+ disk->slave_dir = kobject_create_and_add("slaves", &ddev->kobj);
+
+ if (disk->flags & GENHD_FL_HIDDEN)
+ return;
+
+ disk_scan_partitions(disk);
+
+ /* announce disk after possible partitions are created */
+ dev_set_uevent_suppress(ddev, 0);
+ kobject_uevent(&ddev->kobj, KOBJ_ADD);
+
+ /* announce possible partitions */
+ disk_part_iter_init(&piter, disk, 0);
+ while ((part = disk_part_iter_next(&piter)))
+ kobject_uevent(&part_to_dev(part)->kobj, KOBJ_ADD);
+ disk_part_iter_exit(&piter);
+
+ if (disk->queue->backing_dev_info->dev) {
+ err = sysfs_create_link(&ddev->kobj,
+ &disk->queue->backing_dev_info->dev->kobj,
+ "bdi");
+ WARN_ON(err);
+ }
+}
+
void device_add_disk(struct device *parent, struct gendisk *disk,
const struct attribute_group **groups)
@@ -1242,7 +1250,8 @@ static ssize_t disk_ext_range_show(struct device *dev,
{
struct gendisk *disk = dev_to_disk(dev);
- return sprintf(buf, "%d\n", disk_max_parts(disk));
+ return sprintf(buf, "%d\n",
+ (disk->flags & GENHD_FL_NO_PART) ? 1 : disk_max_parts(disk));
}
static ssize_t disk_removable_show(struct device *dev,
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 3db4dad0d072a..e11e25a799aba 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -1165,7 +1165,7 @@ static int loop_configure(struct loop_device *lo, fmode_t mode,
lo->lo_flags |= LO_FLAGS_PARTSCAN;
partscan = lo->lo_flags & LO_FLAGS_PARTSCAN;
if (partscan)
- lo->lo_disk->flags &= ~GENHD_FL_NO_PART_SCAN;
+ lo->lo_disk->flags &= ~GENHD_FL_NO_PART;
/* Grab the block_device to prevent its destruction after we
* put /dev/loopXX inode. Later in __loop_clr_fd() we bdput(bdev).
@@ -1291,7 +1291,7 @@ static int __loop_clr_fd(struct loop_device *lo, bool release)
mutex_lock(&loop_ctl_mutex);
lo->lo_flags = 0;
if (!part_shift)
- lo->lo_disk->flags |= GENHD_FL_NO_PART_SCAN;
+ lo->lo_disk->flags |= GENHD_FL_NO_PART;
lo->lo_state = Lo_unbound;
mutex_unlock(&loop_ctl_mutex);
@@ -1410,7 +1410,7 @@ loop_set_status(struct loop_device *lo, const struct loop_info64 *info)
if (!err && (lo->lo_flags & LO_FLAGS_PARTSCAN) &&
!(prev_lo_flags & LO_FLAGS_PARTSCAN)) {
- lo->lo_disk->flags &= ~GENHD_FL_NO_PART_SCAN;
+ lo->lo_disk->flags &= ~GENHD_FL_NO_PART;
bdev = lo->lo_device;
partscan = true;
}
@@ -2154,7 +2154,7 @@ static int loop_add(struct loop_device **l, int i)
* userspace tools. Parameters like this in general should be avoided.
*/
if (!part_shift)
- disk->flags |= GENHD_FL_NO_PART_SCAN;
+ disk->flags |= GENHD_FL_NO_PART;
disk->flags |= GENHD_FL_EXT_DEVT;
atomic_set(&lo->lo_refcnt, 0);
lo->lo_number = i;
diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
index e5506c793b6bd..51b43895e3a2d 100644
--- a/drivers/mmc/core/block.c
+++ b/drivers/mmc/core/block.c
@@ -2411,8 +2411,8 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card,
set_disk_ro(md->disk, md->read_only || default_ro);
md->disk->flags = GENHD_FL_EXT_DEVT;
if (area_type & (MMC_BLK_DATA_AREA_RPMB | MMC_BLK_DATA_AREA_BOOT))
- md->disk->flags |= GENHD_FL_NO_PART_SCAN
- | GENHD_FL_SUPPRESS_PARTITION_INFO;
+ md->disk->flags |= GENHD_FL_NO_PART |
+ GENHD_FL_SUPPRESS_PARTITION_INFO;
/*
* As discussed on lkml, GENHD_FL_REMOVABLE should:
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index 4b22bfd9336e1..30e1841630b1f 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -111,15 +111,15 @@ struct hd_struct {
* ``GENHD_FL_BLOCK_EVENTS_ON_EXCL_WRITE`` (0x0100): event polling is
* blocked whenever a writer holds an exclusive lock.
*
- * ``GENHD_FL_NO_PART_SCAN`` (0x0200): partition scanning is disabled.
- * Used for loop devices in their default settings and some MMC
- * devices.
+ * ``GENHD_FL_NO_PART`` (0x0200): partition support is disabled.
+ * The kernel will not scan for partitions from add_disk, and users
+ * can't add partitions manually.
*
* ``GENHD_FL_HIDDEN`` (0x0400): the block device is hidden; it
* doesn't produce events, doesn't appear in sysfs, and doesn't have
* an associated ``bdev``.
* Implies ``GENHD_FL_SUPPRESS_PARTITION_INFO`` and
- * ``GENHD_FL_NO_PART_SCAN``.
+ * ``GENHD_FL_NO_PART``.
* Used for multipath devices.
*/
#define GENHD_FL_REMOVABLE 0x0001
@@ -131,7 +131,7 @@ struct hd_struct {
#define GENHD_FL_EXT_DEVT 0x0040
#define GENHD_FL_NATIVE_CAPACITY 0x0080
#define GENHD_FL_BLOCK_EVENTS_ON_EXCL_WRITE 0x0100
-#define GENHD_FL_NO_PART_SCAN 0x0200
+#define GENHD_FL_NO_PART 0x0200
#define GENHD_FL_HIDDEN 0x0400
enum {
@@ -236,8 +236,7 @@ static inline int disk_max_parts(struct gendisk *disk)
static inline bool disk_part_scan_enabled(struct gendisk *disk)
{
- return disk_max_parts(disk) > 1 &&
- !(disk->flags & GENHD_FL_NO_PART_SCAN);
+ return disk_max_parts(disk) > 1 && !(disk->flags & GENHD_FL_NO_PART);
}
static inline dev_t disk_devt(struct gendisk *disk)
--
2.53.0
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH 5.10.y 5/7] block: remove GENHD_FL_SUPPRESS_PARTITION_INFO
2026-09-10 19:08 ` [PATCH 5.10.y 1/7] block: remove a dead check in show_partition Sasha Levin
` (2 preceding siblings ...)
2026-09-10 19:08 ` [PATCH 5.10.y 4/7] mmc: don't set GENHD_FL_SUPPRESS_PARTITION_INFO Sasha Levin
@ 2026-09-10 19:08 ` Sasha Levin
2026-09-10 19:08 ` [PATCH 5.10.y 6/7] block: don't set GENHD_FL_NO_PART for hidden gendisks Sasha Levin
2026-09-10 19:08 ` [PATCH 5.10.y 7/7] block: flag zoned disks with GENHD_FL_NO_PART Sasha Levin
5 siblings, 0 replies; 8+ messages in thread
From: Sasha Levin @ 2026-09-10 19:08 UTC (permalink / raw)
To: stable; +Cc: Christoph Hellwig, Jens Axboe, Sasha Levin
From: Christoph Hellwig <hch@lst.de>
[ Upstream commit 3b5149ac50970669ee0ddb9629ec77ffd5c0622d ]
This flag is not set directly anywhere and only inherited from
GENHD_FL_HIDDEN. Just check for GENHD_FL_HIDDEN instead.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20211122130625.1136848-11-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Adapt the dependency to the 5.10 disk-registration layout. Remove the
hidden-disk suppression assignment from __device_add_disk(), where this
branch sets GENHD_FL_NO_PART, and keep register_disk() and its existing
uevent and backing-device registration flow intact.
Preserve GENHD_FL_CD, GENHD_FL_UP, GENHD_FL_NATIVE_CAPACITY and
GENHD_FL_BLOCK_EVENTS_ON_EXCL_WRITE, which are still used on this branch.
Only remove GENHD_FL_SUPPRESS_PARTITION_INFO and check GENHD_FL_HIDDEN
in both partition-listing paths. No functions are added.
The preceding dependencies already removed the MMC and null_blk users.
Verified that target 3f9c7a108c0e applies cleanly with a three-way merge,
inserting its zoned-disk check in __device_add_disk() before partition
scanning. The existing GENHD_FL_NO_PART ext_range handling is retained.
Stable-dep-of: 3f9c7a108c0e ("block: flag zoned disks with GENHD_FL_NO_PART")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
block/genhd.c | 11 +++--------
include/linux/genhd.h | 9 +--------
2 files changed, 4 insertions(+), 16 deletions(-)
diff --git a/block/genhd.c b/block/genhd.c
index fef31a2f50a80..4ecab2f503719 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -747,10 +747,8 @@ static void __device_add_disk(struct device *parent, struct gendisk *disk,
if (disk->flags & GENHD_FL_HIDDEN) {
/*
- * Don't let hidden disks show up in /proc/partitions,
- * and don't bother scanning for partitions either.
+ * Don't bother scanning for partitions.
*/
- disk->flags |= GENHD_FL_SUPPRESS_PARTITION_INFO;
disk->flags |= GENHD_FL_NO_PART;
} else {
struct backing_dev_info *bdi = disk->queue->backing_dev_info;
@@ -1086,8 +1084,7 @@ void __init printk_all_partitions(void)
* Don't show empty devices or things that have been
* suppressed
*/
- if (get_capacity(disk) == 0 ||
- (disk->flags & GENHD_FL_SUPPRESS_PARTITION_INFO))
+ if (get_capacity(disk) == 0 || (disk->flags & GENHD_FL_HIDDEN))
continue;
/*
@@ -1182,9 +1179,7 @@ static int show_partition(struct seq_file *seqf, void *v)
struct hd_struct *part;
char buf[BDEVNAME_SIZE];
- if (!get_capacity(sgp))
- return 0;
- if (sgp->flags & GENHD_FL_SUPPRESS_PARTITION_INFO)
+ if (!get_capacity(sgp) || (sgp->flags & GENHD_FL_HIDDEN))
return 0;
/* show the full disk and all non-0 size partitions of it */
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index 30e1841630b1f..d6892e2f31c37 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -92,11 +92,6 @@ struct hd_struct {
* ``GENHD_FL_UP`` (0x0010): indicates that the block device is "up",
* with a similar meaning to network interfaces.
*
- * ``GENHD_FL_SUPPRESS_PARTITION_INFO`` (0x0020): don't include
- * partition information in ``/proc/partitions`` or in the output of
- * printk_all_partitions().
- * Used for the null block device and some MMC devices.
- *
* ``GENHD_FL_EXT_DEVT`` (0x0040): the driver supports extended
* dynamic ``dev_t``, i.e. it wants extended device numbers
* (``BLOCK_EXT_MAJOR``).
@@ -118,8 +113,7 @@ struct hd_struct {
* ``GENHD_FL_HIDDEN`` (0x0400): the block device is hidden; it
* doesn't produce events, doesn't appear in sysfs, and doesn't have
* an associated ``bdev``.
- * Implies ``GENHD_FL_SUPPRESS_PARTITION_INFO`` and
- * ``GENHD_FL_NO_PART``.
+ * Implies ``GENHD_FL_NO_PART``.
* Used for multipath devices.
*/
#define GENHD_FL_REMOVABLE 0x0001
@@ -127,7 +121,6 @@ struct hd_struct {
/* 4 is unused (used to be GENHD_FL_MEDIA_CHANGE_NOTIFY) */
#define GENHD_FL_CD 0x0008
#define GENHD_FL_UP 0x0010
-#define GENHD_FL_SUPPRESS_PARTITION_INFO 0x0020
#define GENHD_FL_EXT_DEVT 0x0040
#define GENHD_FL_NATIVE_CAPACITY 0x0080
#define GENHD_FL_BLOCK_EVENTS_ON_EXCL_WRITE 0x0100
--
2.53.0
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH 5.10.y 7/7] block: flag zoned disks with GENHD_FL_NO_PART
2026-09-10 19:08 ` [PATCH 5.10.y 1/7] block: remove a dead check in show_partition Sasha Levin
` (4 preceding siblings ...)
2026-09-10 19:08 ` [PATCH 5.10.y 6/7] block: don't set GENHD_FL_NO_PART for hidden gendisks Sasha Levin
@ 2026-09-10 19:08 ` Sasha Levin
5 siblings, 0 replies; 8+ messages in thread
From: Sasha Levin @ 2026-09-10 19:08 UTC (permalink / raw)
To: stable
Cc: Damien Le Moal, Bart Van Assche, Hannes Reinecke,
Christoph Hellwig, Hannes Reinecke, Jens Axboe, Sasha Levin
From: Damien Le Moal <dlemoal@kernel.org>
[ Upstream commit 3f9c7a108c0e8f14425384912017071b71341e3b ]
Zoned block devices do not support partitions. However, the partition
table is nevertheless still inspected, and any partition found ignored
with a warning in add_partition(). While this is generally not a problem,
and in fact beneficial to the user as it indicates an invalid use of a
zoned block device, scanning for a partition table on the device may
result in issuing read operations to offline zones (e.g. after a disk head
is depopulated for disks that support head management operations).
Since partitions are ignored anyway, completely disable partition scanning
for zoned gendisks by setting the flag GENHD_FL_NO_PART in __add_disk().
The existing check in add_partition() is left as-is to ensure that we
still get a warning if for whatever reason, despite GENHD_FL_NO_PART, we
still endup trying to add partitions.
Flagging zoned disks with GENHD_FL_NO_PART also has the benefit to expose
through sysfs the ext_range attribute with the value of 1 instead of the
default DISK_MAX_PARTS, thus correctly advertizing the fact that zoned
disks do not support partitions.
Fixes: 5eac3eb30c9a ("block: Remove partition support for zoned block devices")
Cc: stable@vger.kernel.org
Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Hannes Reinecke <hare@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Link: https://patch.msgid.link/20260831025050.667758-1-dlemoal@kernel.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
block/genhd.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/block/genhd.c b/block/genhd.c
index ea81203f6a036..976d2d77a1e0f 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -721,6 +721,13 @@ static void __device_add_disk(struct device *parent, struct gendisk *disk,
if (register_queue)
elevator_init_mq(disk->queue);
+ /*
+ * We do not support partitions with zoned block devices, so do not try
+ * to scan the partitions table.
+ */
+ if (blk_queue_is_zoned(disk->queue))
+ disk->flags |= GENHD_FL_NO_PART;
+
/*
* If the driver provides an explicit major number it also must provide
* the number of minors numbers supported, and those will be used to
--
2.53.0
^ permalink raw reply related [flat|nested] 8+ messages in thread