public inbox for [email protected]
 help / color / mirror / Atom feed
From: Dmitry Kadashev <[email protected]>
To: Linus Torvalds <[email protected]>
Cc: Jens Axboe <[email protected]>,
	Alexander Viro <[email protected]>,
	Christian Brauner <[email protected]>,
	Pavel Begunkov <[email protected]>,
	linux-fsdevel <[email protected]>,
	io-uring <[email protected]>
Subject: Re: [PATCH v7 07/10] fs: make do_linkat() take struct filename
Date: Wed, 7 Jul 2021 14:27:16 +0700	[thread overview]
Message-ID: <CAOKbgA7MiqZAq3t-HDCpSGUFfco4hMA9ArAE-74fTpU+EkvKPw@mail.gmail.com> (raw)
In-Reply-To: <CAHk-=whdhY-RT=8wky=MgxAo0C9gSODcimLg3brdNy9p6OzhxA@mail.gmail.com>

On Wed, Jul 7, 2021 at 1:05 AM Linus Torvalds
<[email protected]> wrote:
>
> This is the only one in the series that I still react fairly negatively at.
>
> I still just don't like how filename_lookup() used to be nice and easy
> to understand ("always eat the name"), and while those semantics
> remain, the new __filename_lookup() has those odd semantics of only
> eating it on failure.
>
> And there is exactly _one_ caller of that new __filename_lookup(), and it does
>
>         error = __filename_lookup(olddfd, old, how, &old_path, NULL);
>         if (error)
>                 goto out_putnew;
>
> and I don't even understand why you'd want to eat it on error, because
> if if *didn't* eat it on error, it would just do
>
>         error = __filename_lookup(olddfd, old, how, &old_path, NULL);
>         if (error)
>                 goto out_putnames;
>
> and it would be much easier to understand (and the "out_putnew" label
> would go away entirely)
>
> What am I missing? You had some reason for not eating the name
> unconditionally, but I look at this patch and I just don't see it.

__filename_lookup() does that "eat the name on error" for uniformity
with the __filename_create(), and the latter does that mostly because Al
suggested to do it that way:

https://lore.kernel.org/io-uring/20210201150042.GQ740243@zeniv-ca/

Granted, he did that back when this series was much smaller, only about
mkdirat, and in that case it looked like it makes things a tad simpler,
and even though I found the semantics a bit confusing, I've assumed that
I'm missing something and this is something the FS code does, so people
are used to it.

Anyway, I'll send v8 of this series with yet another preparation patch,
that will change filename_parenat() to return an error code instead of
struct filename *, and split it into two: filename_parenat() that always
eats the name, and __filename_parentat() that never eats the name. And
__filename_lookup() and __filename_create() will never eat the name as
well, so things are nice and uniform and easy to reason about.

And hopefully if Al does not like that approach he can weigh in.

-- 
Dmitry Kadashev

  reply	other threads:[~2021-07-07  7:27 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-06 12:48 [PATCH v7 00/10] io_uring: add mkdir and [sym]linkat support Dmitry Kadashev
2021-07-06 12:48 ` [PATCH v7 01/10] namei: ignore ERR/NULL names in putname() Dmitry Kadashev
2021-07-06 12:48 ` [PATCH v7 02/10] fs: make do_mkdirat() take struct filename Dmitry Kadashev
2021-07-06 12:48 ` [PATCH v7 03/10] io_uring: add support for IORING_OP_MKDIRAT Dmitry Kadashev
2021-07-06 12:48 ` [PATCH v7 04/10] fs: make do_mknodat() take struct filename Dmitry Kadashev
2021-07-06 12:48 ` [PATCH v7 05/10] fs: make do_symlinkat() " Dmitry Kadashev
2021-07-06 12:48 ` [PATCH v7 06/10] namei: add getname_uflags() Dmitry Kadashev
2021-07-06 12:48 ` [PATCH v7 07/10] fs: make do_linkat() take struct filename Dmitry Kadashev
2021-07-06 18:05   ` Linus Torvalds
2021-07-07  7:27     ` Dmitry Kadashev [this message]
2021-07-06 12:48 ` [PATCH v7 08/10] fs: update do_*() helpers to return ints Dmitry Kadashev
2021-07-06 12:49 ` [PATCH v7 09/10] io_uring: add support for IORING_OP_SYMLINKAT Dmitry Kadashev
2021-07-06 12:49 ` [PATCH v7 10/10] io_uring: add support for IORING_OP_LINKAT Dmitry Kadashev

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=CAOKbgA7MiqZAq3t-HDCpSGUFfco4hMA9ArAE-74fTpU+EkvKPw@mail.gmail.com \
    [email protected] \
    [email protected] \
    [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