Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 562668 - sys-apps/openrc-0.18: /etc/init.d/netmount unmounts local (non-network) filesystems
Summary: sys-apps/openrc-0.18: /etc/init.d/netmount unmounts local (non-network) files...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Hosted Projects
Classification: Unclassified
Component: OpenRC (show other bugs)
Hardware: All Linux
: Highest critical (vote)
Assignee: OpenRC Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-10-09 16:19 UTC by jorgicio
Modified: 2015-10-13 13:42 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
My emerge --info (emerge-info.txt,8.26 KB, text/plain)
2015-10-09 16:19 UTC, jorgicio
Details
The patch (openrc-0.18-netmount.patch,326 bytes, patch)
2015-10-13 13:26 UTC, jorgicio
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description jorgicio 2015-10-09 16:19:28 UTC
Created attachment 414212 [details]
My emerge --info

Hi!

Yesterday I upgraded OpenRC to version 0.18. However, when I disconnect from internet (e.g. when I suspend or restart the NetworkManager daemon), X crashes, and even I had a kernel panic once.

This did not happen in 0.17 or earlier versions.

Here I attach my emerge --info.

Thanks!
Comment 1 Matthias Maier gentoo-dev 2015-10-13 02:02:35 UTC
I believe that your X server crashing and the kernel panic is merely a symptom.

I have observed that /etc/init.d/netmount incorrectly attempts to unmount a local (non network) zfs filesystem if /etc/init.d/net.eth0 (or similar) is restarted.

