From: Linus Torvalds <[email protected]>
To: Dmitry Kadashev <[email protected]>
Cc: Jens Axboe <[email protected]>,
Alexander Viro <[email protected]>,
Christian Brauner <[email protected]>,
linux-fsdevel <[email protected]>,
io-uring <[email protected]>
Subject: Re: [PATCH 4/7] namei: clean up do_mknodat retry logic
Date: Mon, 12 Jul 2021 11:46:20 -0700 [thread overview]
Message-ID: <CAHk-=wjFd0qn6asio=zg7zUTRmSty_TpAEhnwym1Qb=wFgCKzA@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
On Mon, Jul 12, 2021 at 5:37 AM Dmitry Kadashev <[email protected]> wrote:
>
> Moving the main logic to a helper function makes the whole thing much
> easier to follow.
This patch works, but the conversion is not one-to-one.
> -static int do_mknodat(int dfd, struct filename *name, umode_t mode,
> - unsigned int dev)
> +static int mknodat_helper(int dfd, struct filename *name, umode_t mode,
> + unsigned int dev, unsigned int lookup_flags)
> {
> struct user_namespace *mnt_userns;
> struct dentry *dentry;
> struct path path;
> int error;
> - unsigned int lookup_flags = 0;
>
> error = may_mknod(mode);
> if (error)
> - goto out1;
> -retry:
Note how "may_mknod()" was _outside_ the retry before, and now it's inside:
> +static int do_mknodat(int dfd, struct filename *name, umode_t mode,
> + unsigned int dev)
> +{
> + int error;
> +
> + error = mknodat_helper(dfd, name, mode, dev, 0);
> + if (retry_estale(error, 0))
> + error = mknodat_helper(dfd, name, mode, dev, LOOKUP_REVAL);
> +
> putname(name);
> return error;
which happens to not be fatal - doing the may_mknod() twice will not
break anything - but it doesn't match what it used to do.
A few options options:
(a) a separate patch to move the "may_mknod()" to the two callers first
(b) a separate patch to move the "may_mknod()" first into the repeat
loop, with the comment being that it's ok.
(c) keep the logic the same, with the code something like
static int do_mknodat(int dfd, struct filename *name, umode_t mode,
unsigned int dev)
{
int error;
error = may_mknod(mode);
if (!error) {
error = mknodat_helper(dfd, name, mode, dev, 0);
if (retry_estale(error, 0))
error = mknodat_helper(dfd, name, mode, dev,
LOOKUP_REVAL);
}
putname(name);
return error;
}
or
(d) keep the patch as-is, but with an added commit message note about
how it's not one-to-one and why it's ok.
Hmm?
So this patch could be fine, but it really wants to note how it
changes the logic and why that's fine. Or, the patch should be
modified.
Linus
next prev parent reply other threads:[~2021-07-12 18:46 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-12 12:36 [PATCH 0/7] namei: clean up retry logic in various do_* functions Dmitry Kadashev
2021-07-12 12:36 ` [PATCH 1/7] namei: clean up do_rmdir retry logic Dmitry Kadashev
2021-07-13 14:53 ` Christian Brauner
2021-07-13 16:57 ` Linus Torvalds
2021-07-15 10:38 ` Dmitry Kadashev
2021-07-12 12:36 ` [PATCH 2/7] namei: clean up do_unlinkat " Dmitry Kadashev
2021-07-12 12:36 ` [PATCH 3/7] namei: clean up do_mkdirat " Dmitry Kadashev
2021-07-12 12:36 ` [PATCH 4/7] namei: clean up do_mknodat " Dmitry Kadashev
2021-07-12 18:46 ` Linus Torvalds [this message]
2021-07-12 12:36 ` [PATCH 5/7] namei: clean up do_symlinkat " Dmitry Kadashev
2021-07-12 18:54 ` Linus Torvalds
2021-07-12 12:36 ` [PATCH 6/7] namei: clean up do_linkat " Dmitry Kadashev
2021-07-12 18:57 ` Linus Torvalds
2021-07-12 12:36 ` [PATCH 7/7] namei: clean up do_renameat " Dmitry Kadashev
2021-07-12 12:41 ` [PATCH 0/7] namei: clean up retry logic in various do_* functions Dmitry Kadashev
2021-07-12 19:01 ` Linus Torvalds
2021-07-12 20:25 ` Al Viro
2021-07-13 12:28 ` Dmitry Kadashev
2021-07-13 10:22 ` 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='CAHk-=wjFd0qn6asio=zg7zUTRmSty_TpAEhnwym1Qb=wFgCKzA@mail.gmail.com' \
[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