io_uring/chan: grab reference to destination ring
authorJens Axboe <axboe@kernel.dk>
Fri, 25 Jul 2025 11:05:36 +0000 (05:05 -0600)
committerJens Axboe <axboe@kernel.dk>
Sat, 9 Aug 2025 14:38:27 +0000 (08:38 -0600)
commitf5f2de273c6c5a21dad75f5a83158886726b5d9f
tree3b02081a2ec30ba2760a35c0124533cc2479a141
parent9d13021a2157ae8e1b6fdbe59b50217eb0ac1bd0
io_uring/chan: grab reference to destination ring

Grab a reference to the destination ring, and store it in the
io_queue_chan struct. When either end of the channel gets closed, eg
when either of the rings go away, then the reference is dropped
unconditionally. Hence the stored ctx must only be used within a RCU
read lock region.

Note that channels only support DEFER_TASKRUN targets, and such rings
will call synchronize_rcu() before the ring (and task) can go away. This
makes it safe to use ->dst_ring inside rcu_read_lock(), even though the
reference to the ring is put during unregistration.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
io_uring/chan.c
io_uring/chan.h