• Jens Axboe's avatar
    io_uring: don't do flush cancel under inflight_lock · 768134d4
    Jens Axboe authored
    We can't safely cancel under the inflight lock. If the work hasn't been
    started yet, then io_wq_cancel_work() simply marks the work as cancelled
    and invokes the work handler. But if the work completion needs to grab
    the inflight lock because it's grabbing user files, then we'll deadlock
    trying to finish the work as we already hold that lock.
    
    Instead grab a reference to the request, if it isn't already zero. If
    it's zero, then we know it's going through completion anyway, and we
    can safely ignore it. If it's not zero, then we can drop the lock and
    attempt to cancel from there.
    
    This also fixes a missing finish_wait() at the end of
    io_uring_cancel_files().
    Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
    768134d4
io_uring.c 113 KB