On Tue, Mar 12, 2013 at 09:19:06PM -0700, Steve Langasek wrote:
> The use of a symlink for /etc/mtab in wheezy means that 'mount -f' no longer
> works.  As a consequence, extra mount options that libmount *should* record
> in /run/mount/utab are not recorded for any filesystem that is mounted
> before the rootfs is marked rw, including but not limited to _netdev.  This
> potentially leaves the system with no way to cleanly unmount some
> network-dependent filesystems at shutdown time.
[...]
> This is a significant regression in handling of network-based block devices,
> such as iscsi and nbd, compared with squeeze.  I think it's important that
> this be resolved before release.

Hi Steve,

I'm afraid I'm away and without internet access until next weekend.
I've attached what I've done so far to work around this in
initscripts.

While bugs in mount/libmount/findmnt are certainly the cause of the
lack of _netdev, I'm doubtful that these are addressable in time for
wheezy.  And we would have to adapt the initscripts to use mount or
findmnt in order to merge in the utab content rather than looking
at mtab directly (which is easy--I've already done it locally, but
it needs the changes in util-linux from newer upstream releases, and
possibly additional work).  Certainly do-able for jessie.

In initscripts, we make the choice of a dynamic or static mtab in the
mtab_migrate function called from checkroot.sh.  This is only ever
run on read-write root, since it's not possible to change things if
it's read-only (here, the admin is responsible).  As discussed on IRC,
we can't realistically change this at upgrade time due to loss of
information such as nfs/cifs extended mount options.

At boot time, we currently migrate mtab to a symlink where possible.
Other alternatives are
- migrating back to a static file (not recommended; this would
  reintroduce more problems than it solves)
- making the choice of symlink or static file based upon particular
  criteria

The attached patch does the latter.  It looks to see if _netdev is in
use, and if so will refuse to migrate to a symlink.  Though it will
do nothing if a symlink already exists, so it won't revert back to
a static file (this could be added easily; I'm just attaching what I've
done so far prior to going away for the week in case you want to push
a fix for this before I get back).

This isn't an ideal solution, and I certainly wouldn't want to keep it
for jessie, but it will cover the majority of the _netdev usecases
fairly simply as an immediate workaround for wheezy.  I'm not sure of
the scope of this problem, but given that it took around 15-16 months
before this came up as an issue, I don't think it's particularly large,
especially when considering the scope of the bugs affecting static
mtab files, which was vastly larger and could cause worse problems.


Regards,
Roger

-- 
  .''`.  Roger Leigh
 : :' :  Debian GNU/Linux    http://people.debian.org/~rleigh/
 `. `'   schroot and sbuild  http://alioth.debian.org/projects/buildd-tools
   `-    GPG Public Key      F33D 281D 470A B443 6756 147C 07B3 C8BC 4083 E800
diff --git a/debian/src/initscripts/lib/init/mount-functions.sh b/debian/src/initscripts/lib/init/mount-functions.sh
index 2ad4528..c5e0386 100644
@@ -414,6 +420,28 @@ run_migrate ()
 #
 # Migrate /etc/mtab to a compatibility symlink
 #
+_mtab_migrate ()
+{
+	echo netdev=false
+	fstab_files | while read file; do
+                if [ -f "$file" ]; then
+                        while read MNT_FSNAME MNT_DIR MNT_TYPE MNT_OPTS MNT_FREQ MNT_PASS MNT_JUNK; do
+				case "$MNT_FSNAME" in
+				  ""|\#*)
+					continue;
+					;;
+                                esac
+				case "$MNT_OPTS" in
+				  _netdev|_netdev,*|*,_netdev|*,_netdev,*)
+                                        echo netdev=true
+                                        break
+					;;
+                                esac
+			done < "$file"
+		fi
+	done
+}
+
 mtab_migrate ()
 {
 	# Don't symlink if /proc/mounts does not exist.
@@ -421,6 +449,11 @@ mtab_migrate ()
 		return 1
 	fi
 
+	eval "$(_mtab_migrate)"
+	if [ "$netdev" = "true" ]; then
+		return 1
+	fi
+
 	# Create symlink if not already present.
 	if [ -L "/etc/mtab" ] && [ "$(readlink "/etc/mtab")" = "/proc/mounts" ]; then
 		:

Reply via email to