Blame SOURCES/autofs-5.0.9-amd-lookup-fix-prefix-not-set-on-mount-reconnect.patch

4d476f
autofs-5.0.9 - fix prefix not set on mount reconnect
4d476f
4d476f
From: Ian Kent <raven@themaw.net>
4d476f
4d476f
When autofs is started and there are pre-existing mounts the daemon
4d476f
will attempt to reconnect to these mounts to reconstuct the mount
4d476f
tree.
4d476f
4d476f
This process is recursive so subordinate mounts can be reconstructed
4d476f
before parent mounts complete reconnection.
4d476f
4d476f
Also, amd subordinate mounts of type "auto" parent mounts may need
4d476f
to use the parent mount prefix which was set post mount and wasn't
4d476f
available. So, setting the parent mount prefix has to be done near
4d476f
the beginning of parent mount operation.
4d476f
---
4d476f
 modules/mount_autofs.c |    8 ++++++++
4d476f
 modules/parse_amd.c    |   30 +++++++++++++-----------------
4d476f
 2 files changed, 21 insertions(+), 17 deletions(-)
4d476f
4d476f
diff --git a/modules/mount_autofs.c b/modules/mount_autofs.c
4d476f
index ab5a8e3..c7cba3a 100644
4d476f
--- a/modules/mount_autofs.c
4d476f
+++ b/modules/mount_autofs.c
4d476f
@@ -255,6 +255,14 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name,
4d476f
 
4d476f
 	mounts_mutex_lock(ap);
4d476f
 
4d476f
+	if (source->flags & MAP_FLAG_FORMAT_AMD) {
4d476f
+		struct amd_entry *am_entry = __master_find_amdmount(ap, entry->path);
4d476f
+		if (am_entry && am_entry->pref) {
4d476f
+			nap->pref = am_entry->pref;
4d476f
+			am_entry->pref = NULL;
4d476f
+		}
4d476f
+	}
4d476f
+
4d476f
 	if (handle_mounts_startup_cond_init(&suc)) {
4d476f
 		crit(ap->logopt, MODPREFIX
4d476f
 		     "failed to init startup cond for mount %s", entry->path);
4d476f
diff --git a/modules/parse_amd.c b/modules/parse_amd.c
4d476f
index bc056a7..410f6ff 100644
4d476f
--- a/modules/parse_amd.c
4d476f
+++ b/modules/parse_amd.c
4d476f
@@ -893,7 +893,6 @@ static int do_auto_mount(struct autofs_point *ap, const char *name,
4d476f
 			 struct amd_entry *entry, unsigned int flags)
4d476f
 {
4d476f
 	char target[PATH_MAX + 1];
4d476f
-	int ret;
4d476f
 
4d476f
 	if (!entry->map_type)
4d476f
 		strcpy(target, entry->fs);
4d476f
@@ -903,18 +902,8 @@ static int do_auto_mount(struct autofs_point *ap, const char *name,
4d476f
 		strcat(target, entry->fs);
4d476f
 	}
4d476f
 
4d476f
-	ret = do_mount(ap, ap->path,
4d476f
-		       name, strlen(name), target, "autofs", NULL);
4d476f
-	if (!ret) {
4d476f
-		struct autofs_point *sm;
4d476f
-		sm = master_find_submount(ap, entry->path);
4d476f
-		if (sm) {
4d476f
-			sm->pref = entry->pref;
4d476f
-			entry->pref = NULL;
4d476f
-		}
4d476f
-	}
4d476f
-
4d476f
-	return ret;
4d476f
+	return do_mount(ap, ap->path,
4d476f
+			name, strlen(name), target, "autofs", NULL);
4d476f
 }
4d476f
 
4d476f
 static int do_link_mount(struct autofs_point *ap, const char *name,
4d476f
@@ -1878,17 +1867,24 @@ int parse_mount(struct autofs_point *ap, const char *name,
4d476f
 
4d476f
 		dequote_entry(ap, this);
4d476f
 
4d476f
+		/*
4d476f
+		 * Type "auto" needs to set the prefix at mount time so
4d476f
+		 * add parsed entry to parent amd mount list and remove
4d476f
+		 * on mount fail.
4d476f
+		 */
4d476f
+		mounts_mutex_lock(ap);
4d476f
+		list_add_tail(&this->entries, &ap->amdmounts);
4d476f
+		mounts_mutex_unlock(ap);
4d476f
+
4d476f
 		rv = amd_mount(ap, name, this, source, sv, flags, ctxt);
4d476f
 		mounts_mutex_lock(ap);
4d476f
 		if (!rv) {
4d476f
-			/* Add to the parent list of mounts */
4d476f
-			list_add_tail(&this->entries, &ap->amdmounts);
4d476f
-			/* Mounted, leave it on the parent list */
4d476f
+			/* Mounted, remove entry from parsed list */
4d476f
 			list_del_init(&this->list);
4d476f
 			mounts_mutex_unlock(ap);
4d476f
 			break;
4d476f
 		}
4d476f
-		/* Not mounted, remove it from the parent list */
4d476f
+		/* Not mounted, remove entry from the parent list */
4d476f
 		list_del_init(&this->entries);
4d476f
 		mounts_mutex_unlock(ap);
4d476f
 	}