io-uring.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: Pavel Begunkov <asml.silence@gmail.com>, io-uring@vger.kernel.org
Cc: "Franz-B . Tuneke" <franz-bernhard.tuneke@tu-dortmund.de>
Subject: Re: [PATCH v2 5.15] io_uring: auto-removal for direct open/accept
Date: Tue, 14 Sep 2021 09:50:48 -0600	[thread overview]
Message-ID: <ba709c00-f644-7abb-7c45-99fa08ecb1e7@kernel.dk> (raw)
In-Reply-To: <7581ec11-315d-f459-2ee4-652426192807@gmail.com>

On 9/14/21 9:48 AM, Pavel Begunkov wrote:
> On 9/14/21 4:36 PM, Jens Axboe wrote:
>> On 9/14/21 9:12 AM, Pavel Begunkov wrote:
>>> It might be inconvenient that direct open/accept deviates from the
>>> update semantics and fails if the slot is taken instead of removing a
>>> file sitting there. Implement this auto-removal.
>>>
>>> Note that removal might need to allocate and so may fail. However, if an
>>> empty slot is specified, it's guaraneed to not fail on the fd
>>> installation side for valid userspace programs. It's needed for users
>>> who can't tolerate such failures, e.g. accept where the other end
>>> never retries.
>>>
>>> Suggested-by: Franz-B. Tuneke <franz-bernhard.tuneke@tu-dortmund.de>
>>> Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
>>> ---
>>>
>>> v2: simplify io_rsrc_node_switch_start() handling
>>>
>>>  fs/io_uring.c | 52 +++++++++++++++++++++++++++++++++------------------
>>>  1 file changed, 34 insertions(+), 18 deletions(-)
>>>
>>> diff --git a/fs/io_uring.c b/fs/io_uring.c
>>> index a864a94364c6..58c0cbfdd128 100644
>>> --- a/fs/io_uring.c
>>> +++ b/fs/io_uring.c
>>> @@ -8287,11 +8287,27 @@ static int io_sqe_file_register(struct io_ring_ctx *ctx, struct file *file,
>>>  #endif
>>>  }
>>>  
>>> +static int io_queue_rsrc_removal(struct io_rsrc_data *data, unsigned idx,
>>> +				 struct io_rsrc_node *node, void *rsrc)
>>> +{
>>> +	struct io_rsrc_put *prsrc;
>>> +
>>> +	prsrc = kzalloc(sizeof(*prsrc), GFP_KERNEL);
>>> +	if (!prsrc)
>>> +		return -ENOMEM;
>>> +
>>> +	prsrc->tag = *io_get_tag_slot(data, idx);
>>> +	prsrc->rsrc = rsrc;
>>> +	list_add(&prsrc->list, &node->rsrc_list);
>>> +	return 0;
>>> +}
>>
>> I know this code is just being moved, but I tend to like making the
>> expected/fast path inline:
> 
> I think it's more natural as now, as we always have
> 
> ret = do_something();
> if (ret)
>     return ret;
> ret = do_something2();
> if (ret)
>     goto err;
> 
> 
> And I remember you telling once "... I tend to like to do the error
> path like that unless it's a hot path ...". So maybe just add
> unlikely()?

Yeah doesn't matter too much for a non-fast path, and unlikely() here
won't matter as well. Let's just use it as-is.

-- 
Jens Axboe


      reply	other threads:[~2021-09-14 15:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-14 15:12 [PATCH v2 5.15] io_uring: auto-removal for direct open/accept Pavel Begunkov
2021-09-14 15:14 ` Jens Axboe
2021-09-14 15:21   ` Pavel Begunkov
2021-09-14 15:36 ` Jens Axboe
2021-09-14 15:48   ` Pavel Begunkov
2021-09-14 15:50     ` 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=ba709c00-f644-7abb-7c45-99fa08ecb1e7@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=asml.silence@gmail.com \
    --cc=franz-bernhard.tuneke@tu-dortmund.de \
    --cc=io-uring@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).