From: Yuan Tan <yuantan098@gmail.com>
To: a.hindborg@kernel.org
Cc: boqun@kernel.org, linux-block@vger.kernel.org,
rust-for-linux@vger.kernel.org, zhiyunq@cs.ucr.edu,
ardalan@uci.edu, pgovind2@uci.edu, dzueck@uci.edu,
yuantan098@gmail.com, Yuan Tan <ytan089@ucr.edu>
Subject: [PATCH v3] block: rust: fix `Send` bound for `GenDisk`
Date: Wed, 10 Jun 2026 17:32:20 -0700 [thread overview]
Message-ID: <20260611003220.3512652-1-yuantan098@gmail.com> (raw)
From: Yuan Tan <ytan089@ucr.edu>
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")
Reported-by: Priya Bala Govindasamy <pgovind2@uci.edu>
Reported-by: Dylan Zueck <dzueck@uci.edu>
Suggested-by: Andreas Hindborg <a.hindborg@kernel.org>
Signed-off-by: Yuan Tan <ytan089@ucr.edu>
---
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.
The change in this v3 is adding the missing trailers.
Andreas' v2 already addresses the TagSet issue from my v1, and his commit
message is also more appropriate. Therefore this v3 has no changes other
than the trailers.
I am not sure whether it is appropriate for me to take Andreas' patch and
only adjust the trailers. Please correct me, and my apologies if this is
not the right way to handle it.
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 912cb805caf5..b36d24382cc3 100644
--- a/rust/kernel/block/mq/gen_disk.rs
+++ b/rust/kernel/block/mq/gen_disk.rs
@@ -199,8 +199,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
next reply other threads:[~2026-06-11 0:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-11 0:32 Yuan Tan [this message]
2026-06-11 7:32 ` [PATCH v3] block: rust: fix `Send` bound for `GenDisk` Miguel Ojeda
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260611003220.3512652-1-yuantan098@gmail.com \
--to=yuantan098@gmail.com \
--cc=a.hindborg@kernel.org \
--cc=ardalan@uci.edu \
--cc=boqun@kernel.org \
--cc=dzueck@uci.edu \
--cc=linux-block@vger.kernel.org \
--cc=pgovind2@uci.edu \
--cc=rust-for-linux@vger.kernel.org \
--cc=ytan089@ucr.edu \
--cc=zhiyunq@cs.ucr.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox