From: Pavel Begunkov <[email protected]>
To: Joseph Qi <[email protected]>,
Jens Axboe <[email protected]>, io-uring <[email protected]>
Cc: Xiaoguang Wang <[email protected]>
Subject: Re: [PATCH] io_uring: fix SQPOLL IORING_OP_CLOSE cancelation state
Date: Wed, 20 Jan 2021 02:25:23 +0000 [thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
On 20/01/2021 02:07, Joseph Qi wrote:
[...]
>> Fix this by moving the IO_WQ_WORK_NO_CANCEL until _after_ we've modified
>> the fdtable. Canceling before this point is totally fine, and running
>> it in the io-wq context _after_ that point is also fine.
>>
>> For 5.12, we'll handle this internally and get rid of the no-cancel
>> flag, as IORING_OP_CLOSE is the only user of it.
>>
>> Fixes: 14587a46646d ("io_uring: enable file table usage for SQPOLL rings")
>
> As discussed with Pavel, this can not only happen in case sqpoll, but
> also in case async cancel is from io-wq.
Right, and it's handled because execution-during-cancellation can't
anymore get into close_fd_get_file(), either it was already done or
we didn't yet set IO_WQ_WORK_NO_CANCEL. And blkcg is not a problem.
>
>> Reported-by: Joseph Qi <[email protected]>
>
> In fact, it is reported by "Abaci <[email protected]>"
>
>> Signed-off-by: Jens Axboe <[email protected]>
>
> Reviewed-and-tested-by: Joseph Qi <[email protected]>
Thanks!
>>
>> ---
>>
>> Joseph, can you test this patch and see if this fixes it for you?
>>
>> diff --git a/fs/io_uring.c b/fs/io_uring.c
>> index b76bb50f18c7..5f6f1e48954e 100644
>> --- a/fs/io_uring.c
>> +++ b/fs/io_uring.c
>> @@ -4472,7 +4472,6 @@ static int io_close_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
>> * io_wq_work.flags, so initialize io_wq_work firstly.
>> */
>> io_req_init_async(req);
>> - req->work.flags |= IO_WQ_WORK_NO_CANCEL;
>>
>> if (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL))
>> return -EINVAL;
>> @@ -4505,6 +4504,8 @@ static int io_close(struct io_kiocb *req, bool force_nonblock,
>>
>> /* if the file has a flush method, be safe and punt to async */
>> if (close->put_file->f_op->flush && force_nonblock) {
>> + /* not safe to cancel at this point */
>> + req->work.flags |= IO_WQ_WORK_NO_CANCEL;
>> /* was never set, but play safe */
>> req->flags &= ~REQ_F_NOWAIT;
>> /* avoid grabbing files - we don't need the files */
>>
--
Pavel Begunkov
prev parent reply other threads:[~2021-01-20 3:36 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-19 17:18 [PATCH] io_uring: fix SQPOLL IORING_OP_CLOSE cancelation state Jens Axboe
2021-01-20 2:07 ` Joseph Qi
2021-01-20 2:20 ` Jens Axboe
2021-01-20 2:25 ` Pavel Begunkov [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 \
[email protected] \
[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