[PATCH 76/79] block: rust: add `virt_boundary_mask` option to `GenDiskBuilder`
From: Andreas Hindborg
Date: Sun Feb 15 2026 - 18:49: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 b428e3f4207f4..bf4775dbd6d25 100644
--- a/rust/kernel/block/mq/gen_disk.rs
+++ b/rust/kernel/block/mq/gen_disk.rs
@@ -37,6 +37,7 @@ pub struct GenDiskBuilder<T> {
write_cache: bool,
forced_unit_access: bool,
max_sectors: u32,
+ virt_boundary_mask: usize,
_p: PhantomData<T>,
}
@@ -57,6 +58,7 @@ fn default() -> Self {
write_cache: false,
forced_unit_access: false,
max_sectors: 0,
+ virt_boundary_mask: 0,
_p: PhantomData,
}
}
@@ -167,6 +169,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,
@@ -187,6 +198,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