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

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