[PATCH v2 49/83] block: rust: add a method to set the target sector of a request
From: Andreas Hindborg
Date: Tue Jun 09 2026 - 15:27:50 EST
Add a `block::mq::Request::set_sector` to allow setting the target sector
of a request.
Signed-off-by: Andreas Hindborg <a.hindborg@xxxxxxxxxx>
---
rust/kernel/block/mq/request.rs | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/rust/kernel/block/mq/request.rs b/rust/kernel/block/mq/request.rs
index 63e248970ab1..66ef2493c448 100644
--- a/rust/kernel/block/mq/request.rs
+++ b/rust/kernel/block/mq/request.rs
@@ -336,6 +336,13 @@ pub(crate) fn wrapper_ref(&self) -> &RequestDataWrapper<T> {
pub fn data_ref(&self) -> &T::RequestData {
&self.wrapper_ref().data
}
+
+ /// Set the target sector for the request.
+ #[inline(always)]
+ pub fn set_sector(self: Pin<&mut Self>, sector: u64) {
+ // SAFETY: By type invariant of `Self`, `self.0` is valid and live.
+ unsafe { (*self.0 .0.get()).__sector = sector }
+ }
}
/// A wrapper around data stored in the private area of the C [`struct request`].
--
2.51.2