Do you happen to have a zfs filesystem on root? If no, can you please nopaste your /etc/fstab and check whether restarting the network tries to unmount local filesystems via netmount? (Do this by changing to the framebuffer so that you have a chance to see something).
Comment 2 jorgicio 2015-10-13 02:21:00 UTC
(In reply to Matthias Maier from comment #1)
> I believe that your X server crashing and the kernel panic is merely a
> symptom.
> 
> I have observed that /etc/init.d/netmount incorrectly attempts to unmount a
> local (non network) zfs filesystem if /etc/init.d/net.eth0 (or similar) is
> restarted.
> 
> Do you happen to have a zfs filesystem on root? If no, can you please
> nopaste your /etc/fstab and check whether restarting the network tries to
> unmount local filesystems via netmount? (Do this by changing to the
> framebuffer so that you have a chance to see something).

Well... that's weird because I don't have any zfs filesystem on my installation.

If it helps, there's my fstab.

http://nopaste.linux-dev.org/?782248
Comment 3 Matthias Maier gentoo-dev 2015-10-13 02:38:07 UTC
For the record, it is a btrfs:

> http://nopaste.linux-dev.org/?782248

/dev/sda7		/		btrfs		noatime,defaults		0 1
Comment 4 jorgicio 2015-10-13 02:49:50 UTC
Yes, it is, so what's the matter with that? May it fails if so?
Comment 5 Matthias Maier gentoo-dev 2015-10-13 03:08:01 UTC
(In reply to jorgicio from comment #4)
> Yes, it is, so what's the matter with that?

It is something else than ext4. And the nopaste might not be preserved over a long time.



All, it seems that /etc/init.d/netmount in openrc-0.18 goes on rampage when trying to unmounting network filessystems:

 * Unmounting network filesystems ...
 *   Unmounting /usr ...
 *   Unmounting /srv ...
 *   Unmounting /home ...
 *   Unmounting /sys/fs/cgroup/net_prio ...
 *   Unmounting /sys/fs/cgroup/perf_event ...
 *   Unmounting /sys/fs/cgroup/net_cls ...
 *   Unmounting /sys/fs/cgroup/freezer ...
 *   Unmounting /sys/fs/cgroup/devices ...
 *   Unmounting /sys/fs/cgroup/blkio ...
 *   Unmounting /sys/fs/cgroup/cpuacct ...
 *   Unmounting /sys/fs/cgroup/cpu ...
 *   Unmounting /sys/fs/cgroup/cpuset ...
 *   Unmounting /sys/fs/cgroup/openrc ...
 *   Unmounting /sys/fs/fuse/connections ...
 *   Unmounting /sys/fs/cgroup ...
 *   Unmounting /sys/kernel/debug ...
 *   Unmounting /sys/kernel/security ...
 *   Unmounting /dev/shm ...
 *   Unmounting /dev/mqueue ...
 *   Unmounting /run ...
 *   Unmounting / ...
 *   Unmounting /sys ...
 *   Unmounting /dev/pts ...
 *   Unmounting /dev ...
 *   Unmounting /proc ...



Above particular instance is triggered by the following /etc/fstab

#kvm gentoo1 ~ # cat /etc/fstab 
UUID=76dc534c-3826-4f72-be58-53d6970d7d6a /boot ext2  defaults 0 0

And a zfs file system mounted as root and otherwise default configuration but I believe this happens with just about every file system!




Further, line 56 of /etc/init.d/netmount seems fishy:

  do_unmount umount ${fs:+--fstype-regex} $fs --netdev

I assume this must read:
  
  do_unmount "umount ${fs:+--fstype-regex} $fs --netdev"

Without the quotes, netmount just unmounts everything without any contraints...

Is this related to an attempted bug fix of bug #427996 ?
Comment 6 Matthias Maier gentoo-dev 2015-10-13 03:14:49 UTC
To be precise:

With stock openrc-0.18:

 *   Unmounting /usr ...
umount /usr


With quotes: do_unmount "umount ${fs:+--fstype-regex} $fs --netdev"

 *   Remounting /usr read only ...
umount --fstype-regex ^(afs|ceph|cifs|coda|davfs|fuse|fuse.sshfs|gfs|glusterfs|lustre|ncpfs|nfs|nfs4|ocfs2|shfs|smbfs)$ --netdev /usr
Comment 7 jorgicio 2015-10-13 03:47:42 UTC
Tried by myself with and without quotes.
With quotes: fails both in 0.17 and 0.18.
Without quotes: fails in 0.18 only. 0.17 works fine.
Comment 8 Matthias Maier gentoo-dev 2015-10-13 05:11:00 UTC
Bisected to:

#kvm gentoo1 openrc-9999 # git bisect good
5f4f2420364098835522da868a9e75205c9e4f9c is the first bad commit
commit 5f4f2420364098835522da868a9e75205c9e4f9c
Author: William Hubbs <w.d.hubbs@gmail.com>
Date:   Mon Oct 5 10:18:00 2015 -0500

    mountinfo: fix --netdev and --nonetdev on Linux
    
    On Linux, the --netdev and --nonetdev switches were not working. They
    were both returning false. After this change, they operate based on the
    presence or abscence of the _netdev option in mount options.

:040000 040000 7a3c1e9838b726e84c6511eb39198e73010866d7 9fc623d79819f82d646521eaa66c57d1ee4212ac M      src
Comment 9 Mik 2015-10-13 06:04:56 UTC
Given a basically empty /etc/fstab, getmntfile() will return NULL every time. That means netdev isn't initialized, which could cause problems. 

It also means that you could get some really random behavior -- any time getmntfile() returns null, netdev will retain the last filesystem's setting.

I am not comfortable enough testing this on my host OS, but I think simply putting line 308 back in has a good chance of fixing this?
Comment 10 Matthias Maier gentoo-dev 2015-10-13 06:21:57 UTC
(In reply to Mik from comment #9)

> I am not comfortable enough testing this on my host OS, but I think simply
> putting line 308 back in has a good chance of fixing this?

Correct, the following patch resolves the issue:

diff --git a/src/rc/mountinfo.c b/src/rc/mountinfo.c
index 53f2890..3f1dfb6 100644
--- a/src/rc/mountinfo.c
+++ b/src/rc/mountinfo.c
@@ -305,6 +305,7 @@ find_mounts(struct args *args)
 
        buffer = xmalloc(sizeof(char) * PATH_MAX * 3);
        while (fgets(buffer, PATH_MAX * 3, fp)) {
+               netdev = -1;
                p = buffer;
                from = strsep(&p, " ");
                to = strsep(&p, " ");
Comment 11 jorgicio 2015-10-13 13:26:26 UTC
Created attachment 414496 [details, diff]
The patch

Yes, indeed, the patch fixes the issue. Just tried, rebooted, disconnected internet, and working. No hanging.

As the ebuild has the epatch_user, you can put the patch in /etc/portage/patches/sys-apps/openrc.
Comment 12 William Hubbs gentoo-dev 2015-10-13 13:42:17 UTC
This is fixed in commit b81317b which will be back-ported to
openrc-0.18.1.