summaryrefslogtreecommitdiff
path: root/rust/kernel/block
diff options
context:
space:
mode:
authorAndreas Hindborg <a.hindborg@kernel.org>2026-09-30 21:43:55 +0200
committerJens Axboe <axboe@kernel.dk>2026-10-01 07:53:55 -0600
commit06dad60393f20985cc5f24eeed63f965d366c4a0 (patch)
treef1394c701666b033a466d011885598702aeb4e52 /rust/kernel/block
parent67b7a2728e4873e64405c5564fe50f7123012b71 (diff)
downloadlinux-06dad60393f20985cc5f24eeed63f965d366c4a0.tar.gz
linux-06dad60393f20985cc5f24eeed63f965d366c4a0.zip
rust: block: implement `Send` and `Sync` for `TagSet`
`TagSet` never implemented `Send` or `Sync`. This did not matter until commit "rust: block: fix `Send` bound for `GenDisk`" made `GenDisk: Send` depend on `Arc<TagSet<T>>: Send`, which in turn requires `TagSet<T>: Send + Sync`. With that bound unsatisfiable, `GenDisk` is never `Send`, and the rnull driver fails to build once configfs requires `GroupOperations::Child: Send`. `TagSet` owns no data typed by `T`. It only wraps the C `struct blk_mq_tag_set`, which can be dropped from any thread by calling `blk_mq_free_tag_set`. Thus, implement `Send` and `Sync` for `TagSet` unconditionally. Reported-by: Thorsten Leemhuis <linux@leemhuis.info> Closes: https://lore.kernel.org/r/d1381ed8-eab8-4fd7-8b15-1e94876d7099@leemhuis.info Suggested-by: Gary Guo <gary@garyguo.net> Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org> Tested-by: Thorsten Leemhuis <linux@leemhuis.info> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Link: https://patch.msgid.link/20260930-tag-set-send-sync-v1-1-51acdb36f4bb@kernel.org Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'rust/kernel/block')
-rw-r--r--rust/kernel/block/mq/tag_set.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/rust/kernel/block/mq/tag_set.rs b/rust/kernel/block/mq/tag_set.rs
index df3f90bfbb81..5f04008820b7 100644
--- a/rust/kernel/block/mq/tag_set.rs
+++ b/rust/kernel/block/mq/tag_set.rs
@@ -83,3 +83,10 @@ impl<T: Operations> PinnedDrop for TagSet<T> {
unsafe { bindings::blk_mq_free_tag_set(self.inner.get()) };
}
}
+
+// SAFETY: It is safe to transfer ownership of `TagSet` between threads.
+unsafe impl<T: Operations> Send for TagSet<T> {}
+
+// SAFETY: It is safe to share `&TagSet` across threads. `TagSet` exposes no
+// `&self` methods that mutate the contained `blk_mq_tag_set`.
+unsafe impl<T: Operations> Sync for TagSet<T> {}