[PATCH 45/79] block: rust: add a method to set the target sector of a request
From: Andreas Hindborg
Date: Sun Feb 15 2026 - 18:40: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 | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/rust/kernel/block/mq/request.rs b/rust/kernel/block/mq/request.rs
index 4e47419776e0f..4e7adb10929f0 100644
--- a/rust/kernel/block/mq/request.rs
+++ b/rust/kernel/block/mq/request.rs
@@ -7,6 +7,7 @@
use crate::{
bindings,
block::mq::Operations,
+ prelude::*,
sync::{
aref::{ARef, RefCounted},
atomic::ordering,
@@ -296,6 +297,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