[PATCH 36/79] block: rust: add a method to get the request queue for a request

Andreas Hindborg
2026-02-15T23:46:46Z

Add a method to `Request` for obtaining the associated `RequestQueue`.

Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org>
---
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 f6addd20624a9..d6f3ffde1c5c4 100644
--- a/rust/kernel/block/mq/request.rs
+++ b/rust/kernel/block/mq/request.rs
@@ -19,6 +19,7 @@
};
use core::{ffi::c_void, marker::PhantomData, ops::Deref, ptr::NonNull};

+use super::RequestQueue;
use crate::block::bio::Bio;
use crate::block::bio::BioIterator;

@@ -118,6 +119,12 @@ pub fn queue_data(&self) -> <T::QueueData as ForeignOwnable>::Borrowed<'_> {
// SAFETY: By type invariants of `Request`, `self.0` is a valid request.
unsafe { T::QueueData::borrow((*(*self.0.get()).q).queuedata) }
}
+
+ /// Get the request queue associated with this request.
+ pub fn queue(&self) -> &RequestQueue<T> {
+ // SAFETY: By type invariant, self.0 is guaranteed to be valid.
+ unsafe { RequestQueue::from_raw((*self.0.get()).q) }
+ }
}

/// A wrapper around a blk-mq [`struct request`]. This represents an IO request.

--
2.51.2