From: Chandan Rajendra <chandan@linux.vnet.ibm.com>
To: Amir Goldstein <amir73il@gmail.com>
Cc: overlayfs <linux-unionfs@vger.kernel.org>,
Miklos Szeredi <miklos@szeredi.hu>
Subject: Re: [PATCH] check_layer: Add tests for constant st_dev
Date: Fri, 07 Jul 2017 11:06:43 +0530 [thread overview]
Message-ID: <3081705.s7MyyWUpSq@localhost.localdomain> (raw)
In-Reply-To: <CAOQ4uxiS9b7GboLpV2-FekiD+uND3Nofiybdr_=w-XcvhH+pkw@mail.gmail.com>
On Tuesday, July 4, 2017 11:33:57 PM IST Amir Goldstein wrote:
> On Tue, Jul 4, 2017 at 8:00 PM, Chandan Rajendra
> <chandan@linux.vnet.ibm.com> wrote:
> > With constant st_dev implemented, overlayfs never returns the real dev
> > corresponding to lowerdir filesystems. Also, for the samefs case,
> > overlayfs always returns the pseudo st_dev corresponding to the union
> > layer.
> >
> > Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
>
> Chandan,
>
> Tests look correct, however, the tests are correct for a future
> version of overlayfs
> (overlayfs-devel branch) and we don't want to break unionmounts for current
> stable kernel and not even for older kernels, so we have to maintain backward
> compat somehow...
> I suggest that you use the config flag self.config().is_verify(),
> which I already
> introduced in order to support old kernels w.r.t constant ino check,
> as an indication for which st_dev can be expected in layer check.
>
> I think the rules should be:
> 1. ./run --verify --samefs # should enforce all dentries on overlay st_dev
> 2. ./run --verify # should enforce the rules that you wrote
> 3. ./run [--samefs] # should allow for either old kernel rules or new rules
>
> Your challenge is to manage to describe all those rules in a clean and
> short way,
> just like you did with this patch.
>
> Good luck!
> Amir.
>
> (see two more comments below)
>
> > ---
> > context.py | 10 ++++------
> > 1 file changed, 4 insertions(+), 6 deletions(-)
> >
> > diff --git a/context.py b/context.py
> > index 829fb69..f6dbbe7 100644
> > --- a/context.py
> > +++ b/context.py
> > @@ -532,17 +532,15 @@ class test_context:
> > if self.skip_layer_test():
> > pass
> > elif dev == self.lower_fs():
> > - if dentry.is_dir():
> > - raise TestError(name + ": Directory unexpectedly on lower filesystem")
> > + # Overlayfs never returns st_dev corresponding to any of
> > + # the lower layers
> > + raise TestError(name + ": File unexpectedly has lowerfs dev id")
> > elif dentry.is_dir():
> > if dev != self.upper_dir_fs():
> > raise TestError(name + ": Directory not on union layer")
> > elif dev == self.upper_fs() and not dentry.on_upper():
> > raise TestError(name + ": File unexpectedly on upper layer")
>
> You can and should also add the opposite check to enforce that:
> if dentry.on_upper() and not self.config().is_samefs() and dev !=
> self.upper_fs():
> "File unexpectedly not on upper layer"
Hi Amir,
The above check will fail on the newer kernels which might have non-dirs (on
non-samefs overlay instances) which have been copied-up from a file originally
present on lowerdir. For such files, on_upper will be set but st_dev would
correspond to the pseudo device that ovl_getattr() returns.
I have tried to groups together the tests within "is_samefs()" and
"is_verify()" groups as shown below,
diff --git a/context.py b/context.py
index 829fb69..b6a980f 100644
--- a/context.py
+++ b/context.py
@@ -530,20 +530,26 @@ class test_context:
#self.output("- check_layer ", dentry.filename(), " -", dentry.layer(), " # ", dev, "\n")
if self.skip_layer_test():
- pass
- elif dev == self.lower_fs():
- if dentry.is_dir():
- raise TestError(name + ": Directory unexpectedly on lower filesystem")
- elif dentry.is_dir():
+ return
+
+ if self.config().is_samefs():
if dev != self.upper_dir_fs():
+ raise TestError(name + ": File not on union layer")
+
+ if self.config().is_verify():
+ if dev == self.lower_fs():
+ # Overlayfs never returns st_dev corresponding to any of
+ # the lower layers
+ raise TestError(name + ": File unexpectedly on lower layer")
+ if dentry.is_dir() and dev != self.upper_dir_fs():
raise TestError(name + ": Directory not on union layer")
- elif dev == self.upper_fs() and not dentry.on_upper():
+
+ if dev == self.upper_fs() and not dentry.on_upper():
raise TestError(name + ": File unexpectedly on upper layer")
- elif dev != self.upper_fs() and dev != self.upper_dir_fs() and self.config().is_samefs():
- # For samefs, file is on overlay dev
- # TODO: for non-samefs, check file dev matches pseudo dev
- # and that pseduo dev != real dev
- raise TestError(name + ": File on unexpected layer")
+
+ if not self.config().is_samefs() and not self.config().is_verify() \
+ and dentry.on_upper() and dev != self.upper_fs():
+ raise TestError(name + ": File unexpectedly not on upper layer")
if dentry.is_sym() and dentry not in symlinks:
symlinks.add(dentry)
However, as described above, the last added test fails on newer kernels. I
am still trying to figure out an ideal place in check_layer() to add this
test.
--
chandan
next prev parent reply other threads:[~2017-07-07 5:36 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-04 17:00 [PATCH] check_layer: Add tests for constant st_dev Chandan Rajendra
2017-07-04 18:03 ` Amir Goldstein
2017-07-07 5:36 ` Chandan Rajendra [this message]
2017-07-07 20:35 ` Amir Goldstein
2017-07-07 21:09 ` Amir Goldstein
2017-07-08 8:12 ` Amir Goldstein
2017-07-13 14:17 ` Chandan Rajendra
2017-07-13 14:59 ` Amir Goldstein
2017-07-13 15:10 ` 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=3081705.s7MyyWUpSq@localhost.localdomain \
--to=chandan@linux.vnet.ibm.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