All of lore.kernel.org
 help / color / mirror / Atom feed
From: Miklos Szeredi <miklos@szeredi.hu>
To: Amir Goldstein <amir73il@gmail.com>
Cc: Chandan Rajendra <chandan@linux.vnet.ibm.com>,
	Vivek Goyal <vgoyal@redhat.com>,
	"linux-unionfs@vger.kernel.org" <linux-unionfs@vger.kernel.org>
Subject: Re: [PATCH v7 7/8] ovl: update cache version of impure parent on rename
Date: Mon, 6 Nov 2017 11:39:25 +0100	[thread overview]
Message-ID: <CAJfpegseWaL_Y5_vHBOOkTiKOFkhsB6XkHpFiVS0EyMFx4H9mg@mail.gmail.com> (raw)
In-Reply-To: <CAOQ4uxi7NNwvnvcjo3qSFG2h8r9jTx0NrrruJCzraf3bA8WD5A@mail.gmail.com>

On Mon, Nov 6, 2017 at 11:06 AM, Amir Goldstein <amir73il@gmail.com> wrote:
> On Mon, Nov 6, 2017 at 11:17 AM, Miklos Szeredi <miklos@szeredi.hu> wrote:
>> On Thu, Nov 2, 2017 at 9:38 PM, Amir Goldstein <amir73il@gmail.com> wrote:
>>> ovl_rename() updates dir cache version for impure old parent if an entry
>>> with copy up origin is moved into old parent, but it did not update
>>> cache version if the entry moved out of old parent has a copy up origin.
>>>
>>> Signed-off-by: Amir Goldstein <amir73il@gmail.com>
>>> ---
>>>  fs/overlayfs/dir.c | 5 +++--
>>>  1 file changed, 3 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
>>> index ef533198be45..26aef3b5f007 100644
>>> --- a/fs/overlayfs/dir.c
>>> +++ b/fs/overlayfs/dir.c
>>> @@ -1075,9 +1075,10 @@ static int ovl_rename(struct inode *olddir, struct dentry *old,
>>>                         drop_nlink(d_inode(new));
>>>         }
>>>
>>> -       ovl_dentry_version_inc(old->d_parent,
>>> -                              !overwrite && ovl_type_origin(new));
>>> +       ovl_dentry_version_inc(old->d_parent, ovl_type_origin(old));
>>>         ovl_dentry_version_inc(new->d_parent, ovl_type_origin(old));
>>> +       if (!overwrite)
>>> +               ovl_dentry_version_inc(old->d_parent, ovl_type_origin(new));
>>
>> How about the opposite (i.e. newdir losing impurity)?  That can happen two ways:
>>
>>   - overwriting copied up file (new) with pure one (old)
>>   - exchange copied up file (new) with pure one (old)
>>
>> Also I'd merge the two version increments into one, although that
>> doesn't really matter:
>>
>> -    ovl_dentry_version_inc(old->d_parent,
>> -                   !overwrite && ovl_type_origin(new));
>> -    ovl_dentry_version_inc(new->d_parent, ovl_type_origin(old));
>> +    ovl_dentry_version_inc(old->d_parent, ovl_type_origin(old) ||
>> +                   (!overwrite && ovl_type_origin(new)));
>> +    ovl_dentry_version_inc(new->d_parent,
>> +                   ovl_type_origin(old) || ovl_type_origin(new));
>>
>> Fixed up the patch, but tell me if I'm missing something here.
>>
>
> I think you are.
> Both my version and your version are wrong because the argument
> 'impurity' should really be 'impurity_change'
>
> so if we have:
> oldimpurity = ovl_type_origin(old);
> newimpurity = d_inode(new) ? ovl_type_origin(new) : false;
>
> version increment should really be something like this:
> ovl_dentry_version_inc(old->d_parent, oldimpurity ^ (overwrite ?
> newimpurity : false));
> ovl_dentry_version_inc(new->d_parent, oldimpurity ^ newimpurity);
>
>
> I think...

We are not only interested in change of state, but rather if the cache
is valid or not.  If an impurity is removed and another added, then
that needs to be noted as well.

Note: strictly speaking we don't need to invalidate the cache on entry
removal (that's why things worked fine before this patch).  And in
fact recalculating the cache on every removal of an impurity might
well cause worse performance than not doing that.  So this could be
further optimized to differentiate between removal and addition of
impurity and only "garbage collect" old caches occasionally.  But lets
not get lost in such details for now.

Thanks,
Miklos

  reply	other threads:[~2017-11-06 10:39 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-02 20:38 [PATCH v7 0/8] Overlayfs: constant st_ino/d_ino for non-samefs Amir Goldstein
2017-11-02 20:38 ` [PATCH v7 1/8] ovl: move include of ovl_entry.h into overlayfs.h Amir Goldstein
2017-11-02 20:38 ` [PATCH v7 2/8] ovl: re-structure overlay lower layers in-memory Amir Goldstein
2017-11-02 20:38 ` [PATCH v7 3/8] ovl: allocate anonymous devs for lowerdirs Amir Goldstein
2017-11-02 20:38 ` [PATCH v7 4/8] ovl: return anonymous st_dev for lower inodes Amir Goldstein
2017-11-02 20:38 ` [PATCH v7 5/8] ovl: relax same fs constraint for constant st_ino Amir Goldstein
2017-11-06 20:43   ` Vivek Goyal
2017-11-06 21:06     ` Amir Goldstein
2017-11-06 21:10       ` Amir Goldstein
2017-11-02 20:38 ` [PATCH v7 6/8] ovl: recalc d_ino for dir cache in non-samefs case Amir Goldstein
2017-11-02 20:38 ` [PATCH v7 7/8] ovl: update cache version of impure parent on rename Amir Goldstein
2017-11-06  9:17   ` Miklos Szeredi
2017-11-06 10:06     ` Amir Goldstein
2017-11-06 10:39       ` Miklos Szeredi [this message]
2017-11-06 10:59         ` Amir Goldstein
2017-11-02 20:38 ` [PATCH v7 8/8] ovl: ovl_iterate_real() for all pure upper/lower in non-samefs case Amir Goldstein
2017-11-06  9:35   ` Miklos Szeredi
2017-11-06 10:08     ` Amir Goldstein
2017-11-06 10:54       ` Amir Goldstein
2017-11-06 11:45     ` Amir Goldstein
2017-11-06 13:57       ` Miklos Szeredi
2017-11-06 14:30         ` Amir Goldstein
2017-11-06 14:52           ` Miklos Szeredi

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=CAJfpegseWaL_Y5_vHBOOkTiKOFkhsB6XkHpFiVS0EyMFx4H9mg@mail.gmail.com \
    --to=miklos@szeredi.hu \
    --cc=amir73il@gmail.com \
    --cc=chandan@linux.vnet.ibm.com \
    --cc=linux-unionfs@vger.kernel.org \
    --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.