Blame SOURCES/autofs-5.1.4-add-master-map-pseudo-options-for-mount-propagation.patch

9ddfc2
autofs-5.1.4 - add master map pseudo options for mount propagation
9ddfc2
9ddfc2
From: Ian Kent <raven@themaw.net>
9ddfc2
9ddfc2
Add master map entry pseudo mount option of "slave" or "private" to
9ddfc2
allow mount propagation of bind mounts to be set to either "slave" or
9ddfc2
"private".
9ddfc2
9ddfc2
This option may be needed when using multi-mounts that have bind mounts
9ddfc2
that bind to a file system that is propagation shared. This is becuase
9ddfc2
the bind mount will have the same properties as its target which causes
9ddfc2
problems for offset mounts. When this happens an unwanted offset mount
9ddfc2
is propagated back to the target file system resulting in a deadlock
9ddfc2
when attempting to access the offset.
9ddfc2
9ddfc2
By default bind mounts will inherit the mount propagation of the target
9ddfc2
file system.
9ddfc2
9ddfc2
Signed-off-by: Ian Kent <raven@themaw.net>
9ddfc2
---
9ddfc2
 CHANGELOG            |    1 +
9ddfc2
 include/automount.h  |    4 ++++
9ddfc2
 lib/master_parse.y   |   13 +++++++++++++
9ddfc2
 lib/master_tok.l     |    2 ++
9ddfc2
 man/auto.master.5.in |   12 ++++++++++++
9ddfc2
 modules/mount_bind.c |   30 +++++++++++++++++++-----------
9ddfc2
 6 files changed, 51 insertions(+), 11 deletions(-)
9ddfc2
9ddfc2
--- autofs-5.0.7.orig/CHANGELOG
9ddfc2
+++ autofs-5.0.7/CHANGELOG
9ddfc2
@@ -308,6 +308,7 @@
9ddfc2
 - dont probe NFSv2 by default.
9ddfc2
 - add version parameter to rpc_ping().
9ddfc2
 - set bind mount as propagation slave.
9ddfc2
+- add master map pseudo options for mount propagation.
9ddfc2
 
9ddfc2
 25/07/2012 autofs-5.0.7
9ddfc2
 =======================
