From 06dad60393f20985cc5f24eeed63f965d366c4a0 Mon Sep 17 00:00:00 2001 From: Andreas Hindborg Date: Wed, 30 Sep 2026 21:43:55 +0200 Subject: [PATCH] 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>: Send`, which in turn requires `TagSet: 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 Closes: https://lore.kernel.org/r/d1381ed8-eab8-4fd7-8b15-1e94876d7099@leemhuis.info Suggested-by: Gary Guo Signed-off-by: Andreas Hindborg Tested-by: Thorsten Leemhuis Reviewed-by: Alice Ryhl Link: https://patch.msgid.link/20260930-tag-set-send-sync-v1-1-51acdb36f4bb@kernel.org Signed-off-by: Jens Axboe --- rust/kernel/block/mq/tag_set.rs | 7 +++++++ 1 file changed, 7 insertions(+) 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 @@ fn drop(self: Pin<&mut Self>) { unsafe { bindings::blk_mq_free_tag_set(self.inner.get()) }; } } + +// SAFETY: It is safe to transfer ownership of `TagSet` between threads. +unsafe impl Send for TagSet {} + +// SAFETY: It is safe to share `&TagSet` across threads. `TagSet` exposes no +// `&self` methods that mutate the contained `blk_mq_tag_set`. +unsafe impl Sync for TagSet {}