After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 743891 - prepare-root: avoid double-stacked /sysroot mount
prepare-root: avoid double-stacked /sysroot mount
Status: RESOLVED FIXED
Product: ostree
Classification: Infrastructure
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: OSTree maintainer(s)
OSTree maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2015-02-02 21:20 UTC by Daniel Drake
Modified: 2015-03-04 21:02 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch (4.25 KB, patch)
2015-02-02 21:20 UTC, Daniel Drake
accepted-commit_now Details | Review
prepare-root: Unmount old /sysroot mount point (1.80 KB, patch)
2015-02-03 19:17 UTC, Colin Walters
none Details | Review
0001-prepare-root-Move-sysroot-instead-of-unmounting-it.patch (1.90 KB, patch)
2015-02-13 04:14 UTC, Colin Walters
none Details | Review

Description Daniel Drake 2015-02-02 21:20:53 UTC
Created attachment 295980 [details] [review]
patch

prepare-root works with the mount that has been set up at /sysroot.
It creates a bind-mount within /sysroot (the deployment) and then moves
that mount to /sysroot.

Now we have 2 mounts both at /sysroot, and once we do switch_root, we will
never be able to unmount both of them. I'm not sure if this is ultimately
a kernel bug, but either way, ostree could do a bit more tidying up
after itself.
http://thread.gmane.org/gmane.linux.file-systems/92411

Easy way to reproduce:
1. Boot with rd.break param
2. At initramfs shell, run: ostree-prepare-root /sysroot
3. Observe two /sysroot mounts in /proc/mounts

Fix this by setting up the mounts at /sysroot.tmp, and unmounting the
original /sysroot before our new mount is MS_MOVEd on top of it.
Comment 1 Colin Walters 2015-02-03 19:16:55 UTC
Hmm...but this will cause us to hold a reference to a directory on the initramfs, right?  Which isn't the end of the world, but not doing so helps shave real memory.

Can we instead do something like this?
Comment 2 Colin Walters 2015-02-03 19:17:22 UTC
Created attachment 296051 [details] [review]
prepare-root: Unmount old /sysroot mount point

We were previously overmounting it, which meant it was hard to clean
up on shutdown.
Comment 3 Daniel Drake 2015-02-03 19:57:09 UTC
I don't quite follow, what does "hold a reference to a directory" mean and which directory is the one you are concerned about?
Comment 4 Colin Walters 2015-02-03 20:04:51 UTC
Ah, I just read your patch again and I see you're making sysroot.tmp on the "physical /", so indeed it wouldn't hold a reference to the initramfs.  But then the issues I see are:

 - Leaves a tempdir around
 - Breaks booting from readonly media (See https://git.gnome.org/browse/ostree/commit/?id=ff6883ca0655ac8844cd783caf6a7d8815515ba3 )

What do you think about my patch?  (I didn't test it yet)
Comment 5 Daniel Drake 2015-02-03 20:43:59 UTC
umount2() is the function you want there, but it doesn't quite work - both /sysroot mounts get unmounted.
Comment 6 Daniel Drake 2015-02-03 21:16:14 UTC
Can you clarify your concerns about the readonly media issue?

I tested as follows:

- boot into initramfs with rd.break
- mount -o remount,ro /sysroot
- ostree-prepare-root /sysroot # my version
- switch_root /sysroot /bin/bash

Then I ran a trivial C app that does statvfs on /var and it showed the readonly flag, as is the case with the unmodified ostree-prepare-root.
Comment 7 Colin Walters 2015-02-03 23:10:57 UTC
I made this to play around, still debugging a few things:

https://gist.github.com/cgwalters/f5869dddaa2236f13671
Comment 8 Colin Walters 2015-02-03 23:17:12 UTC
Ah, right, you're making it in the initramfs, then we move the mount.  That makes sense.  I'll test.
Comment 9 Colin Walters 2015-02-04 10:41:09 UTC
Review of attachment 295980 [details] [review]:

Works for me.  I also pushed a followup commit which added a few more comments.  Thanks for the patch and pushing back on my overly hasty initial review =)
Comment 10 Colin Walters 2015-02-13 04:14:02 UTC
I tested this patch against a Fedora Atomic system, and it worked.  But it definitely broke gnome-continuous; the system root doesn't have /sysroot mounted.

What do you think about the following patch?  I am not sure offhand why it breaks Continuous but not Fedora.
Comment 11 Colin Walters 2015-02-13 04:14:30 UTC
Created attachment 296735 [details] [review]
0001-prepare-root-Move-sysroot-instead-of-unmounting-it.patch
Comment 12 Daniel Drake 2015-02-13 12:33:02 UTC
Looks reasonable, although I'm a bit uneasy not understanding what went wrong.
Comment 13 Colin Walters 2015-02-13 21:03:09 UTC
This turned out to be an issue with systemd git master, I see:

systemd[1]: Unit sysroot.mount is bound to inactive service. Stopping, too.

I think we may just need a RemainAfterExit= in ostree-remount.service.  Testing...
Comment 14 Colin Walters 2015-03-04 21:02:09 UTC
This was all pushed.  The bug is being addressed in systemd.