[PATCH 16/19] block: don't discover partition with DPS no-auto GPT attribute

From: Vincent Mailhol

Date: Mon Jun 15 2026 - 12:21:52 EST


DPS [1] defines GPT attribute bit 63 as no-auto. Partitions with this
bit set must not be used by automatic discovery.

Add the new GPT_ATTRIBUTE_NO_AUTO flag to designate the GPT attribute
bit 63.

Add the new ADDPART_FLAG_NO_AUTO flag and set it when
GPT_ATTRIBUTE_NO_AUTO is set during the partition scan. Then, propagate
it to the new BD_NO_AUTO_DISCOVERY flag.

Finally, add a condition to match_dev_by_type_uuid() to exclude any
partition with that flag from the automatic discovery.

[1] The Discoverable Partitions Specification (DPS)
Link: https://uapi-group.org/specifications/specs/discoverable_partitions_specification/

Signed-off-by: Vincent Mailhol <mailhol@xxxxxxxxxx>
---
block/blk.h | 1 +
block/early-lookup.c | 1 +
block/partitions/core.c | 2 ++
block/partitions/efi.c | 2 ++
block/partitions/efi.h | 3 +++
include/linux/blk_types.h | 1 +
6 files changed, 10 insertions(+)

diff --git a/block/blk.h b/block/blk.h
index b998a7761faf..14e0f349ff14 100644
--- a/block/blk.h
+++ b/block/blk.h
@@ -604,6 +604,7 @@ void blk_free_ext_minor(unsigned int minor);
#define ADDPART_FLAG_RAID 1
#define ADDPART_FLAG_WHOLEDISK 2
#define ADDPART_FLAG_READONLY 4
+#define ADDPART_FLAG_NO_AUTO 8
int bdev_add_partition(struct gendisk *disk, int partno, sector_t start,
sector_t length);
int bdev_del_partition(struct gendisk *disk, int partno);
diff --git a/block/early-lookup.c b/block/early-lookup.c
index cd10785e70ac..8db0abec141e 100644
--- a/block/early-lookup.c
+++ b/block/early-lookup.c
@@ -266,6 +266,7 @@ static int __init match_dev_by_type_uuid(struct device *dev, const void *data)
const struct uuidcmp *cmp = data;

return bdev->bd_disk == cmp->disk && bdev->bd_meta_info &&
+ !bdev_test_flag(bdev, BD_NO_AUTO_DISCOVERY) &&
!strcasecmp(cmp->uuid, bdev->bd_meta_info->type_uuid);
}

diff --git a/block/partitions/core.c b/block/partitions/core.c
index 5d5332ce586b..4529ea1d308e 100644
--- a/block/partitions/core.c
+++ b/block/partitions/core.c
@@ -382,6 +382,8 @@ static struct block_device *add_partition(struct gendisk *disk, int partno,

if (flags & ADDPART_FLAG_READONLY)
bdev_set_flag(bdev, BD_READ_ONLY);
+ if (flags & ADDPART_FLAG_NO_AUTO)
+ bdev_set_flag(bdev, BD_NO_AUTO_DISCOVERY);

/* everything is up and running, commence */
err = xa_insert(&disk->part_tbl, partno, bdev, GFP_KERNEL);
diff --git a/block/partitions/efi.c b/block/partitions/efi.c
index 4a3835ed9561..50c21625e256 100644
--- a/block/partitions/efi.c
+++ b/block/partitions/efi.c
@@ -739,6 +739,8 @@ int efi_partition(struct parsed_partitions *state)
/* If this is a RAID volume, tell md */
if (!efi_guidcmp(ptes[i].partition_type_guid, PARTITION_LINUX_RAID_GUID))
state->parts[i + 1].flags = ADDPART_FLAG_RAID;
+ if (le64_to_cpu(ptes[i].attributes) & GPT_ATTRIBUTE_NO_AUTO)
+ state->parts[i + 1].flags |= ADDPART_FLAG_NO_AUTO;

info = &state->parts[i + 1].info;
efi_guid_to_str(&ptes[i].unique_partition_guid, info->uuid);
diff --git a/block/partitions/efi.h b/block/partitions/efi.h
index 1f56f93b2804..fb50edb66e84 100644
--- a/block/partitions/efi.h
+++ b/block/partitions/efi.h
@@ -11,6 +11,7 @@
#ifndef FS_PART_EFI_H_INCLUDED
#define FS_PART_EFI_H_INCLUDED

+#include <linux/bits.h>
#include <linux/types.h>
#include <linux/fs.h>
#include <linux/kernel.h>
@@ -30,6 +31,8 @@
#define GPT_HEADER_REVISION_V1 0x00010000
#define GPT_PRIMARY_PARTITION_TABLE_LBA 1

+#define GPT_ATTRIBUTE_NO_AUTO BIT_U64(63)
+
#define PARTITION_SYSTEM_GUID \
EFI_GUID( 0xC12A7328, 0xF81F, 0x11d2, \
0xBA, 0x4B, 0x00, 0xA0, 0xC9, 0x3E, 0xC9, 0x3B)
diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h
index 8808ee76e73c..c6cdc99b0490 100644
--- a/include/linux/blk_types.h
+++ b/include/linux/blk_types.h
@@ -54,6 +54,7 @@ struct block_device {
#ifdef CONFIG_FAIL_MAKE_REQUEST
#define BD_MAKE_IT_FAIL (1u<<12)
#endif
+#define BD_NO_AUTO_DISCOVERY (1u<<13)
dev_t bd_dev;
struct address_space *bd_mapping; /* page cache */


--
2.53.0