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