Blame SOURCES/autofs-5.1.4-set-bind-mount-as-propagation-slave.patch

304803
autofs-5.1.4 - set bind mount as propagation slave
304803
304803
From: Ian Kent <raven@themaw.net>
304803
304803
When using a multi-mount with mount targets that are on the
304803
local machine and resulting bind mounts are made to a file
304803
system that is mount propagation shared (such as the root
304803
file system on systemd managed systems) the autofs offset
304803
mount triggers made within the bind mount will be propagated
304803
back to the target file system.
304803
304803
When this happens the target of the offset (the unwanted
304803
propagated mount) is itself an autofs trigger mount and
304803
accessing the path results in a deadlock.
304803
304803
In order for these multi-mounts to function properly in this
304803
case bind mounts that contain mount triggers must be set to
304803
propagation shared or private so the backward propagation
304803
doesn't occur.
304803
304803
Signed-off-by: Ian Kent <raven@themaw.net>
304803
---
304803
 CHANGELOG            |    1 +
304803
 modules/mount_bind.c |   16 +++++++++++++++-
304803
 2 files changed, 16 insertions(+), 1 deletion(-)
304803
304803
--- autofs-5.0.7.orig/CHANGELOG
304803
+++ autofs-5.0.7/CHANGELOG
304803
@@ -307,6 +307,7 @@
304803
 - add port parameter to rpc_ping().
304803
 - dont probe NFSv2 by default.
304803
 - add version parameter to rpc_ping().
304803
+- set bind mount as propagation slave.
304803
 
304803
 25/07/2012 autofs-5.0.7
304803
 =======================
304803
--- autofs-5.0.7.orig/modules/mount_bind.c
304803
+++ autofs-5.0.7/modules/mount_bind.c
304803
@@ -20,6 +20,7 @@
304803
 #include <sys/param.h>
304803
 #include <sys/types.h>
304803
 #include <sys/stat.h>
304803
+#include <sys/mount.h>
304803
 
304803
 #define MODULE_MOUNT
304803
 #include "automount.h"
304803
@@ -184,8 +185,21 @@ int mount_mount(struct autofs_point *ap,
304803
 			debug(ap->logopt,
304803
 			      MODPREFIX "mounted %s type %s on %s",
304803
 			      what, fstype, fullpath);
304803
-			return 0;
304803
 		}
304803
+
304803
+		/* The bind mount has succeeded but if the target
304803
+		 * mount is propagation shared propagation of child
304803
+		 * mounts (autofs offset mounts for example) back to
304803
+		 * the target of the bind mount must be avoided or
304803
+		 * autofs trigger mounts will deadlock.
304803
+		 */
304803
+		err = mount(NULL, fullpath, NULL, MS_SLAVE, NULL);
304803
+		if (err)
304803
+			warn(ap->logopt,
304803
+			     "failed to set propagation type for %s",
304803
+			     fullpath);
304803
+
304803
+		return 0;
304803
 	} else {
304803
 		char *cp;
304803
 		char basepath[PATH_MAX];