From: Jens Axboe <[email protected]>
To: Gabriel Krisman Bertazi <[email protected]>
Cc: [email protected], [email protected]
Subject: Re: [PATCH 3/3] io_uring/rw: add support for IORING_OP_READ_MULTISHOT
Date: Mon, 11 Sep 2023 18:53:41 -0600 [thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
On 9/11/23 6:46 PM, Jens Axboe wrote:
>>> + ret = __io_read(req, issue_flags);
>>> +
>>> + /*
>>> + * If we get -EAGAIN, recycle our buffer and just let normal poll
>>> + * handling arm it.
>>> + */
>>> + if (ret == -EAGAIN) {
>>> + io_kbuf_recycle(req, issue_flags);
>>> + return -EAGAIN;
>>> + }
>>> +
>>> + /*
>>> + * Any error will terminate a multishot request
>>> + */
>>> + if (ret <= 0) {
>>> +finish:
>>> + io_req_set_res(req, ret, cflags);
>>> + if (issue_flags & IO_URING_F_MULTISHOT)
>>> + return IOU_STOP_MULTISHOT;
>>> + return IOU_OK;
>>
>> Just a style detail, but I'd prefer to unfold this on the end of the
>> function instead of jumping backwards here..
>
> Sure, that might look better. I'll make the edit.
Actually we can just indent the next case and get rid of the goto
completely:
int io_read_mshot(struct io_kiocb *req, unsigned int issue_flags)
{
unsigned int cflags = 0;
int ret;
/*
* Multishot MUST be used on a pollable file
*/
if (!file_can_poll(req->file))
return -EBADFD;
ret = __io_read(req, issue_flags);
/*
* If we get -EAGAIN, recycle our buffer and just let normal poll
* handling arm it.
*/
if (ret == -EAGAIN) {
io_kbuf_recycle(req, issue_flags);
return -EAGAIN;
}
/*
* Any successful return value will keep the multishot read armed.
*/
if (ret > 0) {
/*
* Put our buffer and post a CQE. If we fail to post a CQE, then
* jump to the termination path. This request is then done.
*/
cflags = io_put_kbuf(req, issue_flags);
if (io_fill_cqe_req_aux(req,
issue_flags & IO_URING_F_COMPLETE_DEFER,
ret, cflags | IORING_CQE_F_MORE)) {
if (issue_flags & IO_URING_F_MULTISHOT)
return IOU_ISSUE_SKIP_COMPLETE;
return -EAGAIN;
}
}
/*
* Either an error, or we've hit overflow posting the CQE. For any
* multishot request, hitting overflow will terminate it.
*/
io_req_set_res(req, ret, cflags);
if (issue_flags & IO_URING_F_MULTISHOT)
return IOU_STOP_MULTISHOT;
return IOU_OK;
}
--
Jens Axboe
next prev parent reply other threads:[~2023-09-12 1:16 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-11 20:40 [PATCHSET 0/3] Add support for multishot reads Jens Axboe
2023-09-11 20:40 ` [PATCH 1/3] io_uring/rw: split io_read() into a helper Jens Axboe
2023-09-11 20:40 ` [PATCH 2/3] io_uring/rw: mark readv/writev as vectored in the opcode definition Jens Axboe
2023-09-11 20:40 ` [PATCH 3/3] io_uring/rw: add support for IORING_OP_READ_MULTISHOT Jens Axboe
2023-09-11 23:57 ` Gabriel Krisman Bertazi
2023-09-12 0:46 ` Jens Axboe
2023-09-12 0:53 ` Jens Axboe [this message]
2023-09-12 0:38 ` Gabriel Krisman Bertazi
2023-09-12 0:47 ` Jens Axboe
-- strict thread matches above, loose matches on Subject: below --
2023-09-12 17:24 [PATCHSET v2 0/3] Add support for multishot reads Jens Axboe
2023-09-12 17:24 ` [PATCH 3/3] io_uring/rw: add support for IORING_OP_READ_MULTISHOT Jens Axboe
2023-09-12 18:21 ` Jens Axboe
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 \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
/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