mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
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: 3253aba340 ("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>
This commit is contained in:
parent
a463f71c49
commit
e502b667ee
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user