[PATCH v2 82/83] block: rnull: add `shared_tag_bitmap` config option

From: Andreas Hindborg

Date: Tue Jun 09 2026 - 15:19:43 EST


Add a configfs attribute and module parameter to enable the
`BLK_MQ_F_TAG_HCTX_SHARED` flag for the rnull tag set. When enabled,
a tag bitmap is shared across all hardware queues.

Signed-off-by: Andreas Hindborg <a.hindborg@xxxxxxxxxx>
---
drivers/block/rnull/configfs.rs | 5 +++++
drivers/block/rnull/rnull.rs | 12 ++++++++++++
rust/kernel/block/mq/tag_set/flags.rs | 4 ++++
3 files changed, 21 insertions(+)

diff --git a/drivers/block/rnull/configfs.rs b/drivers/block/rnull/configfs.rs
index 3e054339226c..1bab38c55698 100644
--- a/drivers/block/rnull/configfs.rs
+++ b/drivers/block/rnull/configfs.rs
@@ -134,6 +134,7 @@ fn make_group(
fua: 28,
max_sectors: 29,
virt_boundary: 30,
+ shared_tag_bitmap: 31,
],
};

@@ -223,6 +224,7 @@ fn make_group(
init_hctx_inject,
max_sectors: 0,
virt_boundary: false,
+ shared_tag_bitmap: false,
}),
}),
default_groups,
@@ -318,6 +320,7 @@ struct DeviceConfigInner {
init_hctx_inject: Arc<FaultConfig>,
max_sectors: u32,
virt_boundary: bool,
+ shared_tag_bitmap: bool,
}

#[vtable]
@@ -374,6 +377,7 @@ fn store(this: &DeviceConfig, page: &[u8]) -> Result {
blocking: guard.blocking,
memory_backed: guard.memory_backed,
no_sched: guard.no_sched,
+ shared_tag_bitmap: guard.shared_tag_bitmap,
hw_queue_depth: guard.hw_queue_depth,
#[cfg(CONFIG_BLK_DEV_RUST_NULL_FAULT_INJECTION)]
init_hctx_inject: guard.init_hctx_inject.clone(),
@@ -622,3 +626,4 @@ fn store(this: &DeviceConfig, page: &[u8]) -> Result {
configfs_simple_bool_field!(DeviceConfig, 28, fua);
configfs_simple_field!(DeviceConfig, 29, max_sectors, u32);
configfs_simple_bool_field!(DeviceConfig, 30, virt_boundary);
+configfs_simple_bool_field!(DeviceConfig, 31, shared_tag_bitmap);
diff --git a/drivers/block/rnull/rnull.rs b/drivers/block/rnull/rnull.rs
index 147dc8498c3a..81f9e2d03f31 100644
--- a/drivers/block/rnull/rnull.rs
+++ b/drivers/block/rnull/rnull.rs
@@ -216,6 +216,10 @@
default: false,
description: "Set alignment requirement for IO buffers to be page size.",
},
+ shared_tag_bitmap: bool {
+ default: false,
+ description: "Use shared tag bitmap for all submission queues for blk-mq.",
+ },
},
}

@@ -245,6 +249,7 @@ fn init(_module: &'static ThisModule) -> impl PinInit<Self, Error> {
let memory_backed = module_parameters::memory_backed.value();
let no_sched = module_parameters::no_sched.value();
let hw_queue_depth = module_parameters::hw_queue_depth.value();
+ let shared_tag_bitmap = module_parameters::shared_tag_bitmap.value();

let shared_tag_set = NullBlkDevice::build_tag_set(TagSetOptions {
home_node,
@@ -258,6 +263,7 @@ fn init(_module: &'static ThisModule) -> impl PinInit<Self, Error> {
blocking,
memory_backed,
no_sched,
+ shared_tag_bitmap,
hw_queue_depth,
#[cfg(CONFIG_BLK_DEV_RUST_NULL_FAULT_INJECTION)]
init_hctx_inject: Arc::pin_init(
@@ -300,6 +306,7 @@ fn init(_module: &'static ThisModule) -> impl PinInit<Self, Error> {
blocking,
memory_backed,
no_sched,
+ shared_tag_bitmap,
hw_queue_depth,
#[cfg(CONFIG_BLK_DEV_RUST_NULL_FAULT_INJECTION)]
init_hctx_inject: Arc::pin_init(
@@ -404,6 +411,7 @@ struct TagSetOptions {
blocking: bool,
memory_backed: bool,
no_sched: bool,
+ shared_tag_bitmap: bool,
hw_queue_depth: u32,
#[cfg(CONFIG_BLK_DEV_RUST_NULL_FAULT_INJECTION)]
init_hctx_inject: Arc<FaultConfig>,
@@ -419,6 +427,7 @@ fn build_tag_set(options: TagSetOptions) -> Result<Arc<TagSet<Self>>> {
blocking,
memory_backed,
no_sched,
+ shared_tag_bitmap,
hw_queue_depth,
#[cfg(CONFIG_BLK_DEV_RUST_NULL_FAULT_INJECTION)]
init_hctx_inject,
@@ -441,6 +450,9 @@ fn build_tag_set(options: TagSetOptions) -> Result<Arc<TagSet<Self>>> {
if no_sched {
flags |= mq::tag_set::Flag::NoDefaultScheduler;
}
+ if shared_tag_bitmap {
+ flags |= mq::tag_set::Flag::TagHctxShared;
+ }

let queue_config_guard = queue_config.lock();
let submit_queues = queue_config_guard.submit_queues;
diff --git a/rust/kernel/block/mq/tag_set/flags.rs b/rust/kernel/block/mq/tag_set/flags.rs
index 2561d7090c49..afc9d31ed998 100644
--- a/rust/kernel/block/mq/tag_set/flags.rs
+++ b/rust/kernel/block/mq/tag_set/flags.rs
@@ -21,5 +21,9 @@ pub enum Flag {
/// Select 'none' during queue registration in case of a single hwq or shared
/// hwqs instead of 'mq-deadline'.
NoDefaultScheduler = bindings::BLK_MQ_F_NO_SCHED_BY_DEFAULT,
+
+ /// Use shared tag bitmap for all submission queues.
+ TagHctxShared = bindings::BLK_MQ_F_TAG_HCTX_SHARED,
+
}
}

--
2.51.2