|
|
9a499a |
autofs-5.1.7 - don't add offset mounts to mounted mounts table
|
|
|
9a499a |
|
|
|
9a499a |
From: Ian Kent <raven@themaw.net>
|
|
|
9a499a |
|
|
|
9a499a |
Multi-mount offset mounts are added to the mounted mounts table whether
|
|
|
9a499a |
they have a real mount or not. If there are a large number of offsets
|
|
|
9a499a |
this can add unnecessary overhead to the mounted mounts table processing.
|
|
|
9a499a |
|
|
|
9a499a |
Signed-off-by: Ian Kent <raven@themaw.net>
|
|
|
9a499a |
---
|
|
|
9a499a |
CHANGELOG | 1 +
|
|
|
9a499a |
daemon/direct.c | 14 ++++----------
|
|
|
9a499a |
daemon/indirect.c | 4 +++-
|
|
|
9a499a |
include/mounts.h | 2 +-
|
|
|
9a499a |
lib/mounts.c | 43 +++++++++++--------------------------------
|
|
|
9a499a |
5 files changed, 20 insertions(+), 44 deletions(-)
|
|
|
9a499a |
|
|
|
9a499a |
--- autofs-5.1.4.orig/CHANGELOG
|
|
|
9a499a |
+++ autofs-5.1.4/CHANGELOG
|
|
|
9a499a |
@@ -21,6 +21,7 @@
|
|
|
9a499a |
- remove unused mount offset list lock functions.
|
|
|
9a499a |
- eliminate count_mounts() from expire_proc_indirect().
|
|
|
9a499a |
- eliminate some strlen calls in offset handling.
|
|
|
9a499a |
+- don't add offset mounts to mounted mounts table.
|
|
|
9a499a |
|
|
|
9a499a |
xx/xx/2018 autofs-5.1.5
|
|
|
9a499a |
- fix flag file permission.
|
|
|
9a499a |
--- autofs-5.1.4.orig/daemon/direct.c
|
|
|
9a499a |
+++ autofs-5.1.4/daemon/direct.c
|
|
|
9a499a |
@@ -605,9 +605,6 @@ force_umount:
|
|
|
9a499a |
} else
|
|
|
9a499a |
info(ap->logopt, "umounted offset mount %s", me->key);
|
|
|
9a499a |
|
|
|
9a499a |
- if (!rv)
|
|
|
9a499a |
- mnts_remove_mount(me->key, MNTS_OFFSET);
|
|
|
9a499a |
-
|
|
|
9a499a |
return rv;
|
|
|
9a499a |
}
|
|
|
9a499a |
|
|
|
9a499a |
@@ -761,12 +758,6 @@ int mount_autofs_offset(struct autofs_po
|
|
|
9a499a |
notify_mount_result(ap, me->key, timeout, str_offset);
|
|
|
9a499a |
ops->close(ap->logopt, ioctlfd);
|
|
|
9a499a |
|
|
|
9a499a |
- mnt = mnts_add_mount(ap, me->key, MNTS_OFFSET);
|
|
|
9a499a |
- if (!mnt)
|
|
|
9a499a |
- error(ap->logopt,
|
|
|
9a499a |
- "failed to add offset mount %s to mounted list",
|
|
|
9a499a |
- me->key);
|
|
|
9a499a |
-
|
|
|
9a499a |
debug(ap->logopt, "mounted trigger %s", me->key);
|
|
|
9a499a |
|
|
|
9a499a |
return MOUNT_OFFSET_OK;
|
|
|
9a499a |
@@ -1214,6 +1205,7 @@ static void *do_mount_direct(void *arg)
|
|
|
9a499a |
struct mapent *me;
|
|
|
9a499a |
struct statfs fs;
|
|
|
9a499a |
unsigned int close_fd = 0;
|
|
|
9a499a |
+ unsigned int flags = MNTS_DIRECT|MNTS_MOUNTED;
|
|
|
9a499a |
|
|
|
9a499a |
sbmnt = mnts_find_submount(mt.name);
|
|
|
9a499a |
if (statfs(mt.name, &fs) == -1 ||
|
|
|
9a499a |
@@ -1232,6 +1224,8 @@ static void *do_mount_direct(void *arg)
|
|
|
9a499a |
close_fd = 0;
|
|
|
9a499a |
if (!close_fd)
|
|
|
9a499a |
me->ioctlfd = mt.ioctlfd;
|
|
|
9a499a |
+ if (me->multi && me->multi != me)
|
|
|
9a499a |
+ flags |= MNTS_OFFSET;
|
|
|
9a499a |
}
|
|
|
9a499a |
ops->send_ready(ap->logopt, mt.ioctlfd, mt.wait_queue_token);
|
|
|
9a499a |
cache_unlock(mt.mc);
|
|
|
9a499a |
@@ -1240,7 +1234,7 @@ static void *do_mount_direct(void *arg)
|
|
|
9a499a |
|
|
|
9a499a |
info(ap->logopt, "mounted %s", mt.name);
|
|
|
9a499a |
|
|
|
9a499a |
- mnts_set_mounted_mount(ap, mt.name);
|
|
|
9a499a |
+ mnts_set_mounted_mount(ap, mt.name, flags);
|
|
|
9a499a |
|
|
|
9a499a |
conditional_alarm_add(ap, ap->exp_runfreq);
|
|
|
9a499a |
} else {
|
|
|
9a499a |
--- autofs-5.1.4.orig/daemon/indirect.c
|
|
|
9a499a |
+++ autofs-5.1.4/daemon/indirect.c
|
|
|
9a499a |
@@ -747,12 +747,14 @@ static void *do_mount_indirect(void *arg
|
|
|
9a499a |
status = lookup_nss_mount(ap, NULL, mt.name, mt.len);
|
|
|
9a499a |
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &state);
|
|
|
9a499a |
if (status) {
|
|
|
9a499a |
+ unsigned int flags = MNTS_INDIRECT|MNTS_MOUNTED;
|
|
|
9a499a |
+
|
|
|
9a499a |
ops->send_ready(ap->logopt,
|
|
|
9a499a |
ap->ioctlfd, mt.wait_queue_token);
|
|
|
9a499a |
|
|
|
9a499a |
info(ap->logopt, "mounted %s", buf);
|
|
|
9a499a |
|
|
|
9a499a |
- mnts_set_mounted_mount(ap, mt.name);
|
|
|
9a499a |
+ mnts_set_mounted_mount(ap, mt.name, flags);
|
|
|
9a499a |
|
|
|
9a499a |
conditional_alarm_add(ap, ap->exp_runfreq);
|
|
|
9a499a |
} else {
|
|
|
9a499a |
--- autofs-5.1.4.orig/include/mounts.h
|
|
|
9a499a |
+++ autofs-5.1.4/include/mounts.h
|
|
|
9a499a |
@@ -131,7 +131,7 @@ struct mnt_list *get_mnt_list(const char
|
|
|
9a499a |
unsigned int mnts_has_mounted_mounts(struct autofs_point *ap);
|
|
|
9a499a |
void mnts_get_expire_list(struct list_head *mnts, struct autofs_point *ap);
|
|
|
9a499a |
void mnts_put_expire_list(struct list_head *mnts);
|
|
|
9a499a |
-void mnts_set_mounted_mount(struct autofs_point *ap, const char *name);
|
|
|
9a499a |
+void mnts_set_mounted_mount(struct autofs_point *ap, const char *name, unsigned int flags);
|
|
|
9a499a |
int unlink_mount_tree(struct autofs_point *ap, const char *mp);
|
|
|
9a499a |
void free_mnt_list(struct mnt_list *list);
|
|
|
9a499a |
int is_mounted(const char *mp, unsigned int type);
|
|
|
9a499a |
--- autofs-5.1.4.orig/lib/mounts.c
|
|
|
9a499a |
+++ autofs-5.1.4/lib/mounts.c
|
|
|
9a499a |
@@ -1172,7 +1172,7 @@ struct mnt_list *mnts_add_mount(struct a
|
|
|
9a499a |
this = mnts_get_mount(mp);
|
|
|
9a499a |
if (this) {
|
|
|
9a499a |
this->flags |= flags;
|
|
|
9a499a |
- if (list_empty(&this->mount))
|
|
|
9a499a |
+ if ((this->flags & MNTS_MOUNTED) && list_empty(&this->mount))
|
|
|
9a499a |
list_add(&this->mount, &ap->mounts);
|
|
|
9a499a |
}
|
|
|
9a499a |
mnts_hash_mutex_unlock();
|
|
|
9a499a |
@@ -1193,42 +1193,23 @@ void mnts_remove_mount(const char *mp, u
|
|
|
9a499a |
this = mnts_lookup(mp);
|
|
|
9a499a |
if (this && this->flags & flags) {
|
|
|
9a499a |
this->flags &= ~flags;
|
|
|
9a499a |
- if (!(this->flags & (MNTS_OFFSET|MNTS_MOUNTED)))
|
|
|
9a499a |
+ if (!(this->flags & MNTS_MOUNTED))
|
|
|
9a499a |
list_del_init(&this->mount);
|
|
|
9a499a |
__mnts_put_mount(this);
|
|
|
9a499a |
}
|
|
|
9a499a |
mnts_hash_mutex_unlock();
|
|
|
9a499a |
}
|
|
|
9a499a |
|
|
|
9a499a |
-void mnts_set_mounted_mount(struct autofs_point *ap, const char *name)
|
|
|
9a499a |
+void mnts_set_mounted_mount(struct autofs_point *ap, const char *name, unsigned int flags)
|
|
|
9a499a |
{
|
|
|
9a499a |
struct mnt_list *mnt;
|
|
|
9a499a |
|
|
|
9a499a |
- mnt = mnts_add_mount(ap, name, MNTS_MOUNTED);
|
|
|
9a499a |
+ mnt = mnts_add_mount(ap, name, flags);
|
|
|
9a499a |
if (!mnt) {
|
|
|
9a499a |
error(ap->logopt,
|
|
|
9a499a |
"failed to add mount %s to mounted list", name);
|
|
|
9a499a |
return;
|
|
|
9a499a |
}
|
|
|
9a499a |
-
|
|
|
9a499a |
- /* Offset mount failed but non-strict returns success */
|
|
|
9a499a |
- if (mnt->flags & MNTS_OFFSET &&
|
|
|
9a499a |
- !is_mounted(mnt->mp, MNTS_REAL)) {
|
|
|
9a499a |
- mnt->flags &= ~MNTS_MOUNTED;
|
|
|
9a499a |
- mnts_put_mount(mnt);
|
|
|
9a499a |
- }
|
|
|
9a499a |
-
|
|
|
9a499a |
- /* Housekeeping.
|
|
|
9a499a |
- * Set the base type of the mounted mount.
|
|
|
9a499a |
- * MNTS_AUTOFS and MNTS_OFFSET are set at mount time and
|
|
|
9a499a |
- * are used during expire.
|
|
|
9a499a |
- */
|
|
|
9a499a |
- if (!(mnt->flags & (MNTS_AUTOFS|MNTS_OFFSET))) {
|
|
|
9a499a |
- if (ap->type == LKP_INDIRECT)
|
|
|
9a499a |
- mnt->flags |= MNTS_INDIRECT;
|
|
|
9a499a |
- else
|
|
|
9a499a |
- mnt->flags |= MNTS_DIRECT;
|
|
|
9a499a |
- }
|
|
|
9a499a |
}
|
|
|
9a499a |
|
|
|
9a499a |
unsigned int mnts_has_mounted_mounts(struct autofs_point *ap)
|
|
|
9a499a |
@@ -1943,17 +1924,13 @@ static int do_remount_direct(struct auto
|
|
|
9a499a |
|
|
|
9a499a |
ret = lookup_nss_mount(ap, NULL, path, strlen(path));
|
|
|
9a499a |
if (ret) {
|
|
|
9a499a |
- struct mnt_list *mnt;
|
|
|
9a499a |
+ unsigned int flags = MNTS_DIRECT|MNTS_MOUNTED;
|
|
|
9a499a |
|
|
|
9a499a |
/* If it's an offset mount add a mount reference */
|
|
|
9a499a |
- if (type == t_offset) {
|
|
|
9a499a |
- mnt = mnts_add_mount(ap, path, MNTS_OFFSET);
|
|
|
9a499a |
- if (!mnt)
|
|
|
9a499a |
- error(ap->logopt,
|
|
|
9a499a |
- "failed to add mount %s to mounted list", path);
|
|
|
9a499a |
- }
|
|
|
9a499a |
+ if (type == t_offset)
|
|
|
9a499a |
+ flags |= MNTS_OFFSET;
|
|
|
9a499a |
|
|
|
9a499a |
- mnts_set_mounted_mount(ap, path);
|
|
|
9a499a |
+ mnts_set_mounted_mount(ap, path, flags);
|
|
|
9a499a |
|
|
|
9a499a |
info(ap->logopt, "re-connected to %s", path);
|
|
|
9a499a |
|
|
|
9a499a |
@@ -2028,7 +2005,9 @@ static int do_remount_indirect(struct au
|
|
|
9a499a |
|
|
|
9a499a |
ret = lookup_nss_mount(ap, NULL, de[n]->d_name, len);
|
|
|
9a499a |
if (ret) {
|
|
|
9a499a |
- mnts_set_mounted_mount(ap, buf);
|
|
|
9a499a |
+ unsigned int flags = MNTS_INDIRECT|MNTS_MOUNTED;
|
|
|
9a499a |
+
|
|
|
9a499a |
+ mnts_set_mounted_mount(ap, buf, flags);
|
|
|
9a499a |
|
|
|
9a499a |
info(ap->logopt, "re-connected to %s", buf);
|
|
|
9a499a |
|