From: Ming Lei <ming.lei@redhat.com>
To: Jens Axboe <axboe@kernel.dk>, linux-block@vger.kernel.org
Cc: Caleb Sander Mateos <csander@purestorage.com>,
Uday Shankar <ushankar@purestorage.com>,
Alexander Atanasov <alex@zazolabs.com>,
Ming Lei <ming.lei@redhat.com>, Yoav Cohen <yoav@nvidia.com>
Subject: [PATCH V2 2/9] ublk: add UBLK_F_NO_AUTO_PART_SCAN feature flag
Date: Fri, 30 Jan 2026 00:19:51 +0800 [thread overview]
Message-ID: <20260129162001.3532311-3-ming.lei@redhat.com> (raw)
In-Reply-To: <20260129162001.3532311-1-ming.lei@redhat.com>
Add a new feature flag UBLK_F_NO_AUTO_PART_SCAN to allow users to suppress
automatic partition scanning when starting a ublk device.
This is useful for some cases in which user don't want to scan
partitions.
Users still can manually trigger partition scanning later when appropriate
using standard tools (e.g., partprobe, blockdev --rereadpt).
Reported-by: Yoav Cohen <yoav@nvidia.com>
Link: https://lore.kernel.org/linux-block/DM4PR12MB63280C5637917C071C2F0D65A9A8A@DM4PR12MB6328.namprd12.prod.outlook.com/
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
drivers/block/ublk_drv.c | 14 ++++++++++----
include/uapi/linux/ublk_cmd.h | 3 +++
2 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
index 94470a2ec05e..aa9ea39249b0 100644
--- a/drivers/block/ublk_drv.c
+++ b/drivers/block/ublk_drv.c
@@ -80,7 +80,8 @@
| UBLK_F_BUF_REG_OFF_DAEMON \
| (IS_ENABLED(CONFIG_BLK_DEV_INTEGRITY) ? UBLK_F_INTEGRITY : 0) \
| UBLK_F_SAFE_STOP_DEV \
- | UBLK_F_BATCH_IO)
+ | UBLK_F_BATCH_IO \
+ | UBLK_F_NO_AUTO_PART_SCAN)
#define UBLK_F_ALL_RECOVERY_FLAGS (UBLK_F_USER_RECOVERY \
| UBLK_F_USER_RECOVERY_REISSUE \
@@ -4430,9 +4431,14 @@ static int ublk_ctrl_start_dev(struct ublk_device *ub,
set_bit(UB_STATE_USED, &ub->state);
- /* Schedule async partition scan for trusted daemons */
- if (!ub->unprivileged_daemons)
- schedule_work(&ub->partition_scan_work);
+ /* Skip partition scan if disabled by user */
+ if (ub->dev_info.flags & UBLK_F_NO_AUTO_PART_SCAN) {
+ clear_bit(GD_SUPPRESS_PART_SCAN, &disk->state);
+ } else {
+ /* Schedule async partition scan for trusted daemons */
+ if (!ub->unprivileged_daemons)
+ schedule_work(&ub->partition_scan_work);
+ }
out_put_cdev:
if (ret) {
diff --git a/include/uapi/linux/ublk_cmd.h b/include/uapi/linux/ublk_cmd.h
index 743d31491387..a88876756805 100644
--- a/include/uapi/linux/ublk_cmd.h
+++ b/include/uapi/linux/ublk_cmd.h
@@ -367,6 +367,9 @@
*/
#define UBLK_F_SAFE_STOP_DEV (1ULL << 17)
+/* Disable automatic partition scanning when device is started */
+#define UBLK_F_NO_AUTO_PART_SCAN (1ULL << 18)
+
/* device state */
#define UBLK_S_DEV_DEAD 0
#define UBLK_S_DEV_LIVE 1
--
2.47.0
next prev parent reply other threads:[~2026-01-29 16:20 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-29 16:19 [PATCH V2 0/9] ublk: misc improvement in driver and selftests Ming Lei
2026-01-29 16:19 ` [PATCH V2 1/9] ublk: check list membership before cancelling batch fetch command Ming Lei
2026-01-29 16:19 ` Ming Lei [this message]
2026-01-29 16:19 ` [PATCH V2 3/9] selftests: ublk: derive TID automatically from script name Ming Lei
2026-01-29 16:19 ` [PATCH V2 4/9] selftests: ublk: add selftest for UBLK_F_NO_AUTO_PART_SCAN Ming Lei
2026-01-29 16:19 ` [PATCH V2 5/9] selftests: ublk: rename test_generic_15 to test_part_02 Ming Lei
2026-01-29 16:19 ` [PATCH V2 6/9] selftests: ublk: refactor test_null_04 into separate functions Ming Lei
2026-01-29 16:19 ` [PATCH V2 7/9] selftests: ublk: disable partition scan for integrity tests Ming Lei
2026-01-29 16:19 ` [PATCH V2 8/9] selftests: ublk: mark each test start and end time in dmesg Ming Lei
2026-01-29 16:19 ` [PATCH V2 9/9] selftests: ublk: move test temp files into a sub directory Ming Lei
2026-01-31 2:43 ` Ming Lei
2026-01-31 10:30 ` Alexander Atanasov
2026-01-31 13:49 ` [PATCH V2 0/9] ublk: misc improvement in driver and selftests Jens Axboe
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=20260129162001.3532311-3-ming.lei@redhat.com \
--to=ming.lei@redhat.com \
--cc=alex@zazolabs.com \
--cc=axboe@kernel.dk \
--cc=csander@purestorage.com \
--cc=linux-block@vger.kernel.org \
--cc=ushankar@purestorage.com \
--cc=yoav@nvidia.com \
/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