From: Amir Goldstein <amir73il@gmail.com>
To: Christian Brauner <brauner@kernel.org>
Cc: Miklos Szeredi <miklos@szeredi.hu>,
Linus Torvalds <torvalds@linux-foundation.org>,
linux-unionfs@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH 3/6] ovl: reflow ovl_create_or_link()
Date: Fri, 14 Nov 2025 13:07:25 +0100 [thread overview]
Message-ID: <CAOQ4uxie_CSG7kPBCZaKEfiQmLH7EAcMqrHXvy78ciLqX4QuKA@mail.gmail.com> (raw)
In-Reply-To: <20251114-gasleitung-muffel-2a5478a34a6b@brauner>
On Fri, Nov 14, 2025 at 1:00 PM Christian Brauner <brauner@kernel.org> wrote:
>
> On Fri, Nov 14, 2025 at 12:52:58PM +0100, Amir Goldstein wrote:
> > On Fri, Nov 14, 2025 at 11:15 AM Christian Brauner <brauner@kernel.org> wrote:
> > >
> > > Reflow the creation routine in preparation of porting it to a guard.
> > >
> > > Signed-off-by: Christian Brauner <brauner@kernel.org>
> > > ---
> > > fs/overlayfs/dir.c | 23 +++++++++++++++--------
> > > 1 file changed, 15 insertions(+), 8 deletions(-)
> > >
> > > diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
> > > index a276eafb5e78..ff30a91e07f8 100644
> > > --- a/fs/overlayfs/dir.c
> > > +++ b/fs/overlayfs/dir.c
> > > @@ -644,14 +644,23 @@ static const struct cred *ovl_setup_cred_for_create(struct dentry *dentry,
> > > return override_cred;
> > > }
> > >
> > > +static int do_ovl_create_or_link(struct dentry *dentry, struct inode *inode,
> > > + struct ovl_cattr *attr)
> >
> > Trying to avert the bikesheding over do_ovl_ helper name...
> >
> > > +{
> > > + if (!ovl_dentry_is_whiteout(dentry))
> > > + return ovl_create_upper(dentry, inode, attr);
> > > +
> > > + return ovl_create_over_whiteout(dentry, inode, attr);
> > > +}
> > > +
> > > static int ovl_create_or_link(struct dentry *dentry, struct inode *inode,
> > > struct ovl_cattr *attr, bool origin)
> > > {
> > > int err;
> > > - const struct cred *new_cred __free(put_cred) = NULL;
> > > struct dentry *parent = dentry->d_parent;
> > >
> > > scoped_class(override_creds_ovl, old_cred, dentry->d_sb) {
> > > + const struct cred *new_cred __free(put_cred) = NULL;
> > > /*
> > > * When linking a file with copy up origin into a new parent, mark the
> > > * new parent dir "impure".
> > > @@ -662,7 +671,6 @@ static int ovl_create_or_link(struct dentry *dentry, struct inode *inode,
> > > return err;
> > > }
> > >
> > > - if (!attr->hardlink) {
> > > /*
> > > * In the creation cases(create, mkdir, mknod, symlink),
> > > * ovl should transfer current's fs{u,g}id to underlying
> > > @@ -676,16 +684,15 @@ static int ovl_create_or_link(struct dentry *dentry, struct inode *inode,
> > > * create a new inode, so just use the ovl mounter's
> > > * fs{u,g}id.
> > > */
> > > +
> > > + if (attr->hardlink)
> > > + return do_ovl_create_or_link(dentry, inode, attr);
> > > +
> >
> > ^^^ This looks like an optimization (don't setup cred for hardlink).
> > Is it really an important optimization that is worth complicating the code flow?
>
> It elides a bunch of allocations and an rcu cycle from put_cred().
> So yes, I think it's worth it.
I have no doubt that ovl_setup_cred_for_create() has a price.
The question is whether hardlinking over ovl is an interesting use case
to optimize for.
Miklos? WDYT?
> You can always remove the special-case later yourself.
Sure. Just as we touch and improve the code, it's worth asking those
questions.
Thanks,
Amir.
next prev parent reply other threads:[~2025-11-14 12:07 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-14 10:15 [PATCH 0/6] ovl: convert creation credential override to cred guard Christian Brauner
2025-11-14 10:15 ` [PATCH 1/6] ovl: add prepare_creds_ovl cleanup guard Christian Brauner
2025-11-14 12:04 ` Amir Goldstein
2025-11-14 13:34 ` Christian Brauner
2025-11-14 10:15 ` [PATCH 2/6] ovl: port ovl_create_tmpfile() to new " Christian Brauner
2025-11-14 10:15 ` [PATCH 3/6] ovl: reflow ovl_create_or_link() Christian Brauner
2025-11-14 11:52 ` Amir Goldstein
2025-11-14 12:00 ` Christian Brauner
2025-11-14 12:07 ` Amir Goldstein [this message]
2025-11-14 17:41 ` Miklos Szeredi
2025-11-14 10:15 ` [PATCH 4/6] ovl: mark ovl_setup_cred_for_create() as unused temporarily Christian Brauner
2025-11-14 10:15 ` [PATCH 5/6] ovl: port ovl_create_or_link() to new prepare_creds_ovl cleanup guard Christian Brauner
2025-11-14 10:15 ` [PATCH 6/6] ovl: drop ovl_setup_cred_for_create() Christian Brauner
2025-11-14 12:15 ` [PATCH 0/6] ovl: convert creation credential override to cred guard Amir Goldstein
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=CAOQ4uxie_CSG7kPBCZaKEfiQmLH7EAcMqrHXvy78ciLqX4QuKA@mail.gmail.com \
--to=amir73il@gmail.com \
--cc=brauner@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-unionfs@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=torvalds@linux-foundation.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).