[PATCH 74/79] block: rust: add max_sectors option to `GenDiskBuilder`

Andreas Hindborg
2026-02-15T23:40:49Z

Allow drivers to set the maximum I/O size when building a `GenDisk`.

Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org>
---
rust/kernel/block/mq/gen_disk.rs | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/rust/kernel/block/mq/gen_disk.rs b/rust/kernel/block/mq/gen_disk.rs
index b5291bc3e051d..b428e3f4207f4 100644
--- a/rust/kernel/block/mq/gen_disk.rs
+++ b/rust/kernel/block/mq/gen_disk.rs
@@ -36,6 +36,7 @@ pub struct GenDiskBuilder<T> {
zone_append_max_sectors: u32,
write_cache: bool,
forced_unit_access: bool,
+ max_sectors: u32,
_p: PhantomData<T>,
}

@@ -55,6 +56,7 @@ fn default() -> Self {
zone_append_max_sectors: 0,
write_cache: false,
forced_unit_access: false,
+ max_sectors: 0,
_p: PhantomData,
}
}
@@ -159,6 +161,12 @@ pub fn write_cache(mut self, enable: bool) -> Self {
self
}

+ /// Maximum size of a command in 512 byte sectors.
+ pub fn max_sectors(mut self, sectors: u32) -> Self {
+ self.max_sectors = sectors;
+ self
+ }
+
/// Build a new `GenDisk` and add it to the VFS.
pub fn build(
self,
@@ -178,6 +186,7 @@ pub fn build(
lim.logical_block_size = self.logical_block_size;
lim.physical_block_size = self.physical_block_size;
lim.max_hw_discard_sectors = self.max_hw_discard_sectors;
+ lim.max_sectors = self.max_sectors;
if self.rotational {
lim.features = Feature::Rotational.into();
}

--
2.51.2