|
|
9a499a |
autofs-5.1.6 - use mnt_list for submounts
|
|
|
9a499a |
|
|
|
9a499a |
From: Ian Kent <raven@themaw.net>
|
|
|
9a499a |
|
|
|
9a499a |
Use struct mnt_list objects for submount list entries instead of
|
|
|
9a499a |
struct autofs_point itself.
|
|
|
9a499a |
|
|
|
9a499a |
Signed-off-by: Ian Kent <raven@themaw.net>
|
|
|
9a499a |
---
|
|
|
9a499a |
CHANGELOG | 1
|
|
|
9a499a |
daemon/automount.c | 11 ++++-
|
|
|
9a499a |
daemon/direct.c | 7 ++-
|
|
|
9a499a |
daemon/indirect.c | 5 ++
|
|
|
9a499a |
include/automount.h | 2 -
|
|
|
9a499a |
include/master.h | 2 -
|
|
|
9a499a |
include/mounts.h | 10 +++++
|
|
|
9a499a |
lib/master.c | 93 +++++++++++++++----------------------------------
|
|
|
9a499a |
lib/mounts.c | 81 ++++++++++++++++++++++++++++++++++++++++++
|
|
|
9a499a |
modules/mount_autofs.c | 17 ++++++++
|
|
|
9a499a |
10 files changed, 157 insertions(+), 72 deletions(-)
|
|
|
9a499a |
|
|
|
9a499a |
--- autofs-5.1.4.orig/CHANGELOG
|
|
|
9a499a |
+++ autofs-5.1.4/CHANGELOG
|
|
|
9a499a |
@@ -122,6 +122,7 @@ xx/xx/2018 autofs-5.1.5
|
|
|
9a499a |
- make external mounts independent of amd_entry.
|
|
|
9a499a |
- make external mounts use simpler hashtable.
|
|
|
9a499a |
- add a hash index to mnt_list.
|
|
|
9a499a |
+- use mnt_list for submounts.
|
|
|
9a499a |
|
|
|
9a499a |
19/12/2017 autofs-5.1.4
|
|
|
9a499a |
- fix spec file url.
|
|
|
9a499a |
--- autofs-5.1.4.orig/daemon/automount.c
|
|
|
9a499a |
+++ autofs-5.1.4/daemon/automount.c
|
|
|
9a499a |
@@ -624,6 +624,7 @@ done:
|
|
|
9a499a |
it also tries to umount path itself */
|
|
|
9a499a |
int umount_multi(struct autofs_point *ap, const char *path, int incl)
|
|
|
9a499a |
{
|
|
|
9a499a |
+ struct mnt_list *sbmnt;
|
|
|
9a499a |
int is_autofs_fs;
|
|
|
9a499a |
struct stat st;
|
|
|
9a499a |
int left;
|
|
|
9a499a |
@@ -685,8 +686,11 @@ int umount_multi(struct autofs_point *ap
|
|
|
9a499a |
}
|
|
|
9a499a |
|
|
|
9a499a |
is_autofs_fs = 0;
|
|
|
9a499a |
- if (master_find_submount(ap, path))
|
|
|
9a499a |
+ sbmnt = mnts_find_submount(path);
|
|
|
9a499a |
+ if (sbmnt) {
|
|
|
9a499a |
is_autofs_fs = 1;
|
|
|
9a499a |
+ mnts_put_mount(sbmnt);
|
|
|
9a499a |
+ }
|
|
|
9a499a |
|
|
|
9a499a |
left = 0;
|
|
|
9a499a |
|
|
|
9a499a |
@@ -1717,9 +1721,12 @@ static void handle_mounts_cleanup(void *
|
|
|
9a499a |
|
|
|
9a499a |
if (submount) {
|
|
|
9a499a |
struct amd_entry *am;
|
|
|
9a499a |
+
|
|
|
9a499a |
/* We are finishing up */
|
|
|
9a499a |
ap->parent->submnt_count--;
|
|
|
9a499a |
- list_del_init(&ap->mounts);
|
|
|
9a499a |
+
|
|
|
9a499a |
+ /* Submount at ap->path belongs to parent submount list. */
|
|
|
9a499a |
+ mnts_remove_submount(ap->path);
|
|
|
9a499a |
am = __master_find_amdmount(ap->parent, ap->path);
|
|
|
9a499a |
if (am) {
|
|
|
9a499a |
list_del_init(&am->entries);
|
|
|
9a499a |
--- autofs-5.1.4.orig/daemon/direct.c
|
|
|
9a499a |
+++ autofs-5.1.4/daemon/direct.c
|
|
|
9a499a |
@@ -1211,14 +1211,17 @@ static void *do_mount_direct(void *arg)
|
|
|
9a499a |
*/
|
|
|
9a499a |
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &state);
|
|
|
9a499a |
if (status) {
|
|
|
9a499a |
+ struct mnt_list *sbmnt;
|
|
|
9a499a |
struct mapent *me;
|
|
|
9a499a |
struct statfs fs;
|
|
|
9a499a |
unsigned int close_fd = 0;
|
|
|
9a499a |
|
|
|
9a499a |
+ sbmnt = mnts_find_submount(mt.name);
|
|
|
9a499a |
if (statfs(mt.name, &fs) == -1 ||
|
|
|
9a499a |
- (fs.f_type == AUTOFS_SUPER_MAGIC &&
|
|
|
9a499a |
- !master_find_submount(ap, mt.name)))
|
|
|
9a499a |
+ (fs.f_type == AUTOFS_SUPER_MAGIC && !sbmnt))
|
|
|
9a499a |
close_fd = 1;
|
|
|
9a499a |
+ if (sbmnt)
|
|
|
9a499a |
+ mnts_put_mount(sbmnt);
|
|
|
9a499a |
cache_writelock(mt.mc);
|
|
|
9a499a |
if ((me = cache_lookup_distinct(mt.mc, mt.name))) {
|
|
|
9a499a |
/*
|
|
|
9a499a |
--- autofs-5.1.4.orig/daemon/indirect.c
|
|
|
9a499a |
+++ autofs-5.1.4/daemon/indirect.c
|
|
|
9a499a |
@@ -401,6 +401,7 @@ void *expire_proc_indirect(void *arg)
|
|
|
9a499a |
if (next->flags & MNTS_INDIRECT)
|
|
|
9a499a |
master_notify_submount(ap, next->mp, ap->state);
|
|
|
9a499a |
else if (next->flags & MNTS_OFFSET) {
|
|
|
9a499a |
+ struct mnt_list *sbmnt;
|
|
|
9a499a |
struct map_source *map;
|
|
|
9a499a |
struct mapent_cache *mc = NULL;
|
|
|
9a499a |
struct mapent *me = NULL;
|
|
|
9a499a |
@@ -413,7 +414,9 @@ void *expire_proc_indirect(void *arg)
|
|
|
9a499a |
}
|
|
|
9a499a |
|
|
|
9a499a |
/* Don't touch submounts */
|
|
|
9a499a |
- if (master_find_submount(ap, next->mp)) {
|
|
|
9a499a |
+ sbmnt = mnts_find_submount(next->mp);
|
|
|
9a499a |
+ if (sbmnt) {
|
|
|
9a499a |
+ mnts_put_mount(sbmnt);
|
|
|
9a499a |
pthread_setcancelstate(cur_state, NULL);
|
|
|
9a499a |
continue;
|
|
|
9a499a |
}
|
|
|
9a499a |
--- autofs-5.1.4.orig/include/automount.h
|
|
|
9a499a |
+++ autofs-5.1.4/include/automount.h
|
|
|
9a499a |
@@ -570,9 +570,9 @@ struct autofs_point {
|
|
|
9a499a |
struct list_head mounts; /* List of autofs mounts at current level */
|
|
|
9a499a |
struct list_head amdmounts; /* List of non submount amd mounts */
|
|
|
9a499a |
unsigned int submount; /* Is this a submount */
|
|
|
9a499a |
- unsigned int shutdown; /* Shutdown notification */
|
|
|
9a499a |
unsigned int submnt_count; /* Number of submounts */
|
|
|
9a499a |
struct list_head submounts; /* List of child submounts */
|
|
|
9a499a |
+ unsigned int shutdown; /* Shutdown notification */
|
|
|
9a499a |
};
|
|
|
9a499a |
|
|
|
9a499a |
#define UNLINK_AND_CONT 0x01
|
|
|
9a499a |
--- autofs-5.1.4.orig/include/master.h
|
|
|
9a499a |
+++ autofs-5.1.4/include/master.h
|
|
|
9a499a |
@@ -109,8 +109,6 @@ void master_source_current_wait(struct m
|
|
|
9a499a |
void master_source_current_signal(struct master_mapent *);
|
|
|
9a499a |
struct master_mapent *master_find_mapent(struct master *, const char *);
|
|
|
9a499a |
unsigned int master_partial_match_mapent(struct master *, const char *);
|
|
|
9a499a |
-struct autofs_point *__master_find_submount(struct autofs_point *, const char *);
|
|
|
9a499a |
-struct autofs_point *master_find_submount(struct autofs_point *, const char *);
|
|
|
9a499a |
struct amd_entry *__master_find_amdmount(struct autofs_point *, const char *);
|
|
|
9a499a |
struct amd_entry *master_find_amdmount(struct autofs_point *, const char *);
|
|
|
9a499a |
struct master_mapent *master_new_mapent(struct master *, const char *, time_t);
|
|
|
9a499a |
--- autofs-5.1.4.orig/include/mounts.h
|
|
|
9a499a |
+++ autofs-5.1.4/include/mounts.h
|
|
|
9a499a |
@@ -59,6 +59,11 @@ struct mnt_list {
|
|
|
9a499a |
struct hlist_node hash;
|
|
|
9a499a |
unsigned int ref;
|
|
|
9a499a |
|
|
|
9a499a |
+ /* List of sub-mounts of an autofs_point */
|
|
|
9a499a |
+ struct autofs_point *ap;
|
|
|
9a499a |
+ struct list_head submount;
|
|
|
9a499a |
+ struct list_head submount_work;
|
|
|
9a499a |
+
|
|
|
9a499a |
/*
|
|
|
9a499a |
* List operations ie. get_mnt_list.
|
|
|
9a499a |
*/
|
|
|
9a499a |
@@ -108,6 +113,11 @@ int ext_mount_remove(const char *);
|
|
|
9a499a |
int ext_mount_inuse(const char *);
|
|
|
9a499a |
struct mnt_list *mnts_lookup_mount(const char *mp);
|
|
|
9a499a |
void mnts_put_mount(struct mnt_list *mnt);
|
|
|
9a499a |
+struct mnt_list *mnts_find_submount(const char *path);
|
|
|
9a499a |
+struct mnt_list *mnts_add_submount(struct autofs_point *ap);
|
|
|
9a499a |
+void mnts_remove_submount(const char *mp);
|
|
|
9a499a |
+void mnts_get_submount_list(struct list_head *mnts, struct autofs_point *ap);
|
|
|
9a499a |
+void mnts_put_submount_list(struct list_head *mnts);
|
|
|
9a499a |
struct mnt_list *get_mnt_list(const char *path, int include);
|
|
|
9a499a |
int unlink_mount_tree(struct autofs_point *ap, const char *mp);
|
|
|
9a499a |
void free_mnt_list(struct mnt_list *list);
|
|
|
9a499a |
--- autofs-5.1.4.orig/lib/master.c
|
|
|
9a499a |
+++ autofs-5.1.4/lib/master.c
|
|
|
9a499a |
@@ -761,34 +761,6 @@ unsigned int master_partial_match_mapent
|
|
|
9a499a |
return ret;
|
|
|
9a499a |
}
|
|
|
9a499a |
|
|
|
9a499a |
-struct autofs_point *__master_find_submount(struct autofs_point *ap, const char *path)
|
|
|
9a499a |
-{
|
|
|
9a499a |
- struct list_head *head, *p;
|
|
|
9a499a |
-
|
|
|
9a499a |
- head = &ap->submounts;
|
|
|
9a499a |
- list_for_each(p, head) {
|
|
|
9a499a |
- struct autofs_point *submount;
|
|
|
9a499a |
-
|
|
|
9a499a |
- submount = list_entry(p, struct autofs_point, mounts);
|
|
|
9a499a |
-
|
|
|
9a499a |
- if (!strcmp(submount->path, path))
|
|
|
9a499a |
- return submount;
|
|
|
9a499a |
- }
|
|
|
9a499a |
-
|
|
|
9a499a |
- return NULL;
|
|
|
9a499a |
-}
|
|
|
9a499a |
-
|
|
|
9a499a |
-struct autofs_point *master_find_submount(struct autofs_point *ap, const char *path)
|
|
|
9a499a |
-{
|
|
|
9a499a |
- struct autofs_point *submount;
|
|
|
9a499a |
-
|
|
|
9a499a |
- mounts_mutex_lock(ap);
|
|
|
9a499a |
- submount = __master_find_submount(ap, path);
|
|
|
9a499a |
- mounts_mutex_unlock(ap);
|
|
|
9a499a |
-
|
|
|
9a499a |
- return submount;
|
|
|
9a499a |
-}
|
|
|
9a499a |
-
|
|
|
9a499a |
struct amd_entry *__master_find_amdmount(struct autofs_point *ap, const char *path)
|
|
|
9a499a |
{
|
|
|
9a499a |
struct list_head *head, *p;
|
|
|
9a499a |
@@ -1190,85 +1162,80 @@ int master_submount_list_empty(struct au
|
|
|
9a499a |
|
|
|
9a499a |
int master_notify_submount(struct autofs_point *ap, const char *path, enum states state)
|
|
|
9a499a |
{
|
|
|
9a499a |
- struct list_head *head, *p;
|
|
|
9a499a |
- struct autofs_point *this = NULL;
|
|
|
9a499a |
+ struct mnt_list *this, *sbmnt;
|
|
|
9a499a |
+ LIST_HEAD(sbmnts);
|
|
|
9a499a |
int ret = 1;
|
|
|
9a499a |
|
|
|
9a499a |
- mounts_mutex_lock(ap);
|
|
|
9a499a |
-
|
|
|
9a499a |
- head = &ap->submounts;
|
|
|
9a499a |
- p = head->prev;
|
|
|
9a499a |
- while (p != head) {
|
|
|
9a499a |
- this = list_entry(p, struct autofs_point, mounts);
|
|
|
9a499a |
- p = p->prev;
|
|
|
9a499a |
+ mnts_get_submount_list(&sbmnts, ap);
|
|
|
9a499a |
+ if (list_empty(&sbmnts))
|
|
|
9a499a |
+ return 1;
|
|
|
9a499a |
+
|
|
|
9a499a |
+ list_for_each_entry(this, &sbmnts, submount_work) {
|
|
|
9a499a |
+ /* Not a submount */
|
|
|
9a499a |
+ if (!(this->flags & MNTS_AUTOFS))
|
|
|
9a499a |
+ continue;
|
|
|
9a499a |
|
|
|
9a499a |
/* path not the same */
|
|
|
9a499a |
- if (strcmp(this->path, path))
|
|
|
9a499a |
+ if (strcmp(this->mp, path))
|
|
|
9a499a |
continue;
|
|
|
9a499a |
|
|
|
9a499a |
- if (!master_submount_list_empty(this)) {
|
|
|
9a499a |
- char *this_path = strdup(this->path);
|
|
|
9a499a |
- if (this_path) {
|
|
|
9a499a |
- mounts_mutex_unlock(ap);
|
|
|
9a499a |
- master_notify_submount(this, path, state);
|
|
|
9a499a |
- mounts_mutex_lock(ap);
|
|
|
9a499a |
- if (!__master_find_submount(ap, this_path)) {
|
|
|
9a499a |
- free(this_path);
|
|
|
9a499a |
- continue;
|
|
|
9a499a |
- }
|
|
|
9a499a |
- free(this_path);
|
|
|
9a499a |
- }
|
|
|
9a499a |
+ if (!master_submount_list_empty(this->ap)) {
|
|
|
9a499a |
+ struct mnt_list *sm;
|
|
|
9a499a |
+
|
|
|
9a499a |
+ master_notify_submount(this->ap, path, state);
|
|
|
9a499a |
+ sm = mnts_find_submount(path);
|
|
|
9a499a |
+ if (!sm)
|
|
|
9a499a |
+ continue;
|
|
|
9a499a |
+ mnts_put_mount(sm);
|
|
|
9a499a |
}
|
|
|
9a499a |
|
|
|
9a499a |
/* Now we have found the submount we want to expire */
|
|
|
9a499a |
|
|
|
9a499a |
st_mutex_lock();
|
|
|
9a499a |
|
|
|
9a499a |
- if (this->state == ST_SHUTDOWN) {
|
|
|
9a499a |
+ if (this->ap->state == ST_SHUTDOWN) {
|
|
|
9a499a |
this = NULL;
|
|
|
9a499a |
st_mutex_unlock();
|
|
|
9a499a |
break;
|
|
|
9a499a |
}
|
|
|
9a499a |
|
|
|
9a499a |
- this->shutdown = ap->shutdown;
|
|
|
9a499a |
+ this->ap->shutdown = ap->shutdown;
|
|
|
9a499a |
|
|
|
9a499a |
- __st_add_task(this, state);
|
|
|
9a499a |
+ __st_add_task(this->ap, state);
|
|
|
9a499a |
|
|
|
9a499a |
st_mutex_unlock();
|
|
|
9a499a |
- mounts_mutex_unlock(ap);
|
|
|
9a499a |
|
|
|
9a499a |
- st_wait_task(this, state, 0);
|
|
|
9a499a |
+ st_wait_task(this->ap, state, 0);
|
|
|
9a499a |
|
|
|
9a499a |
/*
|
|
|
9a499a |
* If our submount gets to state ST_SHUTDOWN, ST_SHUTDOWN_PENDING or
|
|
|
9a499a |
* ST_SHUTDOWN_FORCE we need to wait until it goes away or changes
|
|
|
9a499a |
* to ST_READY.
|
|
|
9a499a |
*/
|
|
|
9a499a |
- mounts_mutex_lock(ap);
|
|
|
9a499a |
st_mutex_lock();
|
|
|
9a499a |
- while ((this = __master_find_submount(ap, path))) {
|
|
|
9a499a |
+ while ((sbmnt = mnts_find_submount(path))) {
|
|
|
9a499a |
struct timespec t = { 0, 300000000 };
|
|
|
9a499a |
struct timespec r;
|
|
|
9a499a |
|
|
|
9a499a |
- if (this->state != ST_SHUTDOWN &&
|
|
|
9a499a |
- this->state != ST_SHUTDOWN_PENDING &&
|
|
|
9a499a |
- this->state != ST_SHUTDOWN_FORCE) {
|
|
|
9a499a |
+ if (sbmnt->ap->state != ST_SHUTDOWN &&
|
|
|
9a499a |
+ sbmnt->ap->state != ST_SHUTDOWN_PENDING &&
|
|
|
9a499a |
+ sbmnt->ap->state != ST_SHUTDOWN_FORCE) {
|
|
|
9a499a |
ret = 0;
|
|
|
9a499a |
+ mnts_put_mount(sbmnt);
|
|
|
9a499a |
break;
|
|
|
9a499a |
}
|
|
|
9a499a |
+ mnts_put_mount(sbmnt);
|
|
|
9a499a |
|
|
|
9a499a |
st_mutex_unlock();
|
|
|
9a499a |
- mounts_mutex_unlock(ap);
|
|
|
9a499a |
while (nanosleep(&t, &r) == -1 && errno == EINTR)
|
|
|
9a499a |
memcpy(&t, &r, sizeof(struct timespec));
|
|
|
9a499a |
- mounts_mutex_lock(ap);
|
|
|
9a499a |
st_mutex_lock();
|
|
|
9a499a |
}
|
|
|
9a499a |
st_mutex_unlock();
|
|
|
9a499a |
break;
|
|
|
9a499a |
}
|
|
|
9a499a |
|
|
|
9a499a |
- mounts_mutex_unlock(ap);
|
|
|
9a499a |
+ mnts_put_submount_list(&sbmnts);
|
|
|
9a499a |
|
|
|
9a499a |
return ret;
|
|
|
9a499a |
}
|
|
|
9a499a |
--- autofs-5.1.4.orig/lib/mounts.c
|
|
|
9a499a |
+++ autofs-5.1.4/lib/mounts.c
|
|
|
9a499a |
@@ -885,6 +885,8 @@ static struct mnt_list *mnts_alloc_mount
|
|
|
9a499a |
|
|
|
9a499a |
this->ref = 1;
|
|
|
9a499a |
INIT_HLIST_NODE(&this->hash);
|
|
|
9a499a |
+ INIT_LIST_HEAD(&this->submount);
|
|
|
9a499a |
+ INIT_LIST_HEAD(&this->submount_work);
|
|
|
9a499a |
done:
|
|
|
9a499a |
return this;
|
|
|
9a499a |
}
|
|
|
9a499a |
@@ -967,6 +969,85 @@ void mnts_put_mount(struct mnt_list *mnt
|
|
|
9a499a |
mnts_hash_mutex_unlock();
|
|
|
9a499a |
}
|
|
|
9a499a |
|
|
|
9a499a |
+struct mnt_list *mnts_find_submount(const char *path)
|
|
|
9a499a |
+{
|
|
|
9a499a |
+ struct mnt_list *mnt;
|
|
|
9a499a |
+
|
|
|
9a499a |
+ mnt = mnts_lookup_mount(path);
|
|
|
9a499a |
+ if (mnt && mnt->flags & MNTS_AUTOFS)
|
|
|
9a499a |
+ return mnt;
|
|
|
9a499a |
+ mnts_put_mount(mnt);
|
|
|
9a499a |
+ return NULL;
|
|
|
9a499a |
+}
|
|
|
9a499a |
+
|
|
|
9a499a |
+struct mnt_list *mnts_add_submount(struct autofs_point *ap)
|
|
|
9a499a |
+{
|
|
|
9a499a |
+ struct mnt_list *this;
|
|
|
9a499a |
+
|
|
|
9a499a |
+ mnts_hash_mutex_lock();
|
|
|
9a499a |
+ this = mnts_get_mount(ap->path);
|
|
|
9a499a |
+ if (this) {
|
|
|
9a499a |
+ if (!this->ap)
|
|
|
9a499a |
+ this->ap = ap;
|
|
|
9a499a |
+ else if (this->ap != ap ||
|
|
|
9a499a |
+ this->ap->parent != ap->parent) {
|
|
|
9a499a |
+ __mnts_put_mount(this);
|
|
|
9a499a |
+ mnts_hash_mutex_unlock();
|
|
|
9a499a |
+ error(ap->logopt,
|
|
|
9a499a |
+ "conflict with submount owner: %s", ap->path);
|
|
|
9a499a |
+ goto fail;
|
|
|
9a499a |
+ }
|
|
|
9a499a |
+ this->flags |= MNTS_AUTOFS;
|
|
|
9a499a |
+ if (list_empty(&this->submount))
|
|
|
9a499a |
+ list_add_tail(&this->submount, &ap->parent->submounts);
|
|
|
9a499a |
+ }
|
|
|
9a499a |
+ mnts_hash_mutex_unlock();
|
|
|
9a499a |
+fail:
|
|
|
9a499a |
+ return this;
|
|
|
9a499a |
+}
|
|
|
9a499a |
+
|
|
|
9a499a |
+void mnts_remove_submount(const char *mp)
|
|
|
9a499a |
+{
|
|
|
9a499a |
+ struct mnt_list *this;
|
|
|
9a499a |
+
|
|
|
9a499a |
+ mnts_hash_mutex_lock();
|
|
|
9a499a |
+ this = mnts_lookup(mp);
|
|
|
9a499a |
+ if (this && this->flags & MNTS_AUTOFS) {
|
|
|
9a499a |
+ this->flags &= ~MNTS_AUTOFS;
|
|
|
9a499a |
+ this->ap = NULL;
|
|
|
9a499a |
+ list_del_init(&this->submount);
|
|
|
9a499a |
+ __mnts_put_mount(this);
|
|
|
9a499a |
+ }
|
|
|
9a499a |
+ mnts_hash_mutex_unlock();
|
|
|
9a499a |
+}
|
|
|
9a499a |
+
|
|
|
9a499a |
+void mnts_get_submount_list(struct list_head *mnts, struct autofs_point *ap)
|
|
|
9a499a |
+{
|
|
|
9a499a |
+ struct mnt_list *mnt;
|
|
|
9a499a |
+
|
|
|
9a499a |
+ mnts_hash_mutex_lock();
|
|
|
9a499a |
+ if (list_empty(&ap->submounts))
|
|
|
9a499a |
+ goto done;
|
|
|
9a499a |
+ list_for_each_entry(mnt, &ap->submounts, submount) {
|
|
|
9a499a |
+ __mnts_get_mount(mnt);
|
|
|
9a499a |
+ list_add(&mnt->submount_work, mnts);
|
|
|
9a499a |
+ }
|
|
|
9a499a |
+done:
|
|
|
9a499a |
+ mnts_hash_mutex_unlock();
|
|
|
9a499a |
+}
|
|
|
9a499a |
+
|
|
|
9a499a |
+void mnts_put_submount_list(struct list_head *mnts)
|
|
|
9a499a |
+{
|
|
|
9a499a |
+ struct mnt_list *mnt, *tmp;
|
|
|
9a499a |
+
|
|
|
9a499a |
+ mnts_hash_mutex_lock();
|
|
|
9a499a |
+ list_for_each_entry_safe(mnt, tmp, mnts, submount_work) {
|
|
|
9a499a |
+ list_del_init(&mnt->submount_work);
|
|
|
9a499a |
+ __mnts_put_mount(mnt);
|
|
|
9a499a |
+ }
|
|
|
9a499a |
+ mnts_hash_mutex_unlock();
|
|
|
9a499a |
+}
|
|
|
9a499a |
+
|
|
|
9a499a |
/* From glibc decode_name() */
|
|
|
9a499a |
/* Since the values in a line are separated by spaces, a name cannot
|
|
|
9a499a |
* contain a space. Therefore some programs encode spaces in names
|
|
|
9a499a |
--- autofs-5.1.4.orig/modules/mount_autofs.c
|
|
|
9a499a |
+++ autofs-5.1.4/modules/mount_autofs.c
|
|
|
9a499a |
@@ -65,6 +65,7 @@ int mount_mount(struct autofs_point *ap,
|
|
|
9a499a |
struct master_mapent *entry;
|
|
|
9a499a |
struct map_source *source;
|
|
|
9a499a |
struct autofs_point *nap;
|
|
|
9a499a |
+ struct mnt_list *mnt;
|
|
|
9a499a |
char buf[MAX_ERR_BUF];
|
|
|
9a499a |
char *options, *p;
|
|
|
9a499a |
int len, ret;
|
|
|
9a499a |
@@ -307,6 +308,18 @@ int mount_mount(struct autofs_point *ap,
|
|
|
9a499a |
return 1;
|
|
|
9a499a |
}
|
|
|
9a499a |
|
|
|
9a499a |
+ mnt = mnts_add_submount(nap);
|
|
|
9a499a |
+ if (!mnt) {
|
|
|
9a499a |
+ crit(ap->logopt,
|
|
|
9a499a |
+ MODPREFIX "failed to allocate mount %s", realpath);
|
|
|
9a499a |
+ handle_mounts_startup_cond_destroy(&suc);
|
|
|
9a499a |
+ mounts_mutex_unlock(ap);
|
|
|
9a499a |
+ master_free_map_source(source, 1);
|
|
|
9a499a |
+ master_free_mapent(entry);
|
|
|
9a499a |
+ return 1;
|
|
|
9a499a |
+ }
|
|
|
9a499a |
+
|
|
|
9a499a |
+
|
|
|
9a499a |
suc.ap = nap;
|
|
|
9a499a |
suc.root = mountpoint;
|
|
|
9a499a |
suc.done = 0;
|
|
|
9a499a |
@@ -318,6 +331,7 @@ int mount_mount(struct autofs_point *ap,
|
|
|
9a499a |
"failed to create mount handler thread for %s",
|
|
|
9a499a |
realpath);
|
|
|
9a499a |
handle_mounts_startup_cond_destroy(&suc);
|
|
|
9a499a |
+ mnts_remove_submount(nap->path);
|
|
|
9a499a |
mounts_mutex_unlock(ap);
|
|
|
9a499a |
master_free_map_source(source, 1);
|
|
|
9a499a |
master_free_mapent(entry);
|
|
|
9a499a |
@@ -328,6 +342,7 @@ int mount_mount(struct autofs_point *ap,
|
|
|
9a499a |
status = pthread_cond_wait(&suc.cond, &suc.mutex);
|
|
|
9a499a |
if (status) {
|
|
|
9a499a |
handle_mounts_startup_cond_destroy(&suc);
|
|
|
9a499a |
+ mnts_remove_submount(nap->path);
|
|
|
9a499a |
mounts_mutex_unlock(ap);
|
|
|
9a499a |
master_free_map_source(source, 1);
|
|
|
9a499a |
master_free_mapent(entry);
|
|
|
9a499a |
@@ -339,6 +354,7 @@ int mount_mount(struct autofs_point *ap,
|
|
|
9a499a |
crit(ap->logopt,
|
|
|
9a499a |
MODPREFIX "failed to create submount for %s", realpath);
|
|
|
9a499a |
handle_mounts_startup_cond_destroy(&suc);
|
|
|
9a499a |
+ mnts_remove_submount(nap->path);
|
|
|
9a499a |
mounts_mutex_unlock(ap);
|
|
|
9a499a |
master_free_map_source(source, 1);
|
|
|
9a499a |
master_free_mapent(entry);
|
|
|
9a499a |
@@ -347,7 +363,6 @@ int mount_mount(struct autofs_point *ap,
|
|
|
9a499a |
nap->thid = thid;
|
|
|
9a499a |
|
|
|
9a499a |
ap->submnt_count++;
|
|
|
9a499a |
- list_add(&nap->mounts, &ap->submounts);
|
|
|
9a499a |
|
|
|
9a499a |
handle_mounts_startup_cond_destroy(&suc);
|
|
|
9a499a |
mounts_mutex_unlock(ap);
|