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

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