[5/5] zdtm: now tempfs_overmounted will pass so remove crfail

Submitted by Andrei Vagin on Dec. 7, 2017, 3:07 p.m.

Details

Message ID 20171207150703.GA3373@outlook.office365.com
State New
Series "mount: make it possible to dump overmounted mount"
Headers show

Commit Message

Andrei Vagin Dec. 7, 2017, 3:07 p.m.
On Thu, Dec 07, 2017 at 09:28:04AM +0300, ptikhomirov wrote:
> Sorry, I can't find your patch, may be it is due to watching from a mobile.
> Please resend it somewhere.

Oops, I forgot to attach it.


> 
> 
> 
> Best regards, Tikhomirov Pavel.
> Andrew Vagin <avagin@virtuozzo.com> | От: 7 дек. 2017 г. 8:41 ДП | Сообщение:
> 
> 
>     Did you check my patch from a previous comment? Does it work now?
> 
>     On Wed, Dec 06, 2017 at 04:51:21PM +0300, Pavel Tikhomirov wrote:
>     > changes in v2:
>     > make test check that file on overmounted tmpfs mount is dumped
>     >
>     > Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
>     > ---
>     >  test/zdtm/static/tempfs_overmounted.c    | 22 ++++++++++++++++++++++
>     >  test/zdtm/static/tempfs_overmounted.desc |  2 +-
>     >  2 files changed, 23 insertions(+), 1 deletion(-)
>     >
>     > diff --git a/test/zdtm/static/tempfs_overmounted.c b/test/zdtm/static/
>     tempfs_overmounted.c
>     > index 56c3d2ed8..c9c1e2dae 100644
>     > --- a/test/zdtm/static/tempfs_overmounted.c
>     > +++ b/test/zdtm/static/tempfs_overmounted.c
>     > @@ -16,6 +16,9 @@ TEST_OPTION(dirname, string, "directory name", 1);
>     > 
>     >  int main(int argc, char **argv)
>     >  {
>     > + char testfile[PATH_MAX];
>     > + int fd;
>     > +
>     >  test_init(argc, argv);
>     > 
>     >  mkdir(dirname, 0700);
>     > @@ -23,6 +26,15 @@ int main(int argc, char **argv)
>     >  fail("Can't mount tmpfs");
>     >  return 1;
>     >  }
>     > +
>     > + snprintf(testfile, PATH_MAX, "%s/testfile", dirname);
>     > + fd = open(testfile, O_CREAT | O_EXCL, 0600);
>     > + if (fd < 0) {
>     > + fail("Can't create file");
>     > + return 1;
>     > + }
>     > + close(fd);
>     > +
>     >  if (mount("none", dirname, "tmpfs", 0, "") < 0) {
>     >  fail("Can't mount tmpfs");
>     >  return 1;
>     > @@ -31,6 +43,16 @@ int main(int argc, char **argv)
>     >  test_daemon();
>     >  test_waitsig();
>     > 
>     > + if (umount(dirname)) {
>     > + fail("Can't umount");
>     > + return 1;
>     > + }
>     > +
>     > + if (access(testfile, F_OK) < 0) {
>     > + fail("Can't access testfile");
>     > + return 1;
>     > + }
>     > +
>     >  pass();
>     >  return 0;
>     >  }
>     > diff --git a/test/zdtm/static/tempfs_overmounted.desc b/test/zdtm/static/
>     tempfs_overmounted.desc
>     > index 0d8b7f2b4..7657ba45c 100644
>     > --- a/test/zdtm/static/tempfs_overmounted.desc
>     > +++ b/test/zdtm/static/tempfs_overmounted.desc
>     > @@ -1 +1 @@
>     > -{'flavor': 'ns uns', 'flags': 'suid crfail'}
>     > +{'flavor': 'ns uns', 'flags': 'suid'}
>     > --
>     > 2.13.6
>     >
>

Patch hide | download patch | download mbox

diff --git a/test/zdtm/static/tempfs_overmounted.c b/test/zdtm/static/tempfs_overmounted.c
index 56c3d2ed8..29eca00f4 100644
--- a/test/zdtm/static/tempfs_overmounted.c
+++ b/test/zdtm/static/tempfs_overmounted.c
@@ -19,11 +19,38 @@  int main(int argc, char **argv)
 	test_init(argc, argv);
 
 	mkdir(dirname, 0700);
