[PATCH v2 80/83] block: rust: add `virt_boundary_mask` option to `GenDiskBuilder`

From: Andreas Hindborg

Date: Tue Jun 09 2026 - 15:11:45 EST


Allow Rust device drivers to set the `virt_boundary_mask` property for
block devices.

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

diff --git a/rust/kernel/block/mq/gen_disk.rs b/rust/kernel/block/mq/gen_disk.rs
index 6d760dafade5..38057ebc0878 100644
--- a/rust/kernel/block/mq/gen_disk.rs
+++ b/rust/kernel/block/mq/gen_disk.rs
@@ -59,6 +59,7 @@ pub struct GenDiskBuilder<T> {
write_cache: bool,
forced_unit_access: bool,
max_sectors: u32,
+ virt_boundary_mask: usize,
_p: PhantomData<T>,
}

@@ -79,6 +80,7 @@ fn default() -> Self {
write_cache: false,
forced_unit_access: false,
max_sectors: 0,
+ virt_boundary_mask: 0,
_p: PhantomData,
}
}
@@ -189,6 +191,15 @@ pub fn max_sectors(mut self, sectors: u32) -> Self {
self
}

+ /// Set the I/O segment memory alignment mask for the block device. I/O requests to this device
+ /// will be split between segments wherever either the memory address of the end of the previous
+ /// segment or the memory address of the beginning of the current segment is not aligned to
+ /// virt_boundary_mask + 1 bytes.
+ pub fn virt_boundary_mask(mut self, mask: usize) -> Self {
+ self.virt_boundary_mask = mask;
+ self
+ }
+
/// Build a new `GenDisk` and add it to the VFS.
pub fn build(
self,
@@ -208,6 +219,7 @@ pub fn build(
lim.physical_block_size = self.physical_block_size;
lim.max_hw_discard_sectors = self.max_hw_discard_sectors;
lim.max_sectors = self.max_sectors;
+ lim.virt_boundary_mask = self.virt_boundary_mask;
if self.rotational {
lim.features = Feature::Rotational.into();
}

--
2.51.2