Re: [PATCH v2 1/2] io_uring/cmd: split io_uring_cmd_set_res() from io_uring_cmd_done()

From: Caleb Sander Mateos

Date: Fri Sep 04 2026 - 12:12:45 EST


On Thu, Sep 3, 2026 at 11:11 AM Joanne Koong <joannelkoong@xxxxxxxxx> wrote:
>
> On Wed, Sep 2, 2026 at 3:57 PM Caleb Sander Mateos
> <csander@xxxxxxxxxxxxxxx> wrote:
> >
> > In preparation for setting the io_uring NVMe passthru CQE results from
> > the blk-mq request completion rather than the task work callback, split
> > out functions io_uring_cmd_set_res{,32}() from __io_uring_cmd_done().
> > io_uring_cmd_done{,32}() now call io_uring_cmd_set_res{,32}() and then
> > __io_uring_cmd_done(). This allows __io_uring_cmd_done() to be made
> > CQE-size-agnostic, with 3 fewer arguments.
> >
> > Signed-off-by: Caleb Sander Mateos <csander@xxxxxxxxxxxxxxx>
>
> Reviewed-by: Joanne Koong <joannelkoong@xxxxxxxxx>
>
> > ---
> > include/linux/io_uring/cmd.h | 23 +++++++++++++++++------
> > io_uring/uring_cmd.c | 33 ++++++++++++++++++---------------
> > 2 files changed, 35 insertions(+), 21 deletions(-)
> >
> > diff --git a/include/linux/io_uring/cmd.h b/include/linux/io_uring/cmd.h
> > index 331dcbefe72f..67f2ef700c43 100644
> > --- a/include/linux/io_uring/cmd.h
> > +++ b/include/linux/io_uring/cmd.h
> > @@ -50,19 +50,21 @@ int io_uring_cmd_import_fixed_vec(struct io_uring_cmd *ioucmd,
> > const struct iovec __user *uvec,
> > size_t uvec_segs,
> > int ddir, struct iov_iter *iter,
> > unsigned issue_flags);
> >
> > +void io_uring_cmd_set_res(struct io_uring_cmd *, s32 ret);
> > +void io_uring_cmd_set_res32(struct io_uring_cmd *, s32 ret, u64 res2);
>
> nit: it doesn't look like anywhere else in the header omits the param
> name for the cmd, so maybe worth also having it here (and below) for
> consistency?

IMO the name "cmd" or "ioucmd" doesn't add anything on top of the
argument type. But I can include it if people prefer it.

>
> > +
> > /*
> > * Completes the request, i.e. posts an io_uring CQE and deallocates @ioucmd
> > * and the corresponding io_uring request.
> > *
> > * Note: the caller should never hard code @issue_flags and is only allowed
> > * to pass the mask provided by the core io_uring code.
> > */
> > -void __io_uring_cmd_done(struct io_uring_cmd *cmd, s32 ret, u64 res2,
> > - unsigned issue_flags, bool is_cqe32);
> > +void __io_uring_cmd_done(struct io_uring_cmd *, unsigned issue_flags);
>
> Maybe worth adding a comment that any caller using this api needs to
> set the res themselves before calling this?

Sure, that's a good idea.

Thanks,
Caleb