-	if (mount("none", dirname, "tmpfs", 0, "") < 0) {
+	if (chdir(dirname)) {
+		pr_perror("chdir");
+		return 1;
+	}
+
+	mkdir("a", 0777);
+	mkdir("a/b", 0777);
+
+	mount(NULL, "/", NULL, MS_PRIVATE, "");
+	if (mount("none", "a/b", "tmpfs", 0, "") < 0) {
+		fail("Can't mount tmpfs");
+		return 1;
+	}
+	if (mount("none", "a/b", "tmpfs", 0, "") < 0) {
+		fail("Can't mount tmpfs");
+		return 1;
+	}
+	mkdir("a/b/c", 0777);
+	if (mount("none", "a/b/c", "tmpfs", 0, "") < 0) {
 		fail("Can't mount tmpfs");
 		return 1;
 	}
-	if (mount("none", dirname, "tmpfs", 0, "") < 0) {
+	if (mount("none", "a", "tmpfs", 0, "") < 0) {
+		fail("Can't mount tmpfs");
+		return 1;
+	}
+	if (mount("none", "a", "tmpfs", 0, "") < 0) {
+		fail("Can't mount tmpfs");
+		return 1;
+	}
+	mkdir("a/b", 0777);
+	if (mount("none", "a/b", "tmpfs", 0, "") < 0) {
 		fail("Can't mount tmpfs");
 		return 1;
 	}
@@ -31,6 +58,11 @@  int main(int argc, char **argv)
 	test_daemon();
 	test_waitsig();
 
+	if (umount("a/b") || umount("a") || umount("a") || umount("a/b/c") || umount("a/b") || umount("a/b")) {
+		pr_err("umount");
+		return 1;
+	}
+
 	pass();
 	return 0;
 }

Comments

Pavel Tikhomirov Dec. 8, 2017, 8:24 a.m.
It does not work with your test. But problem is not with dumping mounts:

Mountinfo before dump:

445 486 0:58 / /zdtm/static/tempfs_overmounted.test/a rw,relatime - 
tmpfs none rw
446 445 0:59 / /zdtm/static/tempfs_overmounted.test/a rw,relatime - 
tmpfs none rw
447 446 0:60 / /zdtm/static/tempfs_overmounted.test/a/b rw,relatime - 
tmpfs none rw

 From dump.log:

(00.039801) mnt: Dumping mountpoints
(00.039804) mnt:        447: 3c:/ @ 
./zdtm/static/tempfs_overmounted.test/a/b
(00.049538) mnt:        446: 3b:/ @ ./zdtm/static/tempfs_overmounted.test/a
(00.049551) mnt: Mount is not fully visible 
./zdtm/static/tempfs_overmounted.test/a
(00.049589) mnt:        mount has children 
./zdtm/static/tempfs_overmounted.test/a
(00.065489) mnt:        445: 3a:/ @ ./zdtm/static/tempfs_overmounted.test/a
(00.065499) mnt: Mount is not fully visible 
./zdtm/static/tempfs_overmounted.test/a
(00.065530) mnt:        mount is overmounted 
./zdtm/static/tempfs_overmounted.test/a

tmpfs-dev-59.tar.gz.img and tmpfs-dev-58.tar.gz.img both are saved.

We even mount both 445 and 446, in restore.log:

(00.101594)      1: mnt:        Mounting tmpfs 
@/tmp/.criu.mntns.szk2Td/9-0000000001/zdtm/static/tempfs_overmounted.test/a 
(0)
(00.110129)      1: mnt: 
445:/tmp/.criu.mntns.szk2Td/9-0000000001/zdtm/static/tempfs_overmounted.test/a 
private 1 shared 0 slave 0
(00.110156)      1: mnt:        Mounting tmpfs 
@/tmp/.criu.mntns.szk2Td/9-0000000001/zdtm/static/tempfs_overmounted.test/a 
(0)
(00.118390)      1: mnt: 
446:/tmp/.criu.mntns.szk2Td/9-0000000001/zdtm/static/tempfs_overmounted.test/a 
private 1 shared 0 slave 0

But here is the problem:

(00.152632)      1: mnt: Move mount 
/tmp/.criu.mntns.szk2Td/9-0000000001/zdtm/static/tempfs_overmounted.test/a 
-> 
/tmp/.criu.mntns.szk2Td/9-0000000000/zdtm/static/tempfs_overmounted.test/a

We want to move overmounted mount and thus instead move it's 
children-overmount, that's why mount 445 is lost.

I think it is because remap code operates with does_mnt_overmount() 
which checks that mount is sibling-overmount only, and 
children-overmounts are not remapped.

Will check these idea.