public inbox for linux-unionfs@vger.kernel.org
 help / color / mirror / Atom feed
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 v12 13/17] ovl: Check redirects for metacopy files
Date: Wed, 7 Mar 2018 13:52:07 -0500	[thread overview]
Message-ID: <20180307185207.GH5350@redhat.com> (raw)
In-Reply-To: <CAOQ4uxgLiSNpQq0AE2aXdH3zMCPsdCNgxYtp71CauuGgrd20TQ@mail.gmail.com>

On Wed, Mar 07, 2018 at 02:16:25PM +0200, Amir Goldstein wrote:
> On Tue, Mar 6, 2018 at 10:54 PM, Vivek Goyal <vgoyal@redhat.com> wrote:
> > Right now we rely on path based lookup for data origin of metacopy upper.
> > This will work only if upper has not been renamed. We solved this problem
> > already for merged directories using redirect. Use same logic for metacopy
> > files.
> >
> > This patch just goes on to check redirects for metacopy files.
> >
> > Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
> > ---
> >  fs/overlayfs/namei.c | 17 ++++++++---------
> >  1 file changed, 8 insertions(+), 9 deletions(-)
> >
> > diff --git a/fs/overlayfs/namei.c b/fs/overlayfs/namei.c
> > index 220e754c974b..a4a5c5f5540d 100644
> > --- a/fs/overlayfs/namei.c
> > +++ b/fs/overlayfs/namei.c
> > @@ -265,22 +265,22 @@ static int ovl_lookup_single(struct dentry *base, struct ovl_lookup_data *d,
> >                 goto put_and_out;
> >         }
> >         if (!d_can_lookup(this)) {
> > -               if (d->is_dir)
> > -                       goto put_and_out;
> > +               d->is_dir = false;
> 
> That test was supposed to catch non-dir under dir from an upper layer
> but you are loosing the information stored in d->dir.
> 
Can you elaborate a bit more. I never understood this check.

This probably worked in the past. But now absolute redirects can be put
on regular files as well. So it is very much possible that d->is_dir
is set and then we find a non-dir dentry and in that case we don't
want to jump to "put_and_out"?

IOW, this check worked as long as redirects were supposed to be used
only for directories. Now with metacopy, redirects can be put on on
non-dir as well.

What I can probably do is that leave d->is_dir untouched. But not sure
what does that buy us. When we return back to ovl_lookup() it does not
mean anything. returned dentry could be a directory or non-directory.

If we set it to d->is_dir=false, atleast this info is meaningful in
ovl_lookup and we know if returned dentry is a direcotry or non-dir.

> >                 err = ovl_check_metacopy_xattr(this);
> >                 if (err < 0)
> >                         goto out_err;
> >                 if (!err) {
> >                         d->stop = true;
> >                         d->metacopy = false;
> > +                       goto out;
> >                 } else
> >                         d->metacopy = true;
> > -               goto out;
> > -       }
> > -       d->is_dir = true;
> > -       if (!d->last && ovl_is_opaquedir(this)) {
> > -               d->stop = d->opaque = true;
> > -               goto out;
> > +       } else {
> > +               d->is_dir = true;
> > +               if (!d->last && ovl_is_opaquedir(this)) {
> > +                       d->stop = d->opaque = true;
> > +                       goto out;
> 
> I think there is a bug here - not related to your change, but semi related
> to your recent fix patch (patch 1 in this series).
> 
> d->last is set to true when lookup in parent poe->numlower layer,
> but parent may be pure upper for example and redirect from child can still
> continue lookup to lower layers. If a directory is marked both "redirect" and
> "opaque" (which is an inconsistency). In that case, d->last will be true
> and opaque xattr will not be checked, but redirect will be checked.

I am not sure I understand the concern. d->last will be set only if this
is last layer we are looking into and in that case it does not matter if
we process opaque or not.

Say we had pure upper parent and child directory had both opaque and redirect
set. If redirect is relative, then we will not even search in lower pas
poe->numlower=0. If redirect is absolute, then poe is reset to roe and we
will start searching from root and d->last will be set when searching in
last layer. 

So I can't see what's the issue. Can you give an example.

Thanks
Vivek

> 
> Since AFAIK d->last is an optimization, I think it could be relaxed to
> lower.layer->idx == roe->numlower - 1
> and then for the d->last case, we can skip both opaque and redirect checks
> and skip redirect check for both directory and metadata.
> 
> 
> > +               }
> >         }
> >         err = ovl_check_redirect(this, d, prelen, post);
> >         if (err)
> 
> Thanks,
> Amir.

  reply	other threads:[~2018-03-07 18:52 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-06 20:53 [PATCH v12 00/17] overlayfs: Delayed copy up of data Vivek Goyal
2018-03-06 20:53 ` [PATCH v12 01/17] ovl: redirect_dir=nofollow can follow redirect for opaque lower Vivek Goyal
2018-03-06 20:53 ` [PATCH v12 02/17] ovl: Provide a mount option metacopy=on/off for metadata copyup Vivek Goyal
2018-03-07  8:47   ` Amir Goldstein
2018-03-07 15:43     ` Vivek Goyal
2018-03-06 20:53 ` [PATCH v12 03/17] ovl: During copy up, first copy up metadata and then data Vivek Goyal
2018-03-06 20:53 ` [PATCH v12 04/17] ovl: Move the copy up helpers to copy_up.c Vivek Goyal
2018-03-06 20:53 ` [PATCH v12 05/17] ovl: Copy up only metadata during copy up where it makes sense Vivek Goyal
2018-03-06 20:53 ` [PATCH v12 06/17] ovl: Add helper ovl_already_copied_up() Vivek Goyal
2018-03-06 20:53 ` [PATCH v12 07/17] ovl: A new xattr OVL_XATTR_METACOPY for file on upper Vivek Goyal
2018-03-06 20:53 ` [PATCH v12 08/17] ovl: Modify ovl_lookup() and friends to lookup metacopy dentry Vivek Goyal
2018-03-07 14:42   ` Amir Goldstein
2018-03-07 20:27     ` Vivek Goyal
2018-03-08  8:43       ` Amir Goldstein
2018-03-08 17:03         ` Vivek Goyal
2018-03-08 17:54           ` Amir Goldstein
2018-03-06 20:54 ` [PATCH v12 09/17] ovl: Do not mark a non dir as _OVL_PATH_MERGE in ovl_path_type() Vivek Goyal
2018-03-07  7:07   ` Amir Goldstein
2018-03-07 13:21     ` Vivek Goyal
2018-03-07 13:37       ` Amir Goldstein
2018-03-28 19:43         ` Vivek Goyal
2018-03-29  4:27           ` Amir Goldstein
2018-03-06 20:54 ` [PATCH v12 10/17] ovl: Copy up meta inode data from lowest data inode Vivek Goyal
2018-03-07  7:19   ` Amir Goldstein
2018-03-07 13:30     ` Vivek Goyal
2018-03-06 20:54 ` [PATCH v12 11/17] ovl: Fix ovl_getattr() to get number of blocks from lower Vivek Goyal
2018-03-06 20:54 ` [PATCH v12 12/17] ovl: Do not expose metacopy only upper dentry from d_real() Vivek Goyal
2018-03-07  7:15   ` Amir Goldstein
2018-03-07 13:29     ` Vivek Goyal
2018-03-07 13:40       ` Amir Goldstein
2018-03-07 19:13         ` Vivek Goyal
2018-03-06 20:54 ` [PATCH v12 13/17] ovl: Check redirects for metacopy files Vivek Goyal
2018-03-07 12:16   ` Amir Goldstein
2018-03-07 18:52     ` Vivek Goyal [this message]
2018-03-08  8:55       ` Amir Goldstein
2018-03-06 20:54 ` [PATCH v12 14/17] ovl: Set redirect on metacopy files upon rename Vivek Goyal
2018-03-07  7:48   ` Amir Goldstein
2018-03-07 15:15     ` Vivek Goyal
2018-03-07 16:26       ` Amir Goldstein
2018-03-07 20:43         ` Vivek Goyal
2018-03-08  8:04           ` Amir Goldstein
2018-03-06 20:54 ` [PATCH v12 15/17] ovl: Remove redirect when data of a metacopy file is copied up Vivek Goyal
2018-03-07  8:21   ` Amir Goldstein
2018-03-14 19:15     ` Vivek Goyal
2018-03-15 18:47       ` Vivek Goyal
2018-03-15 20:42         ` Amir Goldstein
2018-03-16 12:52           ` Vivek Goyal
2018-03-16 13:17             ` Amir Goldstein
2018-03-16 15:06               ` Vivek Goyal
2018-03-16 16:09                 ` Amir Goldstein
2018-03-16 18:09                   ` Vivek Goyal
2018-03-20 19:26     ` Vivek Goyal
2018-03-20 20:35       ` Vivek Goyal
2018-03-21  6:23         ` Amir Goldstein
2018-03-29 14:08     ` Vivek Goyal
2018-04-04 13:41     ` Vivek Goyal
2018-04-04 16:04       ` Amir Goldstein
2018-03-06 20:54 ` [PATCH v12 16/17] ovl: Set redirect on upper inode when it is linked Vivek Goyal
2018-03-07  8:02   ` Amir Goldstein
2018-03-07 15:19     ` Vivek Goyal
2018-03-29 14:01     ` Vivek Goyal
2018-03-29 14:09       ` Amir Goldstein
2018-03-06 20:54 ` [PATCH v12 17/17] ovl: Enable metadata only feature 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=20180307185207.GH5350@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox