FAILED: patch "[PATCH] block: flag zoned disks with GENHD_FL_NO_PART" failed to apply to 5.10-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 5.10-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.10.y
git checkout FETCH_HEAD
git cherry-pick -x 3f9c7a108c0e8f14425384912017071b71341e3b
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026090834-voyage-donut-60bd@gregkh' --subject-prefix 'PATCH 5.10.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 3f9c7a108c0e8f14425384912017071b71341e3b Mon Sep 17 00:00:00 2001
From: Damien Le Moal <[email protected]>
Date: Mon, 31 Aug 2026 11:50:50 +0900
Subject: [PATCH] block: flag zoned disks with GENHD_FL_NO_PART
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.
block/genhd.c +7 -0
@@ -447,6 +447,13 @@ static int __add_disk(struct device *parent, struct gendisk *disk,bdev_set_flag (disk->part0,BD_HAS_SUBMIT_BIO ); } +/* +* 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
Sasha Levin
maintainerPATCH 1/7 block: remove a dead check in show_partition
From: Christoph Hellwig <[email protected]>
[ Upstream commit e3b3bad3f29878d13fdbc96f9e59674bd9b06bae ]
disk_max_parts never returns 0 given that ->minors for devices not using the extended dev_t must be non-zero, and disk_max_parts always returns DISK_MAX_PARTS for the latter.
Stable-dep-of: 3f9c7a108c0e ("block: flag zoned disks with GENHD_FL_NO_PART")
--- block/genhd.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
block/genhd.c +1 -3
@@ -1174,9 +1174,7 @@ static int show_partition(struct seq_file *seqf, void *v)struct hd_struct *part;char buf[BDEVNAME_SIZE ]; -/* Don't show non-partitionable removeable devices or empty devices */ -if (!get_capacity (sgp) || (!disk_max_parts (sgp) && - (sgp->flags &GENHD_FL_REMOVABLE ))) +if (!get_capacity (sgp))return 0 ;if (sgp->flags &GENHD_FL_SUPPRESS_PARTITION_INFO )return 0 ;
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 2/7 block: rename GENHD_FL_NO_PART_SCAN to GENHD_FL_NO_PART
From: Christoph Hellwig <[email protected]>
[ Upstream commit 46e7eac647b34ed4106a8262f8bedbb90801fadd ]
The GENHD_FL_NO_PART_SCAN controls more than just partitions canning, so rename it to GENHD_FL_NO_PART.
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")
--- 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(-)
block/genhd.c +73 -64
@@ -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,
drivers/block/loop.c +4 -4
@@ -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;
drivers/mmc/core/block.c +2 -2
@@ -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:
include/linux/genhd.h +6 -7
@@ -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 0x0400enum {
@@ -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)
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 3/7 null_blk: don't suppress partitioning information
In reply to Sasha LevinFrom: Christoph Hellwig <[email protected]>
[ Upstream commit 94b49c3ddb2127f84a133d70cef49054e1ebaaa4 ]
This manually reverts commit 27290b469051 ("null_blk: suppress invalid partition info"). The message in that commit log can't appearch as the flag is never checked during probing, and there is no good reason to treat null_blk special in /proc/partitions.
Stable-dep-of: 3f9c7a108c0e ("block: flag zoned disks with GENHD_FL_NO_PART")
--- drivers/block/null_blk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/null_blk/main.c +1 -1
@@ -1692,7 +1692,7 @@ static int null_gendisk_register(struct nullb *nullb)return -ENOMEM ;set_capacity (disk, size); - disk->flags |=GENHD_FL_EXT_DEVT |GENHD_FL_SUPPRESS_PARTITION_INFO ; + disk->flags |=GENHD_FL_EXT_DEVT ; disk->major = null_major; disk->first_minor = nullb->index;if (queue_is_mq (nullb->q))
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 4/7 mmc: don't set GENHD_FL_SUPPRESS_PARTITION_INFO
In reply to Sasha LevinFrom: Christoph Hellwig <[email protected]>
[ Upstream commit 79b0f79a835c6f1103c06e449cd88fb13e67f405 ]
This manually reverts 07b652cdbec3 ("mmc: card: Don't show eMMC RPMB and BOOT areas in /proc/partitions"). Based on the commit description that change was purely cosmetic. mmc is the last driver that sets this flag and thus prevents it from being removed.
Stable-dep-of: 3f9c7a108c0e ("block: flag zoned disks with GENHD_FL_NO_PART")
--- drivers/mmc/core/block.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/mmc/core/block.c +1 -2
@@ -2411,8 +2411,7 @@ 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 | -GENHD_FL_SUPPRESS_PARTITION_INFO ; + md->disk->flags |=GENHD_FL_NO_PART ;/* * As discussed on lkml, GENHD_FL_REMOVABLE should:
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 5/7 block: remove GENHD_FL_SUPPRESS_PARTITION_INFO
In reply to Sasha LevinFrom: Christoph Hellwig <[email protected]>
[ Upstream commit 3b5149ac50970669ee0ddb9629ec77ffd5c0622d ]
This flag is not set directly anywhere and only inherited from GENHD_FL_HIDDEN. Just check for GENHD_FL_HIDDEN instead.
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")
--- block/genhd.c | 11 +++-------- include/linux/genhd.h | 9 +-------- 2 files changed, 4 insertions(+), 16 deletions(-)
block/genhd.c +3 -8
@@ -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 */
include/linux/genhd.h +1 -8
@@ -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
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 6/7 block: don't set GENHD_FL_NO_PART for hidden gendisks
In reply to Sasha LevinFrom: Christoph Hellwig <[email protected]>
[ Upstream commit 9f18db572c97bc327b63528d195fdb252f47e9de ]
Hidden gendisks can't be opened using blkdev_get_*, so we can't really reach any of the partition scanning paths or partitioning ioctls except for the initial partition scan from add_disk.
Adapt the dependency to the 5.10 disk-registration layout. Keep the void disk_scan_partitions() interface and its capacity and partition-scan checks, adding a direct GENHD_FL_HIDDEN check before requesting a scan.
Remove the implicit GENHD_FL_NO_PART assignment from __device_add_disk(), where this branch handles hidden disks. Preserve its existing BDI and region registration, and keep register_disk()'s hidden-disk early return, uevents and sysfs links intact. No functions are added.
Verified that target 3f9c7a108c0e applies cleanly with a three-way merge, placing 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")
--- block/genhd.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
block/genhd.c +3 -7
@@ -680,7 +680,8 @@ static void disk_scan_partitions(struct gendisk *disk) {struct block_device *bdev; -if (!get_capacity (disk) || !disk_part_scan_enabled (disk)) +if (!get_capacity (disk) || !disk_part_scan_enabled (disk) || + (disk->flags &GENHD_FL_HIDDEN ))return ;set_bit (GD_NEED_PART_SCAN , &disk->state);
@@ -745,12 +746,7 @@ static void __device_add_disk(struct device *parent, struct gendisk *disk,disk_alloc_events (disk); -if (disk->flags &GENHD_FL_HIDDEN ) { -/* -* Don't bother scanning for partitions. -*/ - disk->flags |=GENHD_FL_NO_PART ; - }else { +if (!(disk->flags &GENHD_FL_HIDDEN )) {struct backing_dev_info *bdi = disk->queue->backing_dev_info;struct device *dev =disk_to_dev (disk);int ret;
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 7/7 block: flag zoned disks with GENHD_FL_NO_PART
In reply to Sasha LevinFrom: Damien Le Moal <[email protected]>
[ 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.
--- block/genhd.c | 7 +++++++ 1 file changed, 7 insertions(+)
block/genhd.c +7 -0
@@ -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
Signature · 1 line
2.53.0