[PATCH 32/79] block: rust: implement `Sync` for `GenDisk`.
From: Andreas Hindborg
Date: Sun Feb 15 2026 - 18:43:32 EST
`GenDisk` is a pointer to a `struct gendisk`. It is safe to reference this
struct from multiple threads.
Signed-off-by: Andreas Hindborg <a.hindborg@xxxxxxxxxx>
---
rust/kernel/block/mq/gen_disk.rs | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/rust/kernel/block/mq/gen_disk.rs b/rust/kernel/block/mq/gen_disk.rs
index 75968d6a57639..72bbf3cadfe82 100644
--- a/rust/kernel/block/mq/gen_disk.rs
+++ b/rust/kernel/block/mq/gen_disk.rs
@@ -218,6 +218,10 @@ pub struct GenDisk<T: Operations> {
// `TagSet` It is safe to send this to other threads as long as T is Send.
unsafe impl<T: Operations + Send> Send for GenDisk<T> {}
+// SAFETY: `GenDisk` is an owned pointer to a `struct gendisk` and an `Arc` to a `TagSet`. It is
+// safe to reference these from multiple threads.
+unsafe impl<T: Operations> Sync for GenDisk<T> {}
+
impl<T: Operations> Drop for GenDisk<T> {
fn drop(&mut self) {
// SAFETY: By type invariant of `Self`, `self.gendisk` points to a valid
--
2.51.2