public inbox for linux-unionfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Vivek Goyal <vgoyal@redhat.com>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: linux-unionfs@vger.kernel.org, Amir Goldstein <amir73il@gmail.com>
Subject: Re: [PATCH v9 08/15] ovl: Copy up only metadata during copy up where it makes sense
Date: Mon, 8 Jan 2018 12:03:13 -0500	[thread overview]
Message-ID: <20180108170313.GD9910@redhat.com> (raw)
In-Reply-To: <CAJfpegsXEgz6=y7eLe5kJLKHtCyEP5LxzXkg2zB5JjgNJ3=bfg@mail.gmail.com>

On Mon, Jan 08, 2018 at 11:35:09AM +0100, Miklos Szeredi wrote:
> On Wed, Nov 29, 2017 at 4:54 PM, Vivek Goyal <vgoyal@redhat.com> wrote:
> > If it makes sense to copy up only metadata during copy up, do it. This
> > is done for regular files which are not opened for WRITE and have origin
> > being saved.
> >
> > Right now ->metacopy is set to 0 always. Last patch in the series will
> > remove the hard coded statement and enable metacopy feature.
> >
> > Reviewed-by: Amir Goldstein <amir73il@gmail.com>
> > Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
> > ---
> >  fs/overlayfs/copy_up.c | 38 +++++++++++++++++++++++++++++++-------
> >  1 file changed, 31 insertions(+), 7 deletions(-)
> >
> > diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c
> > index 31711edf5bde..c5804b87f3c7 100644
> > --- a/fs/overlayfs/copy_up.c
> > +++ b/fs/overlayfs/copy_up.c
> > @@ -232,6 +232,26 @@ int ovl_set_attr(struct dentry *upperdentry, struct kstat *stat)
> >         return err;
> >  }
> >
> > +static bool ovl_need_meta_copy_up(struct dentry *dentry, umode_t mode,
> > +                                 int flags)
> > +{
> > +       struct ovl_fs *ofs = dentry->d_sb->s_fs_info;
> > +
> > +       /* TODO: Will enable metacopy in last patch of series */
> > +       return false;
> > +
> > +       if (!ofs->config.metacopy)
> > +               return false;
> > +
> > +       if (!S_ISREG(mode))
> > +               return false;
> > +
> > +       if (flags && ((OPEN_FMODE(flags) & FMODE_WRITE) || (flags & O_TRUNC)))
> > +               return false;
> > +
> > +       return true;
> > +}
> > +
> >  struct ovl_fh *ovl_encode_fh(struct dentry *lower, bool is_upper)
> >  {
> >         struct ovl_fh *fh;
> > @@ -305,11 +325,8 @@ static int ovl_set_origin(struct dentry *dentry, struct dentry *lower,
> >                         return PTR_ERR(fh);
> >         }
> >
> > -       /*
> > -        * Do not fail when upper doesn't support xattrs.
> > -        */
> >         err = ovl_check_setxattr(dentry, upper, OVL_XATTR_ORIGIN, fh,
> > -                                fh ? fh->len : 0, 0);
> > +                                fh ? fh->len : 0, -EOPNOTSUPP);
> >         kfree(fh);
> >
> >         return err;
> > @@ -326,6 +343,7 @@ struct ovl_copy_up_ctx {
> >         struct qstr destname;
> >         struct dentry *workdir;
> >         bool tmpfile;
> > +       bool metacopy;
> >  };
> >
> >  static int ovl_link_up(struct ovl_copy_up_ctx *c)
> > @@ -453,10 +471,14 @@ static int ovl_copy_up_inode(struct ovl_copy_up_ctx *c, struct dentry *temp)
> >          *
> >          */
> >         err = ovl_set_origin(c->dentry, c->lowerpath.dentry, temp);
> > -       if (err)
> > -               return err;
> > +       if (err) {
> > +               if (err != -EOPNOTSUPP)
> > +                       return err;
> > +               /* Upper does not support xattr. Copy up data as well */
> > +               c->metacopy = false;
> 
> Isn't this supposed to be checked in ovl_get_super()?

Hi Miklos,

Right. I think I was confused by code in ovl_check_setxattr().

int ovl_check_setxattr(struct dentry *dentry, struct dentry *upperdentry,
                       const char *name, const void *value, size_t size,
                       int xerr)
{
        int err;
        struct ovl_fs *ofs = dentry->d_sb->s_fs_info;

        if (ofs->noxattr)
                return xerr;

        err = ovl_do_setxattr(upperdentry, name, value, size, 0);

        if (err == -EOPNOTSUPP) {
                pr_warn("overlayfs: cannot set %s xattr on upper\n", name);
                ofs->noxattr = true;
                return xerr;
        }

        return err;
}

ofs->noxattr will be set at mount time. Still we check for -EOPNOTSUPP
and set ofs->noxattr again. Is there a situation where this can happen.
Is it intentional. Can we get rid of this code.

To take care of this situation, I put that code. That is at mount time
xattr was fine and hence ofs->noxattr=false. But later somehow we 
encountered -EOPNOTSUPP while doing ovl_set_origin(). Current code
does not fail copy up operation and I tried to retain same behavior.
That is just disable metacopy in such case but continue.

So if we don't expect all this to happen at all, then I can get rid
of this -EOPNOTSUPP check both from ovl_check_setxattr() as well
as ovl_copy_up_inode().

Vivek

  reply	other threads:[~2018-01-08 17:03 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-29 15:54 [PATCH v9 00/15] overlayfs: Delayed copy up of data Vivek Goyal
2017-11-29 15:54 ` [PATCH v9 01/15] ovl: Do not look for OVL_XATTR_NLINK if index is not there Vivek Goyal
2017-11-29 17:04   ` Amir Goldstein
2017-11-29 15:54 ` [PATCH v9 02/15] ovl: disable redirect_dir and index when no xattr support Vivek Goyal
2017-11-29 15:54 ` [PATCH v9 03/15] ovl: ovl_check_setxattr() get rid of redundant -EOPNOTSUPP check Vivek Goyal
2017-11-29 15:54 ` [PATCH v9 04/15] ovl: Create origin xattr on copy up for all files Vivek Goyal
2018-01-08 10:16   ` Miklos Szeredi
2018-01-08 11:18     ` Amir Goldstein
2018-01-08 15:58       ` Vivek Goyal
2017-11-29 15:54 ` [PATCH v9 05/15] ovl: Provide a mount option metacopy=on/off for metadata copyup Vivek Goyal
2017-11-29 15:54 ` [PATCH v9 06/15] ovl: During copy up, first copy up metadata and then data Vivek Goyal
2017-11-29 15:54 ` [PATCH v9 07/15] ovl: Move the copy up helpers to copy_up.c Vivek Goyal
2017-11-29 15:54 ` [PATCH v9 08/15] ovl: Copy up only metadata during copy up where it makes sense Vivek Goyal
2018-01-08 10:35   ` Miklos Szeredi
2018-01-08 17:03     ` Vivek Goyal [this message]
2018-01-09 10:49       ` Miklos Szeredi
2018-01-09 13:26         ` Vivek Goyal
2018-01-09 13:33           ` Amir Goldstein
2018-01-09 20:34             ` Vivek Goyal
2017-11-29 15:54 ` [PATCH v9 09/15] ovl: Add helper ovl_already_copied_up() Vivek Goyal
2017-11-29 15:54 ` [PATCH v9 10/15] ovl: A new xattr OVL_XATTR_METACOPY for file on upper Vivek Goyal
2018-01-08 15:50   ` Miklos Szeredi
2018-01-08 16:17     ` Vivek Goyal
2018-01-08 16:21       ` Miklos Szeredi
2018-01-08 16:25         ` Miklos Szeredi
2017-11-29 15:54 ` [PATCH v9 11/15] ovl: Fix ovl_getattr() to get number of blocks from lower Vivek Goyal
2017-11-29 15:54 ` [PATCH v9 12/15] ovl: Set OVL_UPPERDATA flag during ovl_lookup() Vivek Goyal
2017-11-29 15:54 ` [PATCH v9 13/15] ovl: Do not expose metacopy only upper dentry from d_real() Vivek Goyal
2017-11-29 15:54 ` [PATCH v9 14/15] ovl: Fix encryption/compression status of a metacopy only file Vivek Goyal
2018-01-18 14:24   ` Vivek Goyal
2018-01-18 14:32     ` Amir Goldstein
2018-01-18 14:36       ` Vivek Goyal
2017-11-29 15:54 ` [PATCH v9 15/15] ovl: Enable metadata only feature Vivek Goyal
2018-01-06  7:38 ` [PATCH v9 00/15] overlayfs: Delayed copy up of data Amir Goldstein
2018-01-08 14:13   ` Vivek Goyal
2018-01-08 14:42     ` Amir Goldstein
2018-01-08 15:44       ` Vivek Goyal
2018-01-10 14:56       ` Vivek Goyal
2018-01-10 15:08         ` Miklos Szeredi
2018-01-10 15:23           ` Vivek Goyal
2018-01-10 15:10         ` Amir Goldstein
2018-01-10 15:27           ` Vivek Goyal
2018-01-10 15:38             ` Miklos Szeredi
2018-01-10 15:47               ` Vivek Goyal
2018-01-10 15:54                 ` Amir Goldstein
2018-01-10 16:03                   ` Miklos Szeredi
2018-01-10 16:30                     ` Vivek Goyal
2018-01-10 17:05                       ` 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=20180108170313.GD9910@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