From: Jens Axboe <axboe@kernel.dk>
To: Caleb Sander Mateos <csander@purestorage.com>,
Ming Lei <tom.leiming@gmail.com>
Cc: Keith Busch <kbusch@kernel.org>, Christoph Hellwig <hch@lst.de>,
Sagi Grimberg <sagi@grimberg.me>,
Joanne Koong <joannelkoong@gmail.com>,
linux-nvme@lists.infradead.org, io-uring@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/2] io_uring/cmd: split io_uring_cmd_set_res() from io_uring_cmd_done()
Date: Tue, 8 Sep 2026 19:16:37 -0600 [thread overview]
Message-ID: <c21acbbb-6558-48d4-9379-c1a952acf1e4@kernel.dk> (raw)
In-Reply-To: <CADUfDZqFLMS08wq0bJWQwKpJL5k9ty1bruVFQFcV6juFVB-9AQ@mail.gmail.com>
On 9/3/26 11:34 AM, Caleb Sander Mateos wrote:
> On Wed, Sep 2, 2026 at 6:02?PM Ming Lei <tom.leiming@gmail.com> wrote:
>>
>> On Wed, Sep 2, 2026 at 6:05?PM Caleb Sander Mateos
>> <csander@purestorage.com> 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@purestorage.com>
>>> ---
>>> 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);
>>> +
>>> /*
>>> * 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);
>>>
>>> void __io_uring_cmd_do_in_task(struct io_uring_cmd *ioucmd,
>>> io_req_tw_func_t task_work_cb,
>>> unsigned flags);
>>>
>>> @@ -105,12 +107,19 @@ static inline int io_uring_cmd_import_fixed_vec(struct io_uring_cmd *ioucmd,
>>> int ddir, struct iov_iter *iter,
>>> unsigned issue_flags)
>>> {
>>> return -EOPNOTSUPP;
>>> }
>>> -static inline void __io_uring_cmd_done(struct io_uring_cmd *cmd, s32 ret,
>>> - u64 ret2, unsigned issue_flags, bool is_cqe32)
>>> +static inline void io_uring_cmd_set_res(struct io_uring_cmd *cmd, s32 ret)
>>> +{
>>> +}
>>> +static inline void io_uring_cmd_set_res32(struct io_uring_cmd *cmd, s32 ret,
>>> + u64 res2)
>>> +{
>>> +}
>>> +static inline void __io_uring_cmd_done(struct io_uring_cmd *cmd,
>>> + unsigned issue_flags)
>>> {
>>> }
>>> static inline void __io_uring_cmd_do_in_task(struct io_uring_cmd *ioucmd,
>>> io_req_tw_func_t task_work_cb, unsigned flags)
>>> {
>>> @@ -171,17 +180,19 @@ static inline void *io_uring_cmd_ctx_handle(struct io_uring_cmd *cmd)
>>> }
>>>
>>> static inline void io_uring_cmd_done(struct io_uring_cmd *ioucmd, s32 ret,
>>> unsigned issue_flags)
>>> {
>>> - return __io_uring_cmd_done(ioucmd, ret, 0, issue_flags, false);
>>> + io_uring_cmd_set_res(ioucmd, ret);
>>> + __io_uring_cmd_done(ioucmd, issue_flags);
>>> }
>>>
>>> static inline void io_uring_cmd_done32(struct io_uring_cmd *ioucmd, s32 ret,
>>> u64 res2, unsigned issue_flags)
>>> {
>>> - return __io_uring_cmd_done(ioucmd, ret, res2, issue_flags, true);
>>> + io_uring_cmd_set_res32(ioucmd, ret, res2);
>>> + __io_uring_cmd_done(ioucmd, issue_flags);
>>> }
>>>
>>> int io_buffer_register_bvec(struct io_uring_cmd *cmd, struct request *rq,
>>> void (*release)(void *), unsigned int index,
>>> unsigned int issue_flags);
>>> diff --git a/io_uring/uring_cmd.c b/io_uring/uring_cmd.c
>>> index 726a659f38c3..917b32a921e6 100644
>>> --- a/io_uring/uring_cmd.c
>>> +++ b/io_uring/uring_cmd.c
>>> @@ -136,40 +136,43 @@ void __io_uring_cmd_do_in_task(struct io_uring_cmd *ioucmd,
>>> req->io_task_work.func = task_work_cb;
>>> __io_req_task_work_add(req, flags);
>>> }
>>> EXPORT_SYMBOL_GPL(__io_uring_cmd_do_in_task);
>>>
>>> -static inline void io_req_set_cqe32_extra(struct io_kiocb *req,
>>> - u64 extra1, u64 extra2)
>>> +void io_uring_cmd_set_res(struct io_uring_cmd *cmd, s32 ret)
>>> {
>>> - req->big_cqe.extra1 = extra1;
>>> - req->big_cqe.extra2 = extra2;
>>> + struct io_kiocb *req = cmd_to_io_kiocb(cmd);
>>> +
>>> + if (ret < 0)
>>> + req_set_fail(req);
>>> + io_req_set_res(req, ret, 0);
>>> }
>>> +EXPORT_SYMBOL_GPL(io_uring_cmd_set_res);
>>> +
>>> +void io_uring_cmd_set_res32(struct io_uring_cmd *cmd, s32 ret, u64 res2)
>>> +{
>>> + struct io_kiocb *req = cmd_to_io_kiocb(cmd);
>>> +
>>> + if (ret < 0)
>>> + req_set_fail(req);
>>> + io_req_set_res32(req, ret, 0, res2, 0);
>>> +}
>>> +EXPORT_SYMBOL_GPL(io_uring_cmd_set_res32);
>>
>> Both the two helpers can be inline, can't they?
>
> I also wanted to do that, but req_set_*() are defined in
> io_uring/io_uring.h, an io_uring-private header, whereas
> include/linux/io_uring/cmd.h is a public header. Perhaps the inline
> functions could be moved to include/linux/io_uring_types.h or
> include/linux/io_uring.h. If not, I think we'll have to rely on LTO to
> inline these calls. I'd be curious to hear Jens's thoughts.
Let's just move them to io_uring.h instead.
--
Jens Axboe
next prev parent reply other threads:[~2026-09-09 1:16 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-02 22:57 [PATCH v2 0/2] io_uring passthru: set result on blk-mq request completion Caleb Sander Mateos
2026-09-02 22:57 ` [PATCH v2 1/2] io_uring/cmd: split io_uring_cmd_set_res() from io_uring_cmd_done() Caleb Sander Mateos
2026-09-03 1:02 ` Ming Lei
2026-09-03 17:34 ` Caleb Sander Mateos
2026-09-09 1:16 ` Jens Axboe [this message]
2026-09-03 18:10 ` Joanne Koong
2026-09-04 15:01 ` Caleb Sander Mateos
2026-09-02 22:57 ` [PATCH v2 2/2] nvme/ioctl: call io_uring_cmd_set_res32() in ->end_io() Caleb Sander Mateos
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c21acbbb-6558-48d4-9379-c1a952acf1e4@kernel.dk \
--to=axboe@kernel.dk \
--cc=csander@purestorage.com \
--cc=hch@lst.de \
--cc=io-uring@vger.kernel.org \
--cc=joannelkoong@gmail.com \
--cc=kbusch@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=sagi@grimberg.me \
--cc=tom.leiming@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox