public inbox for [email protected]
 help / color / mirror / Atom feed
From: Xiaoguang Wang <[email protected]>
To: Pavel Begunkov <[email protected]>,
	Jens Axboe <[email protected]>,
	[email protected]
Subject: Re: [PATCH for-5.10] io_uring: remove req cancel in ->flush()
Date: Fri, 23 Oct 2020 11:33:35 +0800	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>

hi,

> On 22/10/2020 07:42, Xiaoguang Wang wrote:
>>> Every close(io_uring) causes cancellation of all inflight requests
>>> carrying ->files. That's not nice but was neccessary up until recently.
>>> Now task->files removal is handled in the core code, so that part of
>>> flush can be removed.
>> I don't catch up with newest io_uring codes yet, but have one question about
>> the initial implementation "io_uring: io_uring: add support for async work
>> inheriting files": https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=fcb323cc53e29d9cc696d606bb42736b32dd9825
>> There was such comments:
>> +static int io_grab_files(struct io_ring_ctx *ctx, struct io_kiocb *req)
>> +{
>> +       int ret = -EBADF;
>> +
>> +       rcu_read_lock();
>> +       spin_lock_irq(&ctx->inflight_lock);
>> +       /*
>> +        * We use the f_ops->flush() handler to ensure that we can flush
>> +        * out work accessing these files if the fd is closed. Check if
>> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>> I wonder why we only need to flush reqs specifically when they access current->files, are there
>> any special reasons?
> We could have taken a reference to ->files, so it doesn't get freed
> while a request is using it, but that creates a circular dependency.
> 
> IIUC, because if there are ->files refs io_uring won't be closed on exit,
> but io_uring would be holding ->files refs.
> 
> So, it was working without taking ->files references (i.e. weak refs)
> on the basis that the files won't be destroyed until the task itself is
> gone, and we can *kind of* intercept when task is exiting by ->flush()
> and cancel all requests with ->files there.
Now I see :) will help me to understand current codes better.
Really thanks for your explanations.

Regards,
Xiaoguang Wang
> 

      reply	other threads:[~2020-10-23  3:34 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-19 15:45 [PATCH for-5.10] io_uring: remove req cancel in ->flush() Pavel Begunkov
2020-10-19 20:08 ` Jens Axboe
2020-10-19 23:40   ` Pavel Begunkov
2020-10-20 14:09     ` Jens Axboe
2020-10-20 16:29       ` Pavel Begunkov
2020-10-20 16:59         ` Jens Axboe
2020-10-22  6:42 ` Xiaoguang Wang
2020-10-22 11:44   ` Pavel Begunkov
2020-10-23  3:33     ` Xiaoguang Wang [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=18fecee1-05a4-ca49-0530-73790f584d7e@linux.alibaba.com \
    [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