* [PATCH] block: rust: fix `Send` bound for `GenDisk`
@ 2026-07-09 10:00 Yuan Tan
0 siblings, 0 replies; only message in thread
From: Yuan Tan @ 2026-07-09 10:00 UTC (permalink / raw)
To: a.hindborg
Cc: miguel.ojeda.sandonis, boqun, linux-block, rust-for-linux,
zhiyunq, ardalan, pgovind2, dzueck, yuantan098, Yuan Tan
From: Andreas Hindborg <a.hindborg@kernel.org>
The `Send` implementation for `GenDisk<T>` was conditioned on `T: Send`.
This constrains the wrong type. `T` is the `Operations` implementation,
which is typically a zero-sized marker type that carries no data, so `T:
Send` says nothing about whether the data a `GenDisk` actually owns can be
moved to another thread.
A `GenDisk<T>` owns the queue data `T::QueueData` (stored as the
`gendisk`'s `queuedata` and dropped when the `GenDisk` is dropped) and an
`Arc<TagSet<T>>`. These are the values transferred when a `GenDisk` is sent
across a thread boundary, so the `Send` bound must constrain exactly them.
Bound `T::QueueData: Send` and `Arc<TagSet<T>>: Send` instead.
Fixes: 3253aba3408a ("rust: block: introduce `kernel::block::mq` module")
Links: https://lore.kernel.org/all/cover.1780633578.git.ytan089@ucr.edu
Cc: stable@vger.kernel.org
Reported-by: Priya Bala Govindasamy <pgovind2@uci.edu>
Reported-by: Dylan Zueck <dzueck@uci.edu>
Reported-by: Yuan Tan <ytan089@ucr.edu>
Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org>
Signed-off-by: Yuan Tan <ytan089@ucr.edu>
---
Changes in v4:
Following Miguel’s suggestion, I am resending Andreas’ v2 patch, but with
Priya’s and Dylan’s Reported-by tags added.
I noticed that this patch has not been merged yet, and I am not sure what
its current status is.
Link to v3:
- https://lore.kernel.org/all/20260611003220.3512652-1-yuantan098@gmail.com/
Changes in v3:
- Add Priya and Dylan's names to the `Reported-by` tags
Link to v2:
- https://lore.kernel.org/all/20260609-rnull-v6-19-rc5-send-v2-1-82c7404542e2@kernel.org/
Link to v1:
- https://lore.kernel.org/all/cover.1780633578.git.ytan089@ucr.edu/
I am a bit unsure how to handle this v3.
rust/kernel/block/mq/gen_disk.rs | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/rust/kernel/block/mq/gen_disk.rs b/rust/kernel/block/mq/gen_disk.rs
index fc97dd873974..4d49f33c6fab 100644
--- a/rust/kernel/block/mq/gen_disk.rs
+++ b/rust/kernel/block/mq/gen_disk.rs
@@ -212,8 +212,14 @@ pub struct GenDisk<T: Operations> {
}
// SAFETY: `GenDisk` is an owned pointer to a `struct gendisk` and an `Arc` to a
-// `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> {}
+// `TagSet`. It is safe to send this to other threads as long as these two are `Send`.
+unsafe impl<T> Send for GenDisk<T>
+where
+ T: Operations,
+ T::QueueData: Send,
+ Arc<TagSet<T>>: Send,
+{
+}
impl<T: Operations> Drop for GenDisk<T> {
fn drop(&mut self) {
--
2.43.2
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-07-09 10:01 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-09 10:00 [PATCH] block: rust: fix `Send` bound for `GenDisk` Yuan Tan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox