All of lore.kernel.org
 help / color / mirror / Atom feed
From: Amir Goldstein <amir73il@gmail.com>
To: Vivek Goyal <vgoyal@redhat.com>
Cc: overlayfs <linux-unionfs@vger.kernel.org>,
	Miklos Szeredi <miklos@szeredi.hu>,
	"Eric W. Biederman" <ebiederm@xmission.com>
Subject: Re: [PATCH 3/9] ovl: Provide a mount option metacopy=on/off for metadata copyup
Date: Wed, 11 Oct 2017 20:36:03 +0300	[thread overview]
Message-ID: <CAOQ4uxiano2-_YBOgND9O+D3B8bbHK1fUvUwQWev9HGmCkFmjQ@mail.gmail.com> (raw)
In-Reply-To: <20171011165348.GC8086@redhat.com>

On Wed, Oct 11, 2017 at 7:53 PM, Vivek Goyal <vgoyal@redhat.com> wrote:
> On Wed, Oct 11, 2017 at 07:29:38PM +0300, Amir Goldstein wrote:
>
> [..]
>> >
>> > Anyway, I did not understand what's the problem with borken upper
>> > hardlinks when index=off. If two upper hardlinks (broken), can
>> > point to same ORIGIN on lower, they will just copy up same data.
>> >
>> > IOW, it does not seem to be more broken then what it is now just
>> > becase of metadata copy up or because of both upper pointing to
>> > same ORIGIN? What am I missing.
>> >
>> It is not broken now because we intentionally do NOT set origin when
>> copying up lower hardlinks and index is disabled.
>> You must not break this rule, so instead you can avoid metacopy for
>> lower hardlinks when index is disabled.
>
> Hi Amir,
>
> Ok, I am open to change it so that if index=off, lower hardlinks are not
> copied up metadata only.
>
> But please help me understand that what *additional* thing breaks if origin
> is set when index=off.
>
> Say lower has a file foo.txt and another hard link foo-link.txt.
> (say index=off, metacopy=off).
>
> Say, I open foo-link.txt for WRITE, and it gets copied up. Now there is
> no link between foo-link.txt and foo.txt and if a user opens foo.txt for
> READ, it does not see updates to foo-link.txt. So this is the broken
> behavior of hardlinks with index=off, as of today.
>
> Now I go back to original state and this time do same operation with
> (indxex=off, metacopy=on). Then "chown foo-link.txt" will only copy
> metadata and set origin to lower file. Say I also chown "foo.txt", that
> will do the same thing. Now both foo.txt and foo-link.txt will have
> ORIGIN pointing to same lower inode. If any of the file is opened for
> WRITE, data will be copied up from same origin.
>
> So setting same ORIGIN on two upper files, does not seem to break anything
> additional, AFAICS. What am I missing.
>

Sorry for brevity of my response earlier. I was hopping on a plane.
The problem is a bit convoluted to explain, but here goes.

ORIGIN was introduced to implement constant st_ino across copy up.
stat(2) of an overlay file with ORIGIN (both layer in same fs) returns
st_ino of origin inode.

When copy up breaks lower hardlink to *different* upper inodes,
then those broken aliases MUST NOT return the same st_ino,
because they are different files with different data.

Only when index is enabled and copy up does not break lower
hardlink, it is legal to set ORIGIN for every upper alias, because
all upper aliases can and should return same st_ino (the origin st_ino)
from stat(2).

So that is the simplest way to explain why you MUST NOT set ORIGIN
on copy up of lower hardlink when index is disabled and therefore, you
cannot use ORIGIN for metacopy.

As I wrote in some email, you could set METAORIGIN xattr in this case
just for the use of metacopy, but I rather not have this special case.

Beyond the problem stated above with st_ino of broken hardlinks,
if broken hardlinks have the same ORIGIN, this also breaks indexing
assumptions and can lead to EIO on lookup, but no need to get into that.

Hope this is clear now,
Cheers,
Amir.

  reply	other threads:[~2017-10-11 17:36 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-10 15:32 [RFC PATCH 0/9][V3] overlayfs: Delayed copy up of data Vivek Goyal
2017-10-10 15:32 ` [PATCH 1/9] ovl: ovl_check_setxattr() get rid of redundant -EOPNOTSUPP check Vivek Goyal
2017-10-10 15:32 ` [PATCH 2/9] ovl: During copy up, first copy up metadata and then data Vivek Goyal
2017-10-10 15:32 ` [PATCH 3/9] ovl: Provide a mount option metacopy=on/off for metadata copyup Vivek Goyal
2017-10-11  1:36   ` Amir Goldstein
2017-10-11 13:57     ` Vivek Goyal
2017-10-11 16:29       ` Amir Goldstein
2017-10-11 16:53         ` Vivek Goyal
2017-10-11 17:36           ` Amir Goldstein [this message]
2017-10-11 18:34             ` Vivek Goyal
2017-10-11 20:29               ` Amir Goldstein
2017-10-12 13:23                 ` Vivek Goyal
2017-10-12 13:39                   ` Amir Goldstein
2017-10-10 15:32 ` [PATCH 4/9] ovl: Copy up only metadata during copy up where it makes sense Vivek Goyal
2017-10-10 15:32 ` [PATCH 5/9] ovl: Set xattr OVL_XATTR_METACOPY on upper file Vivek Goyal
2017-10-10 17:03   ` Amir Goldstein
2017-10-11 20:16     ` Vivek Goyal
2017-10-11 20:44       ` Amir Goldstein
2017-10-10 15:32 ` [PATCH 6/9] ovl: Fix ovl_getattr() to get number of blocks from lower Vivek Goyal
2017-10-10 15:32 ` [PATCH 7/9] ovl: Introduce read/write barriers around metacopy flag update Vivek Goyal
2017-10-10 17:12   ` Amir Goldstein
2017-10-11 20:27     ` Vivek Goyal
2017-10-11 21:08       ` Amir Goldstein
2017-10-13 18:27         ` Vivek Goyal
2017-10-14  6:05           ` Amir Goldstein
2017-10-14  7:00             ` Amir Goldstein
2017-10-16 13:24               ` Vivek Goyal
2017-10-16 13:24             ` Vivek Goyal
2017-10-16 13:31               ` Amir Goldstein
2017-10-10 15:32 ` [PATCH 8/9] ovl: Set OVL_METACOPY flag during ovl_lookup() Vivek Goyal
2017-10-10 15:32 ` [PATCH 9/9] ovl: Return lower dentry if only metadata copy up took place 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=CAOQ4uxiano2-_YBOgND9O+D3B8bbHK1fUvUwQWev9HGmCkFmjQ@mail.gmail.com \
    --to=amir73il@gmail.com \
    --cc=ebiederm@xmission.com \
    --cc=linux-unionfs@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=vgoyal@redhat.com \
    /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.