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

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