Blame SOURCES/autofs-5.1.6-use-mnt_list-for-amdmounts.patch

beb904
autofs-5.1.6 - use mnt_list for amdmounts
beb904
beb904
From: Ian Kent <raven@themaw.net>
beb904
beb904
Use struct mnt_list objects for the list of amd mounts instead of
beb904
struct amd_entry.
beb904
beb904
Signed-off-by: Ian Kent <raven@themaw.net>
beb904
---
beb904
 CHANGELOG              |    1 
beb904
 daemon/automount.c     |   48 ++++++++++------------
beb904
 daemon/lookup.c        |   18 +++++---
beb904
 include/automount.h    |    2 
beb904
 include/master.h       |    2 
beb904
 include/mounts.h       |   12 +++++
beb904
 include/parse_amd.h    |    1 
beb904
 lib/master.c           |   36 +----------------
beb904
 lib/mounts.c           |  103 ++++++++++++++++++++++++++++++++++++++++++++++++-
beb904
 modules/mount_autofs.c |   15 ++++---
beb904
 modules/parse_amd.c    |   43 +++++++++++++++-----
beb904
 11 files changed, 193 insertions(+), 88 deletions(-)
beb904
beb904
--- autofs-5.1.4.orig/CHANGELOG
beb904
+++ autofs-5.1.4/CHANGELOG
beb904
@@ -123,6 +123,7 @@ xx/xx/2018 autofs-5.1.5
beb904
 - make external mounts use simpler hashtable.
beb904
 - add a hash index to mnt_list.
beb904
 - use mnt_list for submounts.
beb904
+- use mnt_list for amdmounts.
beb904
 
beb904
 19/12/2017 autofs-5.1.4
beb904
 - fix spec file url.
