Skip to content
Snippets Groups Projects
  • Florian Fischer's avatar
    03727b29
    [IoContext] invalidate unsubmitted sqes · 03727b29
    Florian Fischer authored
    io_uring_submit does some inline error checking and consumes less
    cqes than prepared if an error is detected.
    
    Currently we just cancel the Futures, whose prepared sqes were not submitted.
    But this leaves already prepared sqes for those futures in the SQ
    of the io_uring which will be submitted the next time io_uring_submit
    is called.
    
    This results in a violation of the chain guaranty, that dependent operations
    are only executed if all dependencies were successful.
    Additionally this leads to double completions or memory corruption
    because the io_uring will produce cqes for already completed Futures.
    
    To prevent this from happening we track all sqes we prepared to
    invalidate and resubmit those which were not submitted because of a short submit.
    We invalidate sqes by preparing them as NOP instructions and set their
    user data to NULL.
    
    I took this approach instead of rewinding the ring or somethings like
    similar because it seemed safer for me not fiddle with io_uring internals
    and just be less efficient.
    
    Enable previously failing LinkFutureTest test cases.
    03727b29
    History
    [IoContext] invalidate unsubmitted sqes
    Florian Fischer authored
    io_uring_submit does some inline error checking and consumes less
    cqes than prepared if an error is detected.
    
    Currently we just cancel the Futures, whose prepared sqes were not submitted.
    But this leaves already prepared sqes for those futures in the SQ
    of the io_uring which will be submitted the next time io_uring_submit
    is called.
    
    This results in a violation of the chain guaranty, that dependent operations
    are only executed if all dependencies were successful.
    Additionally this leads to double completions or memory corruption
    because the io_uring will produce cqes for already completed Futures.
    
    To prevent this from happening we track all sqes we prepared to
    invalidate and resubmit those which were not submitted because of a short submit.
    We invalidate sqes by preparing them as NOP instructions and set their
    user data to NULL.
    
    I took this approach instead of rewinding the ring or somethings like
    similar because it seemed safer for me not fiddle with io_uring internals
    and just be less efficient.
    
    Enable previously failing LinkFutureTest test cases.