From: Jens Axboe <axboe@kernel.dk>
To: Pavel Begunkov <asml.silence@gmail.com>,
io-uring <io-uring@vger.kernel.org>
Cc: Norman Maurer <norman.maurer@googlemail.com>
Subject: Re: [PATCH] io_uring: no read-retry on -EAGAIN error and O_NONBLOCK marked file
Date: Wed, 2 Sep 2020 10:32:14 -0600 [thread overview]
Message-ID: <a749b272-aea3-e030-1aa6-afaf6dde33fb@kernel.dk> (raw)
In-Reply-To: <cdc949ce-059b-2f4f-bb16-f4e9554eb975@gmail.com>
On 9/2/20 10:09 AM, Pavel Begunkov wrote:
> On 02/09/2020 19:00, Jens Axboe wrote:
>> Actually two things that need fixing up here:
>>
>> - The io_rw_reissue() -EAGAIN retry is explicit to block devices and
>> regular files, so don't ever attempt to do that on other types of
>> files.
>>
>> - If we hit -EAGAIN on a nonblock marked file, don't arm poll handler for
>> it. It should just complete with -EAGAIN.
>>
>> Cc: stable@vger.kernel.org
>> Reported-by: Norman Maurer <norman.maurer@googlemail.com>
>> Signed-off-by: Jens Axboe <axboe@kernel.dk>
>>
>> ---
>>
>> diff --git a/fs/io_uring.c b/fs/io_uring.c
>> index b1ccd7072d93..65656102bbeb 100644
>> --- a/fs/io_uring.c
>> +++ b/fs/io_uring.c
>> @@ -2300,8 +2300,11 @@ static bool io_resubmit_prep(struct io_kiocb *req, int error)
>> static bool io_rw_reissue(struct io_kiocb *req, long res)
>> {
>> #ifdef CONFIG_BLOCK
>> + umode_t mode = file_inode(req->file)->i_mode;
>> int ret;
>>
>> + if (!S_ISBLK(mode) && !S_ISREG(mode))
>> + return false;
>> if ((res != -EAGAIN && res != -EOPNOTSUPP) || io_wq_current_is_worker())
>> return false;
>>
>> @@ -3146,6 +3149,9 @@ static int io_read(struct io_kiocb *req, bool force_nonblock,
>> /* IOPOLL retry should happen for io-wq threads */
>> if (!force_nonblock && !(req->ctx->flags & IORING_SETUP_IOPOLL))
>> goto done;
>> + /* no retry on NONBLOCK marked file */
>> + if (req->file->f_flags & O_NONBLOCK)
>> + goto done;
>
> Looks like it works with open(O_NONBLOCK) but not with IOCB_NOWAIT in the
> request's flags. Is that so?
The IOCB_NOWAIT case should already be fine, it's just the O_NONBLOCK that
isn't covered. IOCB_NOWAIT on a socket unhelpfully fails anyway, since
FMODE_NOWAIT isn't available. Arguably something that should be fixed
separately.
--
Jens Axboe
prev parent reply other threads:[~2020-09-02 16:32 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-02 16:00 [PATCH] io_uring: no read-retry on -EAGAIN error and O_NONBLOCK marked file Jens Axboe
2020-09-02 16:09 ` Pavel Begunkov
2020-09-02 16:32 ` Jens Axboe [this message]
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=a749b272-aea3-e030-1aa6-afaf6dde33fb@kernel.dk \
--to=axboe@kernel.dk \
--cc=asml.silence@gmail.com \
--cc=io-uring@vger.kernel.org \
--cc=norman.maurer@googlemail.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