[PATCH 41/79] block: rnull: add blocking queue mode
From: Andreas Hindborg
Date: Sun Feb 15 2026 - 19:07:23 EST
Add support for blocking queue mode via the `blocking` configfs
attribute. When enabled, the tag set is created with the
`BLK_MQ_F_BLOCKING` flag.
Signed-off-by: Andreas Hindborg <a.hindborg@xxxxxxxxxx>
---
drivers/block/rnull/configfs.rs | 7 ++++++-
drivers/block/rnull/rnull.rs | 9 ++++++++-
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/drivers/block/rnull/configfs.rs b/drivers/block/rnull/configfs.rs
index d369d8b683c61..640e3de230c0a 100644
--- a/drivers/block/rnull/configfs.rs
+++ b/drivers/block/rnull/configfs.rs
@@ -70,7 +70,7 @@ impl AttributeOperations<0> for Config {
let mut writer = kernel::str::Formatter::new(page);
writer.write_str(
"blocksize,size,rotational,irqmode,completion_nsec,memory_backed\
- submit_queues,use_per_node_hctx\n",
+ submit_queues,use_per_node_hctx,discard,blocking\n",
)?;
Ok(writer.bytes_written())
}
@@ -106,6 +106,7 @@ fn make_group(
badblocks_partial_io: 14,
cache_size_mib: 15,
mbps: 16,
+ blocking: 17,
],
};
@@ -138,6 +139,7 @@ fn make_group(
)?,
cache_size_mib: 0,
mbps: 0,
+ blocking: false,
}),
}),
core::iter::empty(),
@@ -203,6 +205,7 @@ struct DeviceConfigInner {
cache_size_mib: u64,
disk_storage: Arc<DiskStorage>,
mbps: u32,
+ blocking: bool,
}
#[vtable]
@@ -243,6 +246,7 @@ fn store(this: &DeviceConfig, page: &[u8]) -> Result {
bad_blocks_partial_io: guard.bad_blocks_partial_io,
storage: guard.disk_storage.clone(),
bandwidth_limit: u64::from(guard.mbps) * 2u64.pow(20),
+ blocking: guard.blocking,
})?);
guard.powered = true;
} else if guard.powered && !power_op {
@@ -462,3 +466,4 @@ fn store(this: &DeviceConfig, page: &[u8]) -> Result {
);
configfs_simple_field!(DeviceConfig, 16, mbps, u32);
+configfs_simple_bool_field!(DeviceConfig, 17, blocking);
diff --git a/drivers/block/rnull/rnull.rs b/drivers/block/rnull/rnull.rs
index 16a4f915e59f4..cfc00c104d9ca 100644
--- a/drivers/block/rnull/rnull.rs
+++ b/drivers/block/rnull/rnull.rs
@@ -141,6 +141,10 @@
default: 0,
description: "Max bandwidth in MiB/s. 0 means no limit.",
},
+ blocking: u8 {
+ default: 0,
+ description: "Register as a blocking blk-mq driver device",
+ },
},
}
@@ -187,6 +191,7 @@ fn init(_module: &'static ThisModule) -> impl PinInit<Self, Error> {
bad_blocks_partial_io: false,
storage: Arc::pin_init(DiskStorage::new(0, block_size as usize), GFP_KERNEL)?,
bandwidth_limit: u64::from(*module_parameters::mbps.value()) * 2u64.pow(20),
+ blocking: *module_parameters::blocking.value() != 0,
})?;
disks.push(disk, GFP_KERNEL)?;
}
@@ -218,6 +223,7 @@ struct NullBlkOptions<'a> {
bad_blocks_partial_io: bool,
storage: Arc<DiskStorage>,
bandwidth_limit: u64,
+ blocking: bool,
}
#[pin_data]
@@ -260,6 +266,7 @@ fn new(options: NullBlkOptions<'_>) -> Result<Arc<GenDisk<Self>>> {
bad_blocks_partial_io,
storage,
bandwidth_limit,
+ blocking,
} = options;
let mut flags = mq::tag_set::Flags::default();
@@ -267,7 +274,7 @@ fn new(options: NullBlkOptions<'_>) -> Result<Arc<GenDisk<Self>>> {
// TODO: lim.features |= BLK_FEAT_WRITE_CACHE;
// if (dev->fua)
// lim.features |= BLK_FEAT_FUA;
- if memory_backed {
+ if blocking || memory_backed {
flags |= mq::tag_set::Flag::Blocking;
}
--
2.51.2