9ddfc2
--- autofs-5.0.7.orig/include/automount.h
9ddfc2
+++ autofs-5.0.7/include/automount.h
9ddfc2
@@ -527,6 +527,10 @@ struct kernel_mod_version {
9ddfc2
 /* Read amd map even if it's not to be ghosted (browsable) */
9ddfc2
 #define MOUNT_FLAG_AMD_CACHE_ALL	0x0080
9ddfc2
 
9ddfc2
+/* Set mount propagation for bind mounts */
9ddfc2
+#define MOUNT_FLAG_SLAVE		0x0100
9ddfc2
+#define MOUNT_FLAG_PRIVATE		0x0200
9ddfc2
+
9ddfc2
 struct autofs_point {
9ddfc2
 	pthread_t thid;
9ddfc2
 	char *path;			/* Mount point name */
9ddfc2
--- autofs-5.0.7.orig/lib/master_parse.y
9ddfc2
+++ autofs-5.0.7/lib/master_parse.y
9ddfc2
@@ -58,6 +58,8 @@ static char *format;
9ddfc2
 static long timeout;
9ddfc2
 static long negative_timeout;
9ddfc2
 static unsigned symlnk;
9ddfc2
+static unsigned slave;
9ddfc2
+static unsigned private;
9ddfc2
 static unsigned nobind;
9ddfc2
 static unsigned ghost;
9ddfc2
 extern unsigned global_selection_options;
9ddfc2
@@ -102,6 +104,7 @@ static int master_fprintf(FILE *, char *
9ddfc2
 %token MAP
9ddfc2
 %token OPT_TIMEOUT OPT_NTIMEOUT OPT_NOBIND OPT_NOGHOST OPT_GHOST OPT_VERBOSE
9ddfc2
 %token OPT_DEBUG OPT_RANDOM OPT_USE_WEIGHT OPT_SYMLINK
9ddfc2
+%token OPT_SLAVE OPT_PRIVATE
9ddfc2
 %token COLON COMMA NL DDASH
9ddfc2
 %type <strtype> map
9ddfc2
 %type <strtype> options
9ddfc2
@@ -188,6 +191,8 @@ line:
9ddfc2
 	| PATH OPT_DEBUG { master_notify($1); YYABORT; }
9ddfc2
 	| PATH OPT_TIMEOUT { master_notify($1); YYABORT; }
9ddfc2
 	| PATH OPT_SYMLINK { master_notify($1); YYABORT; }
9ddfc2
+	| PATH OPT_SLAVE { master_notify($1); YYABORT; }
9ddfc2
+	| PATH OPT_PRIVATE { master_notify($1); YYABORT; }
9ddfc2
 	| PATH OPT_NOBIND { master_notify($1); YYABORT; }
9ddfc2
 	| PATH OPT_GHOST { master_notify($1); YYABORT; }
9ddfc2
 	| PATH OPT_NOGHOST { master_notify($1); YYABORT; }
9ddfc2
@@ -569,6 +574,8 @@ option: daemon_option
9ddfc2
 daemon_option: OPT_TIMEOUT NUMBER { timeout = $2; }
9ddfc2
 	| OPT_NTIMEOUT NUMBER { negative_timeout = $2; }
9ddfc2
 	| OPT_SYMLINK	{ symlnk = 1; }
9ddfc2
+	| OPT_SLAVE	{ slave = 1; }
9ddfc2
+	| OPT_PRIVATE	{ private = 1; }
9ddfc2
 	| OPT_NOBIND	{ nobind = 1; }
9ddfc2
 	| OPT_NOGHOST	{ ghost = 0; }
9ddfc2
 	| OPT_GHOST	{ ghost = 1; }
9ddfc2
@@ -640,6 +647,8 @@ static void local_init_vars(void)
9ddfc2
 	timeout = -1;
9ddfc2
 	negative_timeout = 0;
9ddfc2
 	symlnk = 0;
9ddfc2
+	slave = 0;
9ddfc2
+	private = 0;
9ddfc2
 	nobind = 0;
9ddfc2
 	ghost = defaults_get_browse_mode();
9ddfc2
 	random_selection = global_selection_options & MOUNT_FLAG_RANDOM_SELECT;
9ddfc2
@@ -845,6 +854,10 @@ int master_parse_entry(const char *buffe
9ddfc2
 		entry->ap->flags |= MOUNT_FLAG_USE_WEIGHT_ONLY;
9ddfc2
 	if (symlnk)
9ddfc2
 		entry->ap->flags |= MOUNT_FLAG_SYMLINK;
9ddfc2
+	if (slave)
9ddfc2
+		entry->ap->flags |= MOUNT_FLAG_SLAVE;
9ddfc2
+	if (private)
9ddfc2
+		entry->ap->flags |= MOUNT_FLAG_PRIVATE;
9ddfc2
 	if (negative_timeout)
9ddfc2
 		entry->ap->negative_timeout = negative_timeout;
9ddfc2
 
9ddfc2
--- autofs-5.0.7.orig/lib/master_tok.l
9ddfc2
+++ autofs-5.0.7/lib/master_tok.l
9ddfc2
@@ -386,6 +386,8 @@ OPTNTOUT	(-n{OPTWS}|-n{OPTWS}={OPTWS}|--
9ddfc2
 	-?symlink		{ return(OPT_SYMLINK); }
9ddfc2
 	-?nobind		{ return(OPT_NOBIND); }
9ddfc2
 	-?nobrowse		{ return(OPT_NOGHOST); }
9ddfc2
+	-?slave			{ return(OPT_SLAVE); }
9ddfc2
+	-?private		{ return(OPT_PRIVATE); }
9ddfc2
 	-g|--ghost|-?browse	{ return(OPT_GHOST); }
9ddfc2
 	-v|--verbose		{ return(OPT_VERBOSE); }
9ddfc2
 	-d|--debug		{ return(OPT_DEBUG); }
9ddfc2
--- autofs-5.0.7.orig/man/auto.master.5.in
9ddfc2
+++ autofs-5.0.7/man/auto.master.5.in
9ddfc2
@@ -198,6 +198,18 @@ entries only, either in the master map (
9ddfc2
 or with individual map entries. The option is ignored for direct mounts
9ddfc2
 and non-root offest mount entries.
9ddfc2
 .TP
9ddfc2
+.I slave \fPor\fI private
9ddfc2
+This option allows mount propagation of bind mounts to be set to
9ddfc2
+either \fIslave\fP or \fIprivate\fP. This option may be needed when using
9ddfc2
+multi-mounts that have bind mounts that bind to a file system that is
9ddfc2
+propagation shared. This is becuase the bind mount will have the same
9ddfc2
+properties as its target which causes problems for offset mounts. When
9ddfc2
+this happens an unwanted offset mount is propagated back to the target
9ddfc2
+file system resulting in a deadlock when attempting to access the offset.
9ddfc2
+This option is a an autofs pseudo mount option that can be used in the
9ddfc2
+master map only. By default bind mounts will inherit the mount propagation
9ddfc2
+of the target file system.
9ddfc2
+.TP
9ddfc2
 .I "\-r, \-\-random-multimount-selection"
9ddfc2
 Enables the use of ramdom selection when choosing a host from a
9ddfc2
 list of replicated servers. This option is applied to this mount
9ddfc2
--- autofs-5.0.7.orig/modules/mount_bind.c
9ddfc2
+++ autofs-5.0.7/modules/mount_bind.c
9ddfc2
@@ -187,17 +187,25 @@ int mount_mount(struct autofs_point *ap,
9ddfc2
 			      what, fstype, fullpath);
9ddfc2
 		}
9ddfc2
 
9ddfc2
-		/* The bind mount has succeeded but if the target
9ddfc2
-		 * mount is propagation shared propagation of child
9ddfc2
-		 * mounts (autofs offset mounts for example) back to
9ddfc2
-		 * the target of the bind mount must be avoided or
9ddfc2
-		 * autofs trigger mounts will deadlock.
9ddfc2
-		 */
9ddfc2
-		err = mount(NULL, fullpath, NULL, MS_SLAVE, NULL);
9ddfc2
-		if (err)
9ddfc2
-			warn(ap->logopt,
9ddfc2
-			     "failed to set propagation type for %s",
9ddfc2
-			     fullpath);
9ddfc2
+		if (ap->flags & (MOUNT_FLAG_SLAVE | MOUNT_FLAG_PRIVATE)) {
9ddfc2
+			int flags = MS_SLAVE;
9ddfc2
+
9ddfc2
+			if (ap->flags & MOUNT_FLAG_PRIVATE)
9ddfc2
+				flags = MS_PRIVATE;
9ddfc2
+
9ddfc2
+			/* The bind mount has succeeded but if the target
9ddfc2
+			 * mount is propagation shared propagation of child
9ddfc2
+			 * mounts (autofs offset mounts for example) back to
9ddfc2
+			 * the target of the bind mount must be avoided or
9ddfc2
+			 * autofs trigger mounts will deadlock.
9ddfc2
+			 */
9ddfc2
+			err = mount(NULL, fullpath, NULL, flags, NULL);
9ddfc2
+			if (err) {
9ddfc2
+				warn(ap->logopt,
9ddfc2
+				     "failed to set propagation for %s",
9ddfc2
+				     fullpath, root);
9ddfc2
+			}
9ddfc2
+		}
9ddfc2
 
9ddfc2
 		return 0;
9ddfc2
 	} else {