[PATCH 39/79] block: rust: add `GenDisk::queue_data`
From: Andreas Hindborg
Date: Sun Feb 15 2026 - 18:45:55 EST
Add a method to borrow the private queue data of the queue a `GenDisk` is
associated with.
Signed-off-by: Andreas Hindborg <a.hindborg@xxxxxxxxxx>
---
rust/kernel/block/mq/gen_disk.rs | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/rust/kernel/block/mq/gen_disk.rs b/rust/kernel/block/mq/gen_disk.rs
index 8a22767f1b916..fbda2f572e17f 100644
--- a/rust/kernel/block/mq/gen_disk.rs
+++ b/rust/kernel/block/mq/gen_disk.rs
@@ -246,6 +246,12 @@ pub fn queue(&self) -> &RequestQueue<T> {
// SAFETY: By type invariant, self is a valid gendisk.
unsafe { RequestQueue::from_raw((*self.gendisk).queue) }
}
+
+ /// Get the queue data associated with this [`GenDisk`].
+ pub fn queue_data(&self) -> <T::QueueData as ForeignOwnable>::Borrowed<'_> {
+ // SAFETY: By type invariant, self is a valid gendisk.
+ unsafe { T::QueueData::borrow((*(*self.gendisk).queue).queuedata) }
+ }
}
// SAFETY: `GenDisk` is an owned pointer to a `struct gendisk` and an `Arc` to a
--
2.51.2