beb904
--- autofs-5.1.4.orig/daemon/automount.c
beb904
+++ autofs-5.1.4/daemon/automount.c
beb904
@@ -595,7 +595,8 @@ static int umount_subtree_mounts(struct
beb904
 	 * it already to ensure it's ok to remove any offset triggers.
beb904
 	 */
beb904
 	if (!is_mm_root && is_mounted(path, MNTS_REAL)) {
beb904
-		struct amd_entry *entry;
beb904
+		struct mnt_list *mnt;
beb904
+
beb904
 		debug(ap->logopt, "unmounting dir = %s", path);
beb904
 		if (umount_ent(ap, path) &&
beb904
 		    is_mounted(path, MNTS_REAL)) {
beb904
@@ -605,16 +606,12 @@ static int umount_subtree_mounts(struct
beb904
 		}
beb904
 
beb904
 		/* Check for an external mount and umount if possible */
beb904
-		mounts_mutex_lock(ap);
beb904
-		entry = __master_find_amdmount(ap, path);
beb904
-		if (!entry) {
beb904
-			mounts_mutex_unlock(ap);
beb904
-			goto done;
beb904
+		mnt = mnts_find_amdmount(path);
beb904
+		if (mnt) {
beb904
+			umount_amd_ext_mount(ap, mnt->ext_mp);
beb904
+			mnts_remove_amdmount(path);
beb904
+			mnts_put_mount(mnt);
beb904
 		}
beb904
-		list_del(&entry->entries);
beb904
-		mounts_mutex_unlock(ap);
beb904
-		umount_amd_ext_mount(ap, entry->fs);
beb904
-		free_amd_entry(entry);
beb904
 	}
beb904
 done:
beb904
 	return left;
beb904
@@ -639,7 +636,8 @@ int umount_multi(struct autofs_point *ap
beb904
 
beb904
 	/* if this is a symlink we can handle it now */
beb904
 	if (S_ISLNK(st.st_mode)) {
beb904
-		struct amd_entry *entry;
beb904
+		struct mnt_list *mnt;
beb904
+
beb904
 		if (st.st_dev != ap->dev) {
beb904
 			crit(ap->logopt,
beb904
 			     "symlink %s has the wrong device, "
beb904
@@ -671,17 +669,15 @@ int umount_multi(struct autofs_point *ap
beb904
 				     "mkdir_path %s failed: %s", path, estr);
beb904
 			}
beb904
 		}
beb904
+
beb904
 		/* Check for an external mount and attempt umount if needed */
beb904
-		mounts_mutex_lock(ap);
beb904
-		entry = __master_find_amdmount(ap, path);
beb904
-		if (!entry) {
beb904
-			mounts_mutex_unlock(ap);
beb904
-			return 0;
beb904
-		}
beb904
-		list_del(&entry->entries);
beb904
-		mounts_mutex_unlock(ap);
beb904
-		umount_amd_ext_mount(ap, entry->fs);
beb904
-		free_amd_entry(entry);
beb904
+		mnt = mnts_find_amdmount(path);
beb904
+		if (mnt) {
beb904
+			umount_amd_ext_mount(ap, mnt->ext_mp);
beb904
+			mnts_remove_amdmount(path);
beb904
+			mnts_put_mount(mnt);
beb904
+		}
beb904
+
beb904
 		return 0;
beb904
 	}
beb904
 
beb904
@@ -1720,17 +1716,17 @@ static void handle_mounts_cleanup(void *
beb904
 		clean = 1;
beb904
 
beb904
 	if (submount) {
beb904
-		struct amd_entry *am;
beb904
+		struct mnt_list *mnt;
beb904
 
beb904
 		/* We are finishing up */
beb904
 		ap->parent->submnt_count--;
beb904
 
beb904
 		/* Submount at ap->path belongs to parent submount list. */
beb904
 		mnts_remove_submount(ap->path);
beb904
-		am = __master_find_amdmount(ap->parent, ap->path);
beb904
-		if (am) {
beb904
-			list_del_init(&am->entries);
beb904
-			free_amd_entry(am);
beb904
+		mnt = mnts_find_amdmount(ap->path);
beb904
+		if (mnt) {
beb904
+			mnts_remove_amdmount(ap->path);
beb904
+			mnts_put_mount(mnt);
beb904
 		}
beb904
 	}
beb904
 
beb904
--- autofs-5.1.4.orig/daemon/lookup.c
beb904
+++ autofs-5.1.4/daemon/lookup.c
beb904
@@ -838,7 +838,7 @@ static int lookup_amd_instance(struct au
beb904
 			       const char *name, int name_len)
beb904
 {
beb904
 	struct map_source *instance;
beb904
-	struct amd_entry *entry;
beb904
+	struct mnt_list *mnt;
beb904
 	const char *argv[2];
beb904
 	const char **pargv = NULL;
beb904
 	int argc = 0;
beb904
@@ -861,21 +861,23 @@ static int lookup_amd_instance(struct au
beb904
 	strcpy(m_key, ap->path);
beb904
 	strcat(m_key, "/");
beb904
 	strcat(m_key, me->multi->key);
beb904
-	entry = master_find_amdmount(ap, m_key);
beb904
+
beb904
+	mnt = mnts_find_amdmount(m_key);
beb904
 	free(m_key);
beb904
 
beb904
-	if (!entry) {
beb904
+	if (!mnt) {
beb904
 		error(ap->logopt, "expected amd mount entry not found");
beb904
 		return NSS_STATUS_UNKNOWN;
beb904
 	}
beb904
 
beb904
-	if (strcmp(entry->type, "host")) {
beb904
-		error(ap->logopt, "unexpected map type %s", entry->type);
beb904
+	if (strcmp(mnt->amd_type, "host")) {
beb904
+		error(ap->logopt, "unexpected map type %s", mnt->amd_type);
beb904
+		mnts_put_mount(mnt);
beb904
 		return NSS_STATUS_UNKNOWN;
beb904
 	}
beb904
 
beb904
-	if (entry->opts && *entry->opts) {
beb904
-		argv[0] = entry->opts;
beb904
+	if (mnt->amd_opts && *mnt->amd_opts) {
beb904
+		argv[0] = mnt->amd_opts;
beb904
 		argv[1] = NULL;
beb904
 		pargv = argv;
beb904
 		argc = 1;
beb904
@@ -894,9 +896,11 @@ static int lookup_amd_instance(struct au
beb904
 		}
beb904
 	}
beb904
 	if (!instance) {
beb904
+		mnts_put_mount(mnt);
beb904
 		error(ap->logopt, "expected hosts map instance not found");
beb904
 		return NSS_STATUS_UNKNOWN;
beb904
 	}
beb904
+	mnts_put_mount(mnt);
beb904
 
beb904
 	return do_lookup_mount(ap, instance, name, name_len);
beb904
 }
beb904
--- autofs-5.1.4.orig/include/automount.h
beb904
+++ autofs-5.1.4/include/automount.h
beb904
@@ -568,10 +568,10 @@ struct autofs_point {
beb904
 	struct autofs_point *parent;	/* Owner of mounts list for submount */
beb904
 	pthread_mutex_t mounts_mutex;	/* Protect mount lists */
beb904
 	struct list_head mounts;	/* List of autofs mounts at current level */
beb904
-	struct list_head amdmounts;	/* List of non submount amd mounts */
beb904
 	unsigned int submount;		/* Is this a submount */
beb904
 	unsigned int submnt_count;	/* Number of submounts */
beb904
 	struct list_head submounts;	/* List of child submounts */
beb904
+	struct list_head amdmounts;	/* List of non submount amd mounts */
beb904
 	unsigned int shutdown;		/* Shutdown notification */
beb904
 };
beb904
 
beb904
--- autofs-5.1.4.orig/include/master.h
beb904
+++ autofs-5.1.4/include/master.h
beb904
@@ -109,8 +109,6 @@ void master_source_current_wait(struct m
beb904
 void master_source_current_signal(struct master_mapent *);
beb904
 struct master_mapent *master_find_mapent(struct master *, const char *);
beb904
 unsigned int master_partial_match_mapent(struct master *, const char *);
beb904
-struct amd_entry *__master_find_amdmount(struct autofs_point *, const char *);
beb904
-struct amd_entry *master_find_amdmount(struct autofs_point *, const char *);
beb904
 struct master_mapent *master_new_mapent(struct master *, const char *, time_t);
beb904
 void master_add_mapent(struct master *, struct master_mapent *);
beb904
 void master_remove_mapent(struct master_mapent *);
beb904
--- autofs-5.1.4.orig/include/mounts.h
beb904
+++ autofs-5.1.4/include/mounts.h
beb904
@@ -38,6 +38,7 @@
beb904
 #define MNTS_INDIRECT	0x0008
beb904
 #define MNTS_DIRECT	0x0010
beb904
 #define MNTS_OFFSET	0x0020
beb904
+#define MNTS_AMD_MOUNT	0x0040
beb904
 
beb904
 #define REMOUNT_SUCCESS		0x0000
beb904
 #define REMOUNT_FAIL		0x0001
beb904
@@ -64,6 +65,14 @@ struct mnt_list {
beb904
 	struct list_head submount;
beb904
 	struct list_head submount_work;
beb904
 
beb904
+	/* List of amd-mounts of an autofs_point */
beb904
+	char *ext_mp;
beb904
+	char *amd_pref;
beb904
+	char *amd_type;
beb904
+	char *amd_opts;
beb904
+	unsigned int amd_cache_opts;
beb904
+	struct list_head amdmount;
beb904
+
beb904
 	/*
beb904
 	 * List operations ie. get_mnt_list.
beb904
 	 */
beb904
@@ -118,6 +127,9 @@ struct mnt_list *mnts_add_submount(struc
beb904
 void mnts_remove_submount(const char *mp);
beb904
 void mnts_get_submount_list(struct list_head *mnts, struct autofs_point *ap);
beb904
 void mnts_put_submount_list(struct list_head *mnts);
beb904
+struct mnt_list *mnts_find_amdmount(const char *path);
beb904
+struct mnt_list *mnts_add_amdmount(struct autofs_point *ap, struct amd_entry *entry);
beb904
+void mnts_remove_amdmount(const char *mp);
beb904
 struct mnt_list *get_mnt_list(const char *path, int include);
beb904
 int unlink_mount_tree(struct autofs_point *ap, const char *mp);
beb904
 void free_mnt_list(struct mnt_list *list);
beb904
--- autofs-5.1.4.orig/include/parse_amd.h
beb904
+++ autofs-5.1.4/include/parse_amd.h
beb904
@@ -65,7 +65,6 @@ struct amd_entry {
beb904
 	char *umount;
beb904
 	struct selector *selector;
beb904
 	struct list_head list;
beb904
-	struct list_head entries;
beb904
 };
beb904
 
beb904
 int amd_parse_list(struct autofs_point *,
beb904
--- autofs-5.1.4.orig/lib/master.c
beb904
+++ autofs-5.1.4/lib/master.c
beb904
@@ -152,12 +152,10 @@ void master_free_autofs_point(struct aut
beb904
 	head = &ap->amdmounts;
beb904
 	p = head->next;
beb904
 	while (p != head) {
beb904
-		struct amd_entry *entry = list_entry(p, struct amd_entry, entries);
beb904
+		struct mnt_list *mnt = list_entry(p, struct mnt_list, amdmount);
beb904
 		p = p->next;
beb904
-		if (!list_empty(&entry->entries))
beb904
-			list_del(&entry->entries);
beb904
-		ext_mount_remove(entry->fs);
beb904
-		free_amd_entry(entry);
beb904
+		ext_mount_remove(mnt->ext_mp);
beb904
+		mnts_remove_amdmount(mnt->mp);
beb904
 	}
beb904
 	mounts_mutex_unlock(ap);
beb904
 
beb904
@@ -761,34 +759,6 @@ unsigned int master_partial_match_mapent
beb904
 	return ret;
beb904
 }
beb904
 
beb904
-struct amd_entry *__master_find_amdmount(struct autofs_point *ap, const char *path)
beb904
-{
beb904
-	struct list_head *head, *p;
beb904
-
beb904
-	head = &ap->amdmounts;
beb904
-	list_for_each(p, head) {
beb904
-		struct amd_entry *entry;
beb904
-
beb904
-		entry = list_entry(p, struct amd_entry, entries);
beb904
-
beb904
-		if (!strcmp(entry->path, path))
beb904
-			return entry;
beb904
-	}
beb904
-
beb904
-	return NULL;
beb904
-}
beb904
-
beb904
-struct amd_entry *master_find_amdmount(struct autofs_point *ap, const char *path)
beb904
-{
beb904
-	struct amd_entry *entry;
beb904
-
beb904
-	mounts_mutex_lock(ap);
beb904
-	entry = __master_find_amdmount(ap, path);
beb904
-	mounts_mutex_unlock(ap);
beb904
-
beb904
-	return entry;
beb904
-}
beb904
-
beb904
 struct master_mapent *master_new_mapent(struct master *master, const char *path, time_t age)
beb904
 {
beb904
 	struct master_mapent *entry;
beb904
--- autofs-5.1.4.orig/lib/mounts.c
beb904
+++ autofs-5.1.4/lib/mounts.c
beb904
@@ -546,7 +546,6 @@ struct amd_entry *new_amd_entry(const st
beb904
 	memset(new, 0, sizeof(*new));
beb904
 	new->path = path;
beb904
 	INIT_LIST_HEAD(&new->list);
beb904
-	INIT_LIST_HEAD(&new->entries);
beb904
 
beb904
 	return new;
beb904
 }
beb904
@@ -887,6 +886,7 @@ static struct mnt_list *mnts_alloc_mount
beb904
 	INIT_HLIST_NODE(&this->hash);
beb904
 	INIT_LIST_HEAD(&this->submount);
beb904
 	INIT_LIST_HEAD(&this->submount_work);
beb904
+	INIT_LIST_HEAD(&this->amdmount);
beb904
 done:
beb904
 	return this;
beb904
 }
beb904
@@ -1048,6 +1048,107 @@ void mnts_put_submount_list(struct list_
beb904
 	mnts_hash_mutex_unlock();
beb904
 }
beb904
 
beb904
+struct mnt_list *mnts_find_amdmount(const char *path)
beb904
+{
beb904
+	struct mnt_list *mnt;
beb904
+
beb904
+	mnt = mnts_lookup_mount(path);
beb904
+	if (mnt && mnt->flags & MNTS_AMD_MOUNT)
beb904
+		return mnt;
beb904
+	mnts_put_mount(mnt);
beb904
+	return NULL;
beb904
+}
beb904
+
beb904
+struct mnt_list *mnts_add_amdmount(struct autofs_point *ap, struct amd_entry *entry)
beb904
+{
beb904
+	struct mnt_list *this;
beb904
+	char *type, *ext_mp, *pref, *opts;
beb904
+
beb904
+	ext_mp = pref = type = opts = NULL;
beb904
+
beb904
+	if (entry->fs) {
beb904
+		ext_mp = strdup(entry->fs);
beb904
+		if (!ext_mp)
beb904
+			goto fail;
beb904
+	}
beb904
+
beb904
+	if (entry->pref) {
beb904
+		pref = strdup(entry->pref);
beb904
+		if (!pref)
beb904
+			goto fail;
beb904
+	}
beb904
+
beb904
+	if (entry->type) {
beb904
+		type = strdup(entry->type);
beb904
+		if (!type)
beb904
+			goto fail;
beb904
+	}
beb904
+
beb904
+	if (entry->opts) {
beb904
+		opts = strdup(entry->opts);
beb904
+		if (!opts)
beb904
+			goto fail;
beb904
+	}
beb904
+
beb904
+	mnts_hash_mutex_lock();
beb904
+	this = mnts_get_mount(entry->path);
beb904
+	if (this) {
beb904
+		this->ext_mp = ext_mp;
beb904
+		this->amd_pref = pref;
beb904
+		this->amd_type = type;
beb904
+		this->amd_opts = opts;
beb904
+		this->amd_cache_opts = entry->cache_opts;
beb904
+		this->flags |= MNTS_AMD_MOUNT;
beb904
+		if (list_empty(&this->amdmount))
beb904
+			list_add_tail(&this->amdmount, &ap->amdmounts);
beb904
+	}
beb904
+	mnts_hash_mutex_unlock();
beb904
+
beb904
+	return this;
beb904
+fail:
beb904
+	if (ext_mp)
beb904
+		free(ext_mp);
beb904
+	if (pref)
beb904
+		free(pref);
beb904
+	if (type)
beb904
+		free(type);
beb904
+	if (opts)
beb904
+		free(opts);
beb904
+	return NULL;
beb904
+}
beb904
+
beb904
+void mnts_remove_amdmount(const char *mp)
beb904
+{
beb904
+	struct mnt_list *this;
beb904
+
beb904
+	mnts_hash_mutex_lock();
beb904
+	this = mnts_lookup(mp);
beb904
+	if (!(this && this->flags & MNTS_AMD_MOUNT))
beb904
+		goto done;
beb904
+	this->flags &= ~MNTS_AMD_MOUNT;
beb904
+	list_del_init(&this->submount);
beb904
+	if (this->ext_mp) {
beb904
+		free(this->ext_mp);
beb904
+		this->ext_mp = NULL;
beb904
+	}
beb904
+	if (this->amd_type) {
beb904
+		free(this->amd_type);
beb904
+		this->amd_type = NULL;
beb904
+	}
beb904
+	if (this->amd_pref) {
beb904
+		free(this->amd_pref);
beb904
+		this->amd_pref = NULL;
beb904
+	}
beb904
+	if (this->amd_opts) {
beb904
+		free(this->amd_opts);
beb904
+		this->amd_opts = NULL;
beb904
+	}
beb904
+	this->amd_cache_opts = 0;
beb904
+	__mnts_put_mount(this);
beb904
+done:
beb904
+	mnts_hash_mutex_unlock();
beb904
+}
beb904
+
beb904
 /* From glibc decode_name() */
beb904
 /* Since the values in a line are separated by spaces, a name cannot
beb904
  * contain a space.  Therefore some programs encode spaces in names
beb904
--- autofs-5.1.4.orig/modules/mount_autofs.c
beb904
+++ autofs-5.1.4/modules/mount_autofs.c
beb904
@@ -286,16 +286,19 @@ int mount_mount(struct autofs_point *ap,
beb904
 	mounts_mutex_lock(ap);
beb904
 
beb904
 	if (source->flags & MAP_FLAG_FORMAT_AMD) {
beb904
-		struct amd_entry *am_entry = __master_find_amdmount(ap, entry->path);
beb904
+		struct mnt_list *mnt;
beb904
 
beb904
-		if (am_entry) {
beb904
-			if (am_entry->pref) {
beb904
-				nap->pref = am_entry->pref;
beb904
-				am_entry->pref = NULL;
beb904
+		mnt = mnts_find_amdmount(entry->path);
beb904
+		if (mnt) {
beb904
+			if (mnt->amd_pref) {
beb904
+				nap->pref = mnt->amd_pref;
beb904
+				mnt->amd_pref = NULL;
beb904
 			}
beb904
 
beb904
-			if (am_entry->cache_opts & AMD_CACHE_OPTION_ALL)
beb904
+			if (mnt->amd_cache_opts & AMD_CACHE_OPTION_ALL)
beb904
 				nap->flags |= MOUNT_FLAG_AMD_CACHE_ALL;
beb904
+
beb904
+			mnts_put_mount(mnt);
beb904
 		}
beb904
 	}
beb904
 
beb904
--- autofs-5.1.4.orig/modules/parse_amd.c
beb904
+++ autofs-5.1.4/modules/parse_amd.c
beb904
@@ -1300,6 +1300,7 @@ static int do_host_mount(struct autofs_p
beb904
 {
beb904
 	struct lookup_mod *lookup;
beb904
 	struct map_source *instance;
beb904
+	struct mnt_list *mnt = NULL;
beb904
 	struct mapent *me;
beb904
 	const char *argv[2];
beb904
 	const char **pargv = NULL;
beb904
@@ -1316,7 +1317,9 @@ static int do_host_mount(struct autofs_p
beb904
 	 */
beb904
 	if (strcmp(name, entry->rhost)) {
beb904
 		char *target;
beb904
-		size_t len = strlen(ap->path) + strlen(entry->rhost) + 2;
beb904
+		size_t len;
beb904
+
beb904
+		len = strlen(ap->path) + strlen(entry->rhost) + 2;
beb904
 		target = malloc(len);
beb904
 		if (!target) {
beb904
 			warn(ap->logopt, MODPREFIX
beb904
@@ -1329,6 +1332,15 @@ static int do_host_mount(struct autofs_p
beb904
 		if (entry->path)
beb904
 			free(entry->path);
beb904
 		entry->path = target;
beb904
+
beb904
+		/* Add an mnt_list entry for the updated path. */
beb904
+		mnt = mnts_add_amdmount(ap, entry);
beb904
+		if (!mnt) {
beb904
+			error(ap->logopt, MODPREFIX
beb904
+			      "failed to update mount mnt_list entry");
beb904
+			goto out;
beb904
+		}
beb904
+
beb904
 		/*
beb904
 		 * Wait for any expire before racing to mount the
beb904
 		 * export tree or bail out if we're shutting down.
beb904
@@ -1388,6 +1400,8 @@ static int do_host_mount(struct autofs_p
beb904
 		warn(ap->logopt, MODPREFIX
beb904
 		     "failed to create symlink to hosts mount base");
beb904
 out:
beb904
+	if (ret && mnt)
beb904
+		mnts_remove_amdmount(mnt->mp);
beb904
 	return ret;
beb904
 }
beb904
 
beb904
@@ -2204,6 +2218,7 @@ int parse_mount(struct autofs_point *ap,
beb904
 	struct list_head entries, *p, *head;
beb904
 	struct amd_entry *defaults_entry;
beb904
 	struct amd_entry *cur_defaults;
beb904
+	struct mnt_list *mnt;
beb904
 	int rv = 1;
beb904
 	int cur_state;
beb904
 	int ret;
beb904
@@ -2313,21 +2328,27 @@ int parse_mount(struct autofs_point *ap,
beb904
 		 * add parsed entry to parent amd mount list and remove
beb904
 		 * on mount fail.
beb904
 		 */
beb904
-		mounts_mutex_lock(ap);
beb904
-		list_add_tail(&this->entries, &ap->amdmounts);
beb904
-		mounts_mutex_unlock(ap);
beb904
+		mnt = mnts_add_amdmount(ap, this);
beb904
+		if (!mnt) {
beb904
+			error(ap->logopt, MODPREFIX
beb904
+			      "failed to add mount to mnt_list");
beb904
+			break;
beb904
+		}
beb904
 
beb904
 		rv = amd_mount(ap, name, this, source, sv, flags, ctxt);
beb904
-		mounts_mutex_lock(ap);
beb904
 		if (!rv) {
beb904
-			/* Mounted, remove entry from parsed list */
beb904
-			list_del_init(&this->list);
beb904
-			mounts_mutex_unlock(ap);
beb904
+			/*
beb904
+			 * If entry->path doesn't match the mnt->mp then
beb904
+			 * the mount point path has changed and a new
beb904
+			 * mnt_list entry added for it, so remove the
beb904
+			 * original.
beb904
+			 */
beb904
+			if (strcmp(this->path, mnt->mp))
beb904
+				mnts_remove_amdmount(this->path);
beb904
 			break;
beb904
 		}
beb904
-		/* Not mounted, remove entry from the parent list */
beb904
-		list_del_init(&this->entries);
beb904
-		mounts_mutex_unlock(ap);
beb904
+		/* Not mounted, remove the mnt_list entry from amdmount list */
beb904
+		mnts_remove_amdmount(this->path);
beb904
 	}
beb904
 	free_amd_entry(cur_defaults);
beb904