• Pavel Begunkov's avatar
    io_uring: fix mis-refcounting linked timeouts · 6df1db6b
    Pavel Begunkov authored
    io_prep_linked_timeout() sets REQ_F_LINK_TIMEOUT altering refcounting of
    the following linked request. After that someone should call
    io_queue_linked_timeout(), otherwise a submission reference of the linked
    timeout won't be ever dropped.
    
    That's what happens in io_steal_work() if io-wq decides to postpone linked
    request with io_wqe_enqueue(). io_queue_linked_timeout() can also be
    potentially called twice without synchronisation during re-submission,
    e.g. io_rw_resubmit().
    
    There are the rules, whoever did io_prep_linked_timeout() must also call
    io_queue_linked_timeout(). To not do it twice, io_prep_linked_timeout()
    will return non NULL only for the first call. That's controlled by
    REQ_F_LINK_TIMEOUT flag.
    
    Also kill REQ_F_QUEUE_TIMEOUT.
    Signed-off-by: default avatarPavel Begunkov <asml.silence@gmail.com>
    Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
    6df1db6b
io_uring.c 202 KB