From: Linus Torvalds <torvalds@linux-foundation.org>
To: Miklos Szeredi <mszeredi@redhat.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>,
linux-unionfs@vger.kernel.org,
linux-fsdevel <linux-fsdevel@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Andreas Gruenbacher <agruenba@redhat.com>,
garyhuang <zjh.20052005@163.com>
Subject: Re: [PATCH v2 2/2] ovl: enable RCU'd ->get_acl()
Date: Wed, 18 Aug 2021 11:34:31 -0700 [thread overview]
Message-ID: <CAHk-=wga+3G+mR-UyQ=pwqN2iS04k-O61bssvzyVk+vkdZkd1Q@mail.gmail.com> (raw)
In-Reply-To: <20210818133400.830078-3-mszeredi@redhat.com>
On Wed, Aug 18, 2021 at 6:34 AM Miklos Szeredi <mszeredi@redhat.com> wrote:
>
> struct posix_acl *get_cached_acl_rcu(struct inode *inode, int type)
> {
> - return rcu_dereference(*acl_by_type(inode, type));
> + struct posix_acl *acl = rcu_dereference(*acl_by_type(inode, type));
> +
> + if (acl == ACL_DONT_CACHE)
> + acl = inode->i_op->get_acl(inode, type, LOOKUP_RCU);
> +
> + return acl;
> }
What? No.
You just made get_cached_acl_rcu() return ERR_PTR(-EINVAL) for most filesystems.
So now you've changed the behavior of get_cached_acl_rcu() ENTIRELY.
It used to return either
(a) the ACL
(b) NULL
(c) ACL_DONT_CACHE/ACL_NOT_CACHED
but now you've changed that (c) case to "ACL_NOT_CACHED or random error value".
You can't just mix these kinds of entirely different return values like that.
So no, this is not at all acceptable.
I would suggest:
(a) make the first patch actually test explicitly for LOOKUP_RCU, so
that it's clear to the filesystems what is going on.
So instead of that pattern of
if (flags)
return ERR_PTR(-EINVAL);
I'd suggest using
if (flags & LOOKUP_RCU)
return ERR_PTR(-ECHILD);
so that it actually matches what lookup does for the "I can't do
this under RCU", and so that any reader of the code understands what
"flags" is all about.
And then
(b) make the get_cached_acl_rcu() case handle errors _properly_
instead of mixing the special ACL cache markers with error returns.
So instead of
if (acl == ACL_DONT_CACHE)
acl = inode->i_op->get_acl(inode, type, LOOKUP_RCU);
maybe something more along the lines of
if (acl == ACL_DONT_CACHE) {
struct posix_acl *lookup_acl;
lookup_acl = inode->i_op->get_acl(inode, type, LOOKUP_RCU);
if (!IS_ERR(lookup_acl))
acl = lookup_acl;
}
or whatever.
I disagree with Al that a "bool" would be better. I think LOOKUP_RCU
is good documentation, and consistent with lookup, but it really needs
to be *consistent*. Thus that
if (flags & LOOKUP_RCU)
return ERR_PTR(-ECHILD);
pattern, not some "test underscibed flags, return -EINVAL" pattern
that looks entirely nonsensical.
Linus
next prev parent reply other threads:[~2021-08-18 18:34 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-18 13:33 [PATCH v2 0/2] allow overlayfs to do RCU lookups Miklos Szeredi
2021-08-18 13:33 ` [PATCH v2 1/2] vfs: add flags argument to ->get_acl() callback Miklos Szeredi
2021-08-18 13:49 ` Christian Brauner
2021-08-18 13:34 ` [PATCH v2 2/2] ovl: enable RCU'd ->get_acl() Miklos Szeredi
2021-08-18 18:34 ` Linus Torvalds [this message]
2021-08-18 18:53 ` Miklos Szeredi
2021-08-18 14:26 ` [PATCH v2 0/2] allow overlayfs to do RCU lookups Al Viro
2021-08-18 15:03 ` Miklos Szeredi
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-=wga+3G+mR-UyQ=pwqN2iS04k-O61bssvzyVk+vkdZkd1Q@mail.gmail.com' \
--to=torvalds@linux-foundation.org \
--cc=agruenba@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-unionfs@vger.kernel.org \
--cc=mszeredi@redhat.com \
--cc=viro@zeniv.linux.org.uk \
--cc=zjh.20052005@163.com \
/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).