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