[PATCH v2 79/83] block: rnull: allow configuration of the maximum IO size
From: Andreas Hindborg
Date: Tue Jun 09 2026 - 15:24:57 EST
Add module parameter and configfs option for controlling the maximum size
of an IO for the emulated block device.
Signed-off-by: Andreas Hindborg <a.hindborg@xxxxxxxxxx>
---
drivers/block/rnull/configfs.rs | 5 +++++
drivers/block/rnull/rnull.rs | 10 +++++++++-
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/drivers/block/rnull/configfs.rs b/drivers/block/rnull/configfs.rs
index eaa7617e5ffa..5ab217e43e2b 100644
--- a/drivers/block/rnull/configfs.rs
+++ b/drivers/block/rnull/configfs.rs
@@ -132,6 +132,7 @@ fn make_group(
zone_append_max_sectors: 26,
poll_queues: 27,
fua: 28,
+ max_sectors: 29,
],
};
@@ -219,6 +220,7 @@ fn make_group(
requeue_inject,
#[cfg(CONFIG_BLK_DEV_RUST_NULL_FAULT_INJECTION)]
init_hctx_inject,
+ max_sectors: 0,
}),
}),
default_groups,
@@ -312,6 +314,7 @@ struct DeviceConfigInner {
requeue_inject: Arc<FaultConfig>,
#[cfg(CONFIG_BLK_DEV_RUST_NULL_FAULT_INJECTION)]
init_hctx_inject: Arc<FaultConfig>,
+ max_sectors: u32,
}
#[vtable]
@@ -384,6 +387,7 @@ fn store(this: &DeviceConfig, page: &[u8]) -> Result {
requeue_inject: guard.requeue_inject.clone(),
#[cfg(CONFIG_BLK_DEV_RUST_NULL_FAULT_INJECTION)]
timeout_inject: guard.timeout_inject.clone(),
+ max_sectors: guard.max_sectors,
})?);
guard.powered = true;
} else if guard.powered && !power_op {
@@ -612,3 +616,4 @@ fn store(this: &DeviceConfig, page: &[u8]) -> Result {
},
}
configfs_simple_bool_field!(DeviceConfig, 28, fua);
+configfs_simple_field!(DeviceConfig, 29, max_sectors, u32);
diff --git a/drivers/block/rnull/rnull.rs b/drivers/block/rnull/rnull.rs
index f909360ec70d..15b8c365b9fa 100644
--- a/drivers/block/rnull/rnull.rs
+++ b/drivers/block/rnull/rnull.rs
@@ -204,6 +204,10 @@
default: true,
description: "Enable/disable FUA support when cache_size is used.",
},
+ max_sectors: u32 {
+ default: 0,
+ description: "Maximum size of a command (in 512B sectors)",
+ },
},
}
@@ -307,6 +311,7 @@ fn init(_module: &'static ThisModule) -> impl PinInit<Self, Error> {
requeue_inject: Arc::pin_init(FaultConfig::new(c"requeue_inject"), GFP_KERNEL)?,
#[cfg(CONFIG_BLK_DEV_RUST_NULL_FAULT_INJECTION)]
timeout_inject: Arc::pin_init(FaultConfig::new(c"timeout_inject"), GFP_KERNEL)?,
+ max_sectors: module_parameters::max_sectors.value(),
})?;
disks.push(disk, GFP_KERNEL)?;
}
@@ -352,6 +357,7 @@ struct NullBlkOptions<'a> {
requeue_inject: Arc<FaultConfig>,
#[cfg(CONFIG_BLK_DEV_RUST_NULL_FAULT_INJECTION)]
timeout_inject: Arc<FaultConfig>,
+ max_sectors: u32,
}
#[pin_data]
@@ -487,6 +493,7 @@ fn new(options: NullBlkOptions<'_>) -> Result<Arc<GenDisk<Self>>> {
requeue_inject,
#[cfg(CONFIG_BLK_DEV_RUST_NULL_FAULT_INJECTION)]
timeout_inject,
+ max_sectors,
} = options;
let memory_backed = tag_set.memory_backed;
@@ -548,7 +555,8 @@ fn new(options: NullBlkOptions<'_>) -> Result<Arc<GenDisk<Self>>> {
.physical_block_size(block_size_bytes)?
.rotational(rotational)
.write_cache(storage.cache_enabled())
- .forced_unit_access(forced_unit_access && storage.cache_enabled());
+ .forced_unit_access(forced_unit_access && storage.cache_enabled())
+ .max_sectors(max_sectors);
#[cfg(CONFIG_BLK_DEV_ZONED)]
{
--
2.51.2