• Breno Leitao's avatar
    io_uring: Pass whole sqe to commands · fd9b8547
    Breno Leitao authored
    Currently uring CMD operation relies on having large SQEs, but future
    operations might want to use normal SQE.
    
    The io_uring_cmd currently only saves the payload (cmd) part of the SQE,
    but, for commands that use normal SQE size, it might be necessary to
    access the initial SQE fields outside of the payload/cmd block.  So,
    saves the whole SQE other than just the pdu.
    
    This changes slightly how the io_uring_cmd works, since the cmd
    structures and callbacks are not opaque to io_uring anymore. I.e, the
    callbacks can look at the SQE entries, not only, in the cmd structure.
    
    The main advantage is that we don't need to create custom structures for
    simple commands.
    
    Creates io_uring_sqe_cmd() that returns the cmd private data as a null
    pointer and avoids casting in the callee side.
    Also, make most of ublk_drv's sqe->cmd priv structure into const, and use
    io_uring_sqe_cmd() to get the private structure, removing the unwanted
    cast. (There is one case where the cast is still needed since the
    header->{len,addr} is updated in the private structure)
    Suggested-by: default avatarPavel Begunkov <asml.silence@gmail.com>
    Signed-off-by: default avatarBreno Leitao <leitao@debian.org>
    Reviewed-by: default avatarKeith Busch <kbusch@kernel.org>
    Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
    Reviewed-by: default avatarPavel Begunkov <asml.silence@gmail.com>
    Link: https://lore.kernel.org/r/20230504121856.904491-3-leitao@debian.orgSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
    fd9b8547
ublk_drv.c 57.8 KB