summaryrefslogtreecommitdiff
path: root/rust/kernel/block
diff options
context:
space:
mode:
authorAndreas Hindborg <a.hindborg@kernel.org>2026-09-29 11:34:02 +0200
committerJens Axboe <axboe@kernel.dk>2026-09-29 05:46:56 -0600
commite502b667ee70a7fa2a578e7722672ecd4fe0eb81 (patch)
treed62e86600ece8511b697961a071877de724e79b1 /rust/kernel/block
parenta463f71c492336f9650bae7d7166b66ee87461e9 (diff)
downloadlinux-next-e502b667ee70a7fa2a578e7722672ecd4fe0eb81.tar.gz
linux-next-e502b667ee70a7fa2a578e7722672ecd4fe0eb81.zip
rust: block: fix `Send` bound for `GenDisk`
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") Cc: stable@vger.kernel.org Reported-by: Priya Bala Govindasamy <pgovind2@uci.edu>, Dylan Zueck <dzueck@uci.edu>, Yuan Tan <ytan089@ucr.edu> Closes: https://lore.kernel.org/all/cover.1780633578.git.ytan089@ucr.edu Signed-off-by: Yuan Tan <ytan089@ucr.edu> Link: https://msgid.link/20260709100100.604252-1-yuantan098@gmail.com [ Andreas: Fix tags to make checkpatch happy. Change summary line. ] Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org> Link: https://patch.msgid.link/20260929-rust-block-for-v7-4-rc1-b4-v1-4-642a4c1aebd7@kernel.org Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'rust/kernel/block')
-rw-r--r--rust/kernel/block/mq/gen_disk.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/rust/kernel/block/mq/gen_disk.rs b/rust/kernel/block/mq/gen_disk.rs
index 8ec38a7b9815..080dedb5d5d9 100644
--- a/rust/kernel/block/mq/gen_disk.rs
+++ b/rust/kernel/block/mq/gen_disk.rs
@@ -224,8 +224,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) {