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 v13 27/28] ovl: Verify a data dentry has been found for metacopy inode
Date: Thu, 5 Apr 2018 14:22:11 -0400 [thread overview]
Message-ID: <20180405182211.GB4017@redhat.com> (raw)
In-Reply-To: <20180405143757.GA4017@redhat.com>
On Thu, Apr 05, 2018 at 10:37:57AM -0400, Vivek Goyal wrote:
> On Wed, Apr 04, 2018 at 06:51:57PM +0300, Amir Goldstein wrote:
> > On Wed, Apr 4, 2018 at 4:21 PM, Vivek Goyal <vgoyal@redhat.com> wrote:
> > > On Wed, Apr 04, 2018 at 03:51:37PM +0300, Amir Goldstein wrote:
> > >> On Wed, Apr 4, 2018 at 3:29 PM, Vivek Goyal <vgoyal@redhat.com> wrote:
> > >> > On Fri, Mar 30, 2018 at 01:53:24PM +0300, Amir Goldstein wrote:
> > >> >> On Thu, Mar 29, 2018 at 10:38 PM, Vivek Goyal <vgoyal@redhat.com> wrote:
> > >> >> > If we find a upper metacopy inode, make sure we also found associated data
> > >> >> > dentry in lower. Otherwise copy up operation later will fail.
> > >> >> >
> > >> >> > There are two cases where this can happen. First case is that somehow
> > >> >> > data file was removed from lower layer. Other case is that REDIRECT
> > >> >> > xattr was removed due to copy up of file on another cpu (when inode is
> > >> >> > shared between two dentries) and hence ovl_lookup() could not find the
> > >> >> > correct dentry.
> > >> >> >
> > >> >>
> > >> >> Remind me again why we remove REDIRECT xattr?
> > >> >> Is it a must for functionality or just for being boy scouts?
> > >> >> I would prefer to avoid having to deal with races of this sort.
> > >> >> You can cleanup REDIRECT for non-dir that is not metacopy
> > >> >> on lookup when finding a I_NEW inode.
> > >> >
> > >> > Ok, thinking more about it. If we were to clean REDIRECT on lookup when
> > >> > finding I_NEW inode, that means we will have to always do
> > >> > vfs_removexattr(OVL_XATTR_REDIRECT) on all non-metacopy non-dir files.
> > >> > That does not sound like a very good idea. Its unnecessary overhead in
> > >> > lookup path.
> > >> >
> > >> > IOW, I think removing REDIRECT and doing appropriate locking around
> > >> > ovl_inode->redirect is probably better.
> > >> >
> > >>
> > >> Here is what I propose.
> > >> During lookup, you anyway check REDIRECT and check METACOPY
> > >> on upper and then call ovl_get_inode() with upper redirect and upper
> > >> metacopy information.
> > >
> > > We check for upperredirect only if metacopy xattr is found. Otherwise
> > > we skip checking for redirect.
> > >
> > > https://github.com/rhvgoyal/linux/blob/metacopy-v13/fs/overlayfs/namei.c#L270
> > >
> > >>
> > >> IF this is a new inode AND both REDIRECT and METACOPY were
> > >> found on upper THEN it is safe to remove REDIRECT xattr.
> > >
> > > If both METACOPY and REDIRECT were found, then we should not remove
> > > REDIRECT. That REDIRECT is still useful. REDIRECT should be removed
> > > only if METACOPY is not found and REDIRECT is found (on a non-dir file).
> > >
> > >>
> > >> Maybe I am missing something, but I don't see where the extra overhead
> > >> is, beyond the overhead already there for metacopy enabled lookup.
> > >
> > > Given we don't check for REDIRECT if upper is not METACOPY, that means
> > > we will have to always check for REDIRECT in ovl_get_inode() and add
> > > the unnecessary overhead (To all non-dir files).
> > >
> >
> > I see.
> >
> > >>
> > >> OTOH, I don't see what cleaning REDIRECT gets us in the first place.
> > >> During lookup, REDIRECT does not affect non metacopy non-dir,
> > >> because we skip ovl_check_redirect().
> > >> REDIRECT could actually be useful for reconstructing ORIGIN xattr
> > >> and index after copying layers, so not sure its a good thing to remove it
> > >> at all. After all, redirects are pretty rare as it is.
> > >
> > > I see it as unnecessary xattr present and feel that cleaning it is a
> > > good idea. Given we are thinking of packing REDIRECT xattr in tar file
> > > for layer backup and restore case, it makes even more sense to clean
> > > it up otherwise it shows up every where unnecessarily. I personally
> > > think it is always a good idea to cleanup information you don't need
> > > anymore, instead of letting it sit around.
> > >
> >
> > Look. I have no objection to cleaning REDIRECT, but I am saying it
> > is tricky, so I think it is going to cost you a few more patches and maybe
> > a few more review cycles, so I advised against it.
>
> Hi Amir,
>
> Anyway, I doubt these patches are going to be merged for 4.17. So
> I am fine if it takes few more revisions to properly review it. Doing
> it properly is more important. (Despite the fact that I am little
> exhausted now. :-))
>
> >
> > But here is another idea: store the redirect string in the METACOPY
> > xattr, this way, removal of METACOPY xattr atomically cleans up
> > REDIRECT and in lookup, only need to check METACOPY xattr
> > (exists but empty means no redirect).
>
> I don't like this much. I had thought about it but did not pursue it.
>
> - First of all, I don't like that REDIRECT for dir and non-dir will be
> stored differently.
>
> - Secondly, xattr is just one pience. We also need to protet
> ov_inode->redirect field and this will not solve that issue. That issue
> can be solved only if we provide proper locking so that readers and
> writers of ovl_inode->redirect don't race and run into unexpected
> surprises.
>
> Given VFS locking does not protect against copy up path races with
> rename(), I think that right solution for this problem is to protect
> against this race by taking ovl_inode->lock. I think this is something
> future readers can understand and build more functionality on top.
>
> If we are primarily worried about races against copy up for redirect, then
> we probably don't have to double lock both ovl_inodes. As you suggested,
> I should be able to move out set_redirect() earlier in rename
> path and take one lock at a time. That should simplify the locking
> logic a bit. How about this instead?
If you don't like this locking ovl_inode->lock model, I guess for now
I could live with not removing REDIRECT after copy up. Once that gets
merged, I could do one patch series just to clean up REDIRECT after copy
up and do proper locking.
Vivek
next prev parent reply other threads:[~2018-04-05 18:22 UTC|newest]
Thread overview: 91+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-29 19:38 [PATCH v13 00/28] overlayfs: Delayed copy up of data Vivek Goyal
2018-03-29 19:38 ` [PATCH v13 01/28] ovl: Set OVL_INDEX flag in ovl_get_inode() Vivek Goyal
2018-03-30 4:59 ` Amir Goldstein
2018-03-29 19:38 ` [PATCH v13 02/28] ovl: Initialize ovl_inode->redirect " Vivek Goyal
2018-03-30 4:57 ` Amir Goldstein
2018-03-29 19:38 ` [PATCH v13 03/28] ovl: Rename local variable locked to new_locked Vivek Goyal
2018-03-30 4:58 ` Amir Goldstein
2018-03-29 19:38 ` [PATCH v13 04/28] ovl: Provide a mount option metacopy=on/off for metadata copyup Vivek Goyal
2018-03-30 4:52 ` Amir Goldstein
2018-04-02 13:56 ` Vivek Goyal
2018-04-05 20:16 ` Amir Goldstein
2018-04-06 13:51 ` Vivek Goyal
2018-03-29 19:38 ` [PATCH v13 05/28] ovl: During copy up, first copy up metadata and then data Vivek Goyal
2018-03-29 19:38 ` [PATCH v13 06/28] ovl: Move the copy up helpers to copy_up.c Vivek Goyal
2018-03-29 19:38 ` [PATCH v13 07/28] ovl: Copy up only metadata during copy up where it makes sense Vivek Goyal
2018-03-29 19:38 ` [PATCH v13 08/28] ovl: Add helper ovl_already_copied_up() Vivek Goyal
2018-03-29 19:38 ` [PATCH v13 09/28] ovl: A new xattr OVL_XATTR_METACOPY for file on upper Vivek Goyal
2018-04-11 15:10 ` Amir Goldstein
2018-04-11 15:53 ` Vivek Goyal
2018-03-29 19:38 ` [PATCH v13 10/28] ovl: Modify ovl_lookup() and friends to lookup metacopy dentry Vivek Goyal
2018-03-30 5:49 ` Amir Goldstein
2018-03-30 9:12 ` Amir Goldstein
2018-04-02 19:45 ` Vivek Goyal
2018-04-02 20:07 ` Amir Goldstein
2018-04-02 15:06 ` Vivek Goyal
2018-03-29 19:38 ` [PATCH v13 11/28] ovl: Copy up meta inode data from lowest data inode Vivek Goyal
2018-03-29 19:38 ` [PATCH v13 12/28] ovl: Fix ovl_getattr() to get number of blocks from lower Vivek Goyal
2018-03-30 9:24 ` Amir Goldstein
2018-04-02 20:11 ` Vivek Goyal
2018-04-02 20:27 ` Amir Goldstein
2018-03-29 19:38 ` [PATCH v13 13/28] ovl: Add helper ovl_dentry_lowerdata() to get lower data dentry Vivek Goyal
2018-03-30 6:01 ` Amir Goldstein
2018-04-02 15:08 ` Vivek Goyal
2018-03-29 19:38 ` [PATCH v13 14/28] ovl: Do not expose metacopy only dentry from d_real() Vivek Goyal
2018-03-29 19:38 ` [PATCH v13 15/28] ovl: Move some of ovl_nlink_start() functionality in ovl_nlink_prep() Vivek Goyal
2018-03-30 6:23 ` Amir Goldstein
2018-03-29 19:38 ` [PATCH v13 16/28] ovl: Create locked version of ovl_nlink_start() and ovl_nlink_end() Vivek Goyal
2018-03-30 6:28 ` Amir Goldstein
2018-03-29 19:38 ` [PATCH v13 17/28] ovl: During rename lock both source and target ovl_inode Vivek Goyal
2018-03-30 6:50 ` Amir Goldstein
2018-04-02 17:34 ` Vivek Goyal
2018-03-29 19:38 ` [PATCH v13 18/28] ovl: Check redirects for metacopy files Vivek Goyal
2018-03-30 10:02 ` Amir Goldstein
2018-04-02 20:29 ` Vivek Goyal
2018-04-03 5:44 ` Amir Goldstein
2018-04-03 12:31 ` Vivek Goyal
2018-03-29 19:38 ` [PATCH v13 19/28] ovl: Treat metacopy dentries as type OVL_PATH_MERGE Vivek Goyal
2018-03-30 6:52 ` Amir Goldstein
2018-03-29 19:38 ` [PATCH v13 20/28] ovl: Do not set dentry type ORIGIN for broken hardlinks Vivek Goyal
2018-03-30 9:54 ` Amir Goldstein
2018-04-10 14:00 ` Vivek Goyal
2018-04-10 19:20 ` Amir Goldstein
2018-04-10 19:29 ` Amir Goldstein
2018-04-10 20:59 ` Vivek Goyal
2018-04-10 20:51 ` Vivek Goyal
2018-04-11 8:58 ` Amir Goldstein
2018-04-11 13:31 ` Vivek Goyal
2018-03-29 19:38 ` [PATCH v13 21/28] ovl: Set redirect on metacopy files upon rename Vivek Goyal
2018-03-30 7:31 ` Amir Goldstein
2018-04-11 15:12 ` Vivek Goyal
2018-04-11 17:01 ` Amir Goldstein
2018-03-29 19:38 ` [PATCH v13 22/28] ovl: Set redirect on upper inode when it is linked Vivek Goyal
2018-03-30 7:04 ` Amir Goldstein
2018-04-11 15:59 ` Vivek Goyal
2018-03-29 19:38 ` [PATCH v13 23/28] ovl: Remove redirect when data of a metacopy file is copied up Vivek Goyal
2018-03-29 19:38 ` [PATCH v13 24/28] ovl: Do not error if REDIRECT XATTR is missing Vivek Goyal
2018-03-30 7:41 ` Amir Goldstein
2018-03-29 19:38 ` [PATCH v13 25/28] ovl: Use out_err insteada of out_nomem Vivek Goyal
2018-03-30 7:35 ` Amir Goldstein
2018-03-29 19:38 ` [PATCH v13 26/28] ovl: Re-check redirect xattr during inode initialization Vivek Goyal
2018-03-30 8:56 ` Amir Goldstein
2018-04-02 19:35 ` Vivek Goyal
2018-04-02 20:25 ` Amir Goldstein
2018-03-29 19:38 ` [PATCH v13 27/28] ovl: Verify a data dentry has been found for metacopy inode Vivek Goyal
2018-03-30 10:53 ` Amir Goldstein
2018-04-02 12:39 ` Vivek Goyal
2018-04-04 12:29 ` Vivek Goyal
2018-04-04 12:51 ` Amir Goldstein
2018-04-04 13:21 ` Vivek Goyal
2018-04-04 15:51 ` Amir Goldstein
2018-04-05 14:37 ` Vivek Goyal
2018-04-05 18:22 ` Vivek Goyal [this message]
2018-04-05 19:58 ` Amir Goldstein
2018-04-05 20:45 ` Vivek Goyal
2018-04-06 9:46 ` Amir Goldstein
2018-04-06 15:37 ` Vivek Goyal
2018-04-06 16:21 ` Amir Goldstein
2018-04-06 17:32 ` Vivek Goyal
2018-04-06 20:10 ` Amir Goldstein
2018-04-09 12:18 ` Vivek Goyal
2018-03-29 19:38 ` [PATCH v13 28/28] 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=20180405182211.GB4017@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