Allow drivers to set the maximum I/O size when building a `GenDisk`. Signed-off-by: Andreas Hindborg --- 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 a50ba7b605d7..6d760dafade5 100644 --- a/rust/kernel/block/mq/gen_disk.rs +++ b/rust/kernel/block/mq/gen_disk.rs @@ -58,6 +58,7 @@ pub struct GenDiskBuilder { zone_append_max_sectors: u32, write_cache: bool, forced_unit_access: bool, + max_sectors: u32, _p: PhantomData, } @@ -77,6 +78,7 @@ fn default() -> Self { zone_append_max_sectors: 0, write_cache: false, forced_unit_access: false, + max_sectors: 0, _p: PhantomData, } } @@ -181,6 +183,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, @@ -199,6 +207,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