From: Vivek Goyal <vgoyal@redhat.com>
To: Amir Goldstein <amir73il@gmail.com>
Cc: overlayfs <linux-unionfs@vger.kernel.org>,
Miklos Szeredi <miklos@szeredi.hu>
Subject: Re: [PATCH 08/11] ovl: Set OVL_METACOPY flag during ovl_lookup()
Date: Wed, 18 Oct 2017 09:53:27 -0400 [thread overview]
Message-ID: <20171018135327.GF3445@redhat.com> (raw)
In-Reply-To: <CAOQ4uxiEVNRbHWg=GXc7LYJm1A1LmDuHPLxYKxuJtbEa+M8f+w@mail.gmail.com>
On Wed, Oct 18, 2017 at 08:06:19AM +0300, Amir Goldstein wrote:
> On Wed, Oct 18, 2017 at 12:05 AM, Vivek Goyal <vgoyal@redhat.com> wrote:
> > During lookup, check for presence of OVL_XATTR_METACOPY and if present,
> > set OVL_METACOPY bit in flags.
> >
> > Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
> > ---
> > fs/overlayfs/namei.c | 40 ++++++++++++++++++++++++++++++++++++++++
> > 1 file changed, 40 insertions(+)
> >
> > diff --git a/fs/overlayfs/namei.c b/fs/overlayfs/namei.c
> > index 88ff1daeb3d7..d32da041f4bf 100644
> > --- a/fs/overlayfs/namei.c
> > +++ b/fs/overlayfs/namei.c
> > @@ -26,6 +26,24 @@ struct ovl_lookup_data {
> > char *redirect;
> > };
> >
> > +/* err < 0, 0 if no metacopy xattr, 1 if metacopy xattr found */
> > +static int ovl_check_metacopy(struct dentry *dentry)
> > +{
> > + int res;
> > +
> > + res = vfs_getxattr(dentry, OVL_XATTR_METACOPY, NULL, 0);
> > + if (res < 0) {
> > + if (res == -ENODATA || res == -EOPNOTSUPP)
> > + return 0;
> > + goto out;
> > + }
> > +
> > + return 1;
> > +out:
> > + pr_warn_ratelimited("overlayfs: failed to get metacopy (%i)\n", res);
> > + return res;
> > +}
> > +
> > static int ovl_check_redirect(struct dentry *dentry, struct ovl_lookup_data *d,
> > size_t prelen, const char *post)
> > {
> > @@ -594,6 +612,7 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
> > struct dentry *this;
> > unsigned int i;
> > int err;
> > + bool metacopy = false;
> > struct ovl_lookup_data d = {
> > .name = dentry->d_name,
> > .is_dir = false,
> > @@ -634,6 +653,12 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
> > roe->numlower, &stack, &ctr);
> > if (err)
> > goto out;
> > +
> > + err = ovl_check_metacopy(upperdentry);
> > + if (err < 0)
> > + goto out;
> > + if (err == 1)
> > + metacopy = true;
>
> Miklos seems to prefer
> metacopy = err;
> if (err < 0)
> goto out;
>
> Not sure if it is just coding style or for better branch prediction code.
Ok, will change.
>
>
> > }
> >
> > if (d.redirect) {
> > @@ -719,6 +744,19 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
> > OVL_I(inode)->redirect = upperredirect;
> > if (index)
> > ovl_set_flag(OVL_INDEX, inode);
> > +
> > + if (metacopy) {
> > + /*
> > + * Found an upper with metacopy set but at the same
> > + * time there is no lower dentry. Something is not
> > + * right.
> > + */
> > + if (!ctr) {
>
> Please move this test up right after ovl_check_metacopy()
> There is no reason to wait as ctr is not going to grow for non-dir after
> that point.
Makes sense. Will do.
>
> > + err = -ESTALE;
> > + goto out_put_inode;
> > + }
> > + ovl_set_flag(OVL_METACOPY, inode);
> > + }
> > }
> >
> > revert_creds(old_cred);
> > @@ -729,6 +767,8 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
> >
> > return NULL;
> >
> > +out_put_inode:
> > + iput(inode);
>
> And than new goto label becomes obsolete
Sounds good.
Vivek
>
> > out_free_oe:
> > dentry->d_fsdata = NULL;
> > kfree(oe);
> > --
> > 2.13.5
> >
next prev parent reply other threads:[~2017-10-18 13:53 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-17 21:05 [RFC PATCH 00/11][V4] overlayfs: Delayed copy up of data Vivek Goyal
2017-10-17 21:05 ` [PATCH 01/11] ovl: Create origin xattr on copy up for all files Vivek Goyal
2017-10-18 4:09 ` Amir Goldstein
2017-10-18 12:55 ` Vivek Goyal
2017-10-18 13:56 ` Amir Goldstein
2017-10-17 21:05 ` [PATCH 02/11] ovl: ovl_check_setxattr() get rid of redundant -EOPNOTSUPP check Vivek Goyal
2017-10-18 4:11 ` Amir Goldstein
2017-10-17 21:05 ` [PATCH 03/11] ovl: During copy up, first copy up metadata and then data Vivek Goyal
2017-10-18 4:13 ` Amir Goldstein
2017-10-18 4:39 ` Amir Goldstein
2017-10-17 21:05 ` [PATCH 04/11] ovl: Provide a mount option metacopy=on/off for metadata copyup Vivek Goyal
2017-10-18 4:31 ` Amir Goldstein
2017-10-18 13:03 ` Vivek Goyal
2017-10-18 14:09 ` Amir Goldstein
2017-10-18 14:26 ` Vivek Goyal
2017-10-18 14:38 ` Amir Goldstein
2017-10-18 14:10 ` Vivek Goyal
2017-10-18 14:26 ` Amir Goldstein
2017-10-17 21:05 ` [PATCH 05/11] ovl: Copy up only metadata during copy up where it makes sense Vivek Goyal
2017-10-18 4:46 ` Amir Goldstein
2017-10-17 21:05 ` [PATCH 06/11] ovl: Set xattr OVL_XATTR_METACOPY on upper file Vivek Goyal
2017-10-18 4:57 ` Amir Goldstein
2017-10-18 13:30 ` Vivek Goyal
2017-10-17 21:05 ` [PATCH 07/11] ovl: Fix ovl_getattr() to get number of blocks from lower Vivek Goyal
2017-10-18 5:01 ` Amir Goldstein
2017-10-18 13:39 ` Vivek Goyal
2017-10-17 21:05 ` [PATCH 08/11] ovl: Set OVL_METACOPY flag during ovl_lookup() Vivek Goyal
2017-10-18 5:06 ` Amir Goldstein
2017-10-18 13:53 ` Vivek Goyal [this message]
2017-10-17 21:05 ` [PATCH 09/11] ovl: Return lower dentry if only metadata copy up took place Vivek Goyal
2017-10-18 5:07 ` Amir Goldstein
2017-10-17 21:05 ` [PATCH 10/11] ovl: Introduce read/write barriers around metacopy flag update Vivek Goyal
2017-10-18 5:19 ` Amir Goldstein
2017-10-18 15:32 ` Vivek Goyal
2017-10-18 16:05 ` Amir Goldstein
2017-10-17 21:05 ` [PATCH 11/11] ovl: Put barriers to order oi->__upperdentry and OVL_METACOPY update Vivek Goyal
2017-10-18 5:40 ` Amir Goldstein
2017-10-19 13:00 ` Vivek Goyal
2017-10-19 13:21 ` Amir Goldstein
2017-10-19 14:58 ` Vivek Goyal
2017-10-19 15:08 ` Amir Goldstein
2017-10-19 15:22 ` Vivek Goyal
2017-10-19 15:39 ` Amir Goldstein
2017-10-19 15:59 ` Vivek Goyal
2017-10-19 16:33 ` Amir Goldstein
2017-10-19 20:33 ` Vivek Goyal
2017-10-20 4:09 ` Amir Goldstein
2017-10-20 15:41 ` Vivek Goyal
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=20171018135327.GF3445@redhat.com \
--to=vgoyal@redhat.com \
--cc=amir73il@gmail.com \
--cc=linux-unionfs@vger.kernel.org \
--cc=miklos@szeredi.hu \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.