|
|
23b4c9 |
autofs-5.1.2 - use autofs_point to store expire timeout where possibe
|
|
|
23b4c9 |
|
|
|
23b4c9 |
From: Ian Kent <raven@themaw.net>
|
|
|
23b4c9 |
|
|
|
23b4c9 |
For technical reasons the expire timeout is stored in the map entry source
|
|
|
23b4c9 |
rather than the struct autofs_point and must be stored in the map source for
|
|
|
23b4c9 |
direct (and offset) mounts.
|
|
|
23b4c9 |
|
|
|
23b4c9 |
But with the map source re-use needed by amd format type "auto" mounts the
|
|
|
23b4c9 |
timeout can't be stored in the map source since the it may be different for
|
|
|
23b4c9 |
mounts that share the map source.
|
|
|
23b4c9 |
|
|
|
23b4c9 |
So use the struct autofs_point where possible.
|
|
|
23b4c9 |
|
|
|
23b4c9 |
Signed-off-by: Ian Kent <raven@themaw.net>
|
|
|
23b4c9 |
---
|
|
|
23b4c9 |
CHANGELOG | 1 +
|
|
|
23b4c9 |
daemon/direct.c | 6 +++---
|
|
|
23b4c9 |
daemon/indirect.c | 2 +-
|
|
|
23b4c9 |
daemon/state.c | 12 +++++++-----
|
|
|
23b4c9 |
include/automount.h | 1 +
|
|
|
23b4c9 |
include/mounts.h | 2 ++
|
|
|
23b4c9 |
lib/master.c | 5 ++++-
|
|
|
23b4c9 |
lib/master_parse.y | 27 +++++++++++++--------------
|
|
|
23b4c9 |
lib/mounts.c | 27 +++++++++++++++++++++------
|
|
|
23b4c9 |
modules/mount_autofs.c | 12 ++++--------
|
|
|
23b4c9 |
10 files changed, 57 insertions(+), 38 deletions(-)
|
|
|
23b4c9 |
|
|
|
23b4c9 |
--- autofs-5.0.7.orig/CHANGELOG
|
|
|
23b4c9 |
+++ autofs-5.0.7/CHANGELOG
|
|
|
23b4c9 |
@@ -242,6 +242,7 @@
|
|
|
23b4c9 |
- add config option to use mount request log id.
|
|
|
23b4c9 |
- work around sss startup delay.
|
|
|
23b4c9 |
- add sss master map wait config option.
|
|
|
23b4c9 |
+- use autofs_point to store expire timeout where possibe.
|
|
|
23b4c9 |
|
|
|
23b4c9 |
25/07/2012 autofs-5.0.7
|
|
|
23b4c9 |
=======================
|
|
|
23b4c9 |
--- autofs-5.0.7.orig/daemon/direct.c
|
|
|
23b4c9 |
+++ autofs-5.0.7/daemon/direct.c
|
|
|
23b4c9 |
@@ -312,7 +312,7 @@ static int unlink_active_mounts(struct a
|
|
|
23b4c9 |
|
|
|
23b4c9 |
if (tree_get_mnt_list(mnts, &list, me->key, 1)) {
|
|
|
23b4c9 |
if (ap->state == ST_READMAP) {
|
|
|
23b4c9 |
- time_t tout = me->source->exp_timeout;
|
|
|
23b4c9 |
+ time_t tout = get_exp_timeout(ap, me->source);
|
|
|
23b4c9 |
int save_ioctlfd, ioctlfd;
|
|
|
23b4c9 |
|
|
|
23b4c9 |
save_ioctlfd = ioctlfd = me->ioctlfd;
|
|
|
23b4c9 |
@@ -518,7 +518,7 @@ int mount_autofs_direct(struct autofs_po
|
|
|
23b4c9 |
}
|
|
|
23b4c9 |
|
|
|
23b4c9 |
mc = map->mc;
|
|
|
23b4c9 |
- timeout = map->exp_timeout;
|
|
|
23b4c9 |
+ timeout = get_exp_timeout(ap, map);
|
|
|
23b4c9 |
cache_readlock(mc);
|
|
|
23b4c9 |
pthread_cleanup_push(cache_lock_cleanup, mc);
|
|
|
23b4c9 |
me = cache_enumerate(mc, NULL);
|
|
|
23b4c9 |
@@ -674,7 +674,7 @@ int mount_autofs_offset(struct autofs_po
|
|
|
23b4c9 |
struct ioctl_ops *ops = get_ioctl_ops();
|
|
|
23b4c9 |
char buf[MAX_ERR_BUF];
|
|
|
23b4c9 |
struct mnt_params *mp;
|
|
|
23b4c9 |
- time_t timeout = me->source->exp_timeout;
|
|
|
23b4c9 |
+ time_t timeout = get_exp_timeout(ap, me->source);
|
|
|
23b4c9 |
struct stat st;
|
|
|
23b4c9 |
int ioctlfd, status, ret;
|
|
|
23b4c9 |
const char *hosts_map_name = "-hosts";
|
|
|
23b4c9 |
--- autofs-5.0.7.orig/daemon/indirect.c
|
|
|
23b4c9 |
+++ autofs-5.0.7/daemon/indirect.c
|
|
|
23b4c9 |
@@ -87,7 +87,7 @@ static int do_mount_autofs_indirect(stru
|
|
|
23b4c9 |
{
|
|
|
23b4c9 |
const char *str_indirect = mount_type_str(t_indirect);
|
|
|
23b4c9 |
struct ioctl_ops *ops = get_ioctl_ops();
|
|
|
23b4c9 |
- time_t timeout = ap->entry->maps->exp_timeout;
|
|
|
23b4c9 |
+ time_t timeout = get_exp_timeout(ap, ap->entry->maps);
|
|
|
23b4c9 |
char *options = NULL;
|
|
|
23b4c9 |
const char *hosts_map_name = "-hosts";
|
|
|
23b4c9 |
const char *map_name = hosts_map_name;
|
|
|
23b4c9 |
--- autofs-5.0.7.orig/daemon/state.c
|
|
|
23b4c9 |
+++ autofs-5.0.7/daemon/state.c
|
|
|
23b4c9 |
@@ -407,6 +407,7 @@ static void do_readmap_mount(struct auto
|
|
|
23b4c9 |
if (valid) {
|
|
|
23b4c9 |
struct mapent_cache *vmc = valid->mc;
|
|
|
23b4c9 |
struct ioctl_ops *ops = get_ioctl_ops();
|
|
|
23b4c9 |
+ time_t timeout;
|
|
|
23b4c9 |
time_t runfreq;
|
|
|
23b4c9 |
|
|
|
23b4c9 |
cache_unlock(vmc);
|
|
|
23b4c9 |
@@ -428,9 +429,10 @@ static void do_readmap_mount(struct auto
|
|
|
23b4c9 |
cache_set_ino_index(vmc, me->key, me->dev, me->ino);
|
|
|
23b4c9 |
cache_unlock(vmc);
|
|
|
23b4c9 |
/* Set timeout and calculate the expire run frequency */
|
|
|
23b4c9 |
- ops->timeout(ap->logopt, valid->ioctlfd, map->exp_timeout);
|
|
|
23b4c9 |
- if (map->exp_timeout) {
|
|
|
23b4c9 |
- runfreq = (map->exp_timeout + CHECK_RATIO - 1) / CHECK_RATIO;
|
|
|
23b4c9 |
+ timeout = get_exp_timeout(ap, map);
|
|
|
23b4c9 |
+ ops->timeout(ap->logopt, valid->ioctlfd, timeout);
|
|
|
23b4c9 |
+ if (timeout) {
|
|
|
23b4c9 |
+ runfreq = (timeout + CHECK_RATIO - 1) / CHECK_RATIO;
|
|
|
23b4c9 |
if (ap->exp_runfreq)
|
|
|
23b4c9 |
ap->exp_runfreq = min(ap->exp_runfreq, runfreq);
|
|
|
23b4c9 |
else
|
|
|
23b4c9 |
@@ -442,7 +444,7 @@ static void do_readmap_mount(struct auto
|
|
|
23b4c9 |
debug(ap->logopt,
|
|
|
23b4c9 |
"%s is mounted", me->key);
|
|
|
23b4c9 |
} else
|
|
|
23b4c9 |
- do_mount_autofs_direct(ap, mnts, me, map->exp_timeout);
|
|
|
23b4c9 |
+ do_mount_autofs_direct(ap, mnts, me, get_exp_timeout(ap, map));
|
|
|
23b4c9 |
|
|
|
23b4c9 |
return;
|
|
|
23b4c9 |
}
|
|
|
23b4c9 |
@@ -491,7 +493,7 @@ static void *do_readmap(void *arg)
|
|
|
23b4c9 |
|
|
|
23b4c9 |
if (ap->type == LKP_INDIRECT) {
|
|
|
23b4c9 |
struct ioctl_ops *ops = get_ioctl_ops();
|
|
|
23b4c9 |
- time_t timeout = ap->entry->maps->exp_timeout;
|
|
|
23b4c9 |
+ time_t timeout = get_exp_timeout(ap, ap->entry->maps);
|
|
|
23b4c9 |
ap->exp_runfreq = (timeout + CHECK_RATIO - 1) / CHECK_RATIO;
|
|
|
23b4c9 |
ops->timeout(ap->logopt, ap->ioctlfd, timeout);
|
|
|
23b4c9 |
lookup_prune_cache(ap, now);
|
|
|
23b4c9 |
--- autofs-5.0.7.orig/include/automount.h
|
|
|
23b4c9 |
+++ autofs-5.0.7/include/automount.h
|
|
|
23b4c9 |
@@ -527,6 +527,7 @@ struct autofs_point {
|
|
|
23b4c9 |
dev_t dev; /* "Device" number assigned by kernel */
|
|
|
23b4c9 |
struct master_mapent *entry; /* Master map entry for this mount */
|
|
|
23b4c9 |
unsigned int type; /* Type of map direct or indirect */
|
|
|
23b4c9 |
+ time_t exp_timeout; /* Indirect mount expire timeout */
|
|
|
23b4c9 |
time_t exp_runfreq; /* Frequency for polling for timeouts */
|
|
|
23b4c9 |
time_t negative_timeout; /* timeout in secs for failed mounts */
|
|
|
23b4c9 |
unsigned int flags; /* autofs mount flags */
|
|
|
23b4c9 |
--- autofs-5.0.7.orig/include/mounts.h
|
|
|
23b4c9 |
+++ autofs-5.0.7/include/mounts.h
|
|
|
23b4c9 |
@@ -112,6 +112,8 @@ int tree_find_mnt_ents(struct mnt_list *
|
|
|
23b4c9 |
int tree_is_mounted(struct mnt_list *mnts, const char *path, unsigned int type);
|
|
|
23b4c9 |
void set_tsd_user_vars(unsigned int, uid_t, gid_t);
|
|
|
23b4c9 |
const char *mount_type_str(unsigned int);
|
|
|
23b4c9 |
+void set_exp_timeout(struct autofs_point *ap, struct map_source *source, time_t timeout);
|
|
|
23b4c9 |
+time_t get_exp_timeout(struct autofs_point *ap, struct map_source *source);
|
|
|
23b4c9 |
void notify_mount_result(struct autofs_point *, const char *, time_t, const char *);
|
|
|
23b4c9 |
int try_remount(struct autofs_point *, struct mapent *, unsigned int);
|
|
|
23b4c9 |
void set_indirect_mount_tree_catatonic(struct autofs_point *);
|
|
|
23b4c9 |
--- autofs-5.0.7.orig/lib/master.c
|
|
|
23b4c9 |
+++ autofs-5.0.7/lib/master.c
|
|
|
23b4c9 |
@@ -99,6 +99,7 @@ int master_add_autofs_point(struct maste
|
|
|
23b4c9 |
ap->negative_timeout = defaults_get_negative_timeout();
|
|
|
23b4c9 |
else
|
|
|
23b4c9 |
ap->negative_timeout = global_negative_timeout;
|
|
|
23b4c9 |
+ ap->exp_timeout = defaults_get_timeout();
|
|
|
23b4c9 |
ap->exp_runfreq = 0;
|
|
|
23b4c9 |
ap->flags = 0;
|
|
|
23b4c9 |
if (ghost)
|
|
|
23b4c9 |
@@ -980,6 +981,7 @@ static void master_add_amd_mount_section
|
|
|
23b4c9 |
while (paths[i]) {
|
|
|
23b4c9 |
const char *path = paths[i];
|
|
|
23b4c9 |
unsigned int ghost = 0;
|
|
|
23b4c9 |
+ time_t timeout;
|
|
|
23b4c9 |
char *type = NULL;
|
|
|
23b4c9 |
char *map = NULL;
|
|
|
23b4c9 |
char *opts;
|
|
|
23b4c9 |
@@ -1065,7 +1067,8 @@ static void master_add_amd_mount_section
|
|
|
23b4c9 |
goto next;
|
|
|
23b4c9 |
}
|
|
|
23b4c9 |
|
|
|
23b4c9 |
- source->exp_timeout = conf_amd_get_dismount_interval(path);
|
|
|
23b4c9 |
+ timeout = conf_amd_get_dismount_interval(path);
|
|
|
23b4c9 |
+ set_exp_timeout(entry->ap, source, timeout);
|
|
|
23b4c9 |
source->master_line = 0;
|
|
|
23b4c9 |
|
|
|
23b4c9 |
entry->age = age;
|
|
|
23b4c9 |
--- autofs-5.0.7.orig/lib/master_parse.y
|
|
|
23b4c9 |
+++ autofs-5.0.7/lib/master_parse.y
|
|
|
23b4c9 |
@@ -823,19 +823,6 @@ int master_parse_entry(const char *buffe
|
|
|
23b4c9 |
ghost = 1;
|
|
|
23b4c9 |
}
|
|
|
23b4c9 |
|
|
|
23b4c9 |
- if (timeout < 0) {
|
|
|
23b4c9 |
- /*
|
|
|
23b4c9 |
- * If no timeout is given get the timout from the
|
|
|
23b4c9 |
- * first map (if it exists) or the config for amd
|
|
|
23b4c9 |
- * maps.
|
|
|
23b4c9 |
- */
|
|
|
23b4c9 |
- if (format && !strcmp(format, "amd"))
|
|
|
23b4c9 |
- timeout = conf_amd_get_dismount_interval(path);
|
|
|
23b4c9 |
- else if (entry->maps)
|
|
|
23b4c9 |
- timeout = entry->maps->exp_timeout;
|
|
|
23b4c9 |
- else
|
|
|
23b4c9 |
- timeout = default_timeout;
|
|
|
23b4c9 |
- }
|
|
|
23b4c9 |
|
|
|
23b4c9 |
if (!entry->ap) {
|
|
|
23b4c9 |
ret = master_add_autofs_point(entry, logopt, nobind, ghost, 0);
|
|
|
23b4c9 |
@@ -856,6 +843,18 @@ int master_parse_entry(const char *buffe
|
|
|
23b4c9 |
if (negative_timeout)
|
|
|
23b4c9 |
entry->ap->negative_timeout = negative_timeout;
|
|
|
23b4c9 |
|
|
|
23b4c9 |
+ if (timeout < 0) {
|
|
|
23b4c9 |
+ /*
|
|
|
23b4c9 |
+ * If no timeout is given get the timout from the
|
|
|
23b4c9 |
+ * autofs point, or the first map, or the config
|
|
|
23b4c9 |
+ * for amd maps.
|
|
|
23b4c9 |
+ */
|
|
|
23b4c9 |
+ if (format && !strcmp(format, "amd"))
|
|
|
23b4c9 |
+ timeout = conf_amd_get_dismount_interval(path);
|
|
|
23b4c9 |
+ else
|
|
|
23b4c9 |
+ timeout = get_exp_timeout(entry->ap, entry->maps);
|
|
|
23b4c9 |
+ }
|
|
|
23b4c9 |
+
|
|
|
23b4c9 |
if (format && !strcmp(format, "amd")) {
|
|
|
23b4c9 |
char *opts = conf_amd_get_map_options(path);
|
|
|
23b4c9 |
if (opts) {
|
|
|
23b4c9 |
@@ -890,7 +889,7 @@ int master_parse_entry(const char *buffe
|
|
|
23b4c9 |
local_free_vars();
|
|
|
23b4c9 |
return 0;
|
|
|
23b4c9 |
}
|
|
|
23b4c9 |
- source->exp_timeout = timeout;
|
|
|
23b4c9 |
+ set_exp_timeout(entry->ap, source, timeout);
|
|
|
23b4c9 |
source->master_line = lineno;
|
|
|
23b4c9 |
|
|
|
23b4c9 |
entry->age = age;
|
|
|
23b4c9 |
--- autofs-5.0.7.orig/lib/mounts.c
|
|
|
23b4c9 |
+++ autofs-5.0.7/lib/mounts.c
|
|
|
23b4c9 |
@@ -1616,6 +1616,24 @@ const char *mount_type_str(const unsigne
|
|
|
23b4c9 |
return (pos == type_count ? NULL : str_type[pos]);
|
|
|
23b4c9 |
}
|
|
|
23b4c9 |
|
|
|
23b4c9 |
+void set_exp_timeout(struct autofs_point *ap,
|
|
|
23b4c9 |
+ struct map_source *source, time_t timeout)
|
|
|
23b4c9 |
+{
|
|
|
23b4c9 |
+ ap->exp_timeout = timeout;
|
|
|
23b4c9 |
+ if (source)
|
|
|
23b4c9 |
+ source->exp_timeout = timeout;
|
|
|
23b4c9 |
+}
|
|
|
23b4c9 |
+
|
|
|
23b4c9 |
+time_t get_exp_timeout(struct autofs_point *ap, struct map_source *source)
|
|
|
23b4c9 |
+{
|
|
|
23b4c9 |
+ time_t timeout = ap->exp_timeout;
|
|
|
23b4c9 |
+
|
|
|
23b4c9 |
+ if (source && ap->type == LKP_DIRECT)
|
|
|
23b4c9 |
+ timeout = source->exp_timeout;
|
|
|
23b4c9 |
+
|
|
|
23b4c9 |
+ return timeout;
|
|
|
23b4c9 |
+}
|
|
|
23b4c9 |
+
|
|
|
23b4c9 |
void notify_mount_result(struct autofs_point *ap,
|
|
|
23b4c9 |
const char *path, time_t timeout, const char *type)
|
|
|
23b4c9 |
{
|
|
|
23b4c9 |
@@ -1747,12 +1765,9 @@ static int remount_active_mount(struct a
|
|
|
23b4c9 |
ops->open(ap->logopt, &fd, devid, path);
|
|
|
23b4c9 |
if (fd == -1)
|
|
|
23b4c9 |
return REMOUNT_OPEN_FAIL;
|
|
|
23b4c9 |
- else {
|
|
|
23b4c9 |
- if (type == t_indirect || type == t_offset)
|
|
|
23b4c9 |
- timeout = ap->entry->maps->exp_timeout;
|
|
|
23b4c9 |
- else
|
|
|
23b4c9 |
- timeout = me->source->exp_timeout;
|
|
|
23b4c9 |
- }
|
|
|
23b4c9 |
+
|
|
|
23b4c9 |
+ error(ap->logopt, "ap->type %d type %u", ap->type, type);
|
|
|
23b4c9 |
+ timeout = get_exp_timeout(ap, me->source);
|
|
|
23b4c9 |
|
|
|
23b4c9 |
/* Re-reading the map, set timeout and return */
|
|
|
23b4c9 |
if (ap->state == ST_READMAP) {
|
|
|
23b4c9 |
--- autofs-5.0.7.orig/modules/mount_autofs.c
|
|
|
23b4c9 |
+++ autofs-5.0.7/modules/mount_autofs.c
|
|
|
23b4c9 |
@@ -57,7 +57,7 @@ int mount_mount(struct autofs_point *ap,
|
|
|
23b4c9 |
int nobind = ap->flags & MOUNT_FLAG_NOBIND;
|
|
|
23b4c9 |
int ghost = ap->flags & MOUNT_FLAG_GHOST;
|
|
|
23b4c9 |
int symlnk = ap->flags & MOUNT_FLAG_SYMLINK;
|
|
|
23b4c9 |
- time_t timeout = ap->entry->maps->exp_timeout;
|
|
|
23b4c9 |
+ time_t timeout = get_exp_timeout(ap, ap->entry->maps);
|
|
|
23b4c9 |
unsigned logopt = ap->logopt;
|
|
|
23b4c9 |
struct map_type_info *info;
|
|
|
23b4c9 |
struct master *master;
|
|
|
23b4c9 |
@@ -272,13 +272,9 @@ int mount_mount(struct autofs_point *ap,
|
|
|
23b4c9 |
return 1;
|
|
|
23b4c9 |
}
|
|
|
23b4c9 |
free_map_type_info(info);
|
|
|
23b4c9 |
- /* The exp_timeout can't be inherited if the map is shared, so
|
|
|
23b4c9 |
- * the autofs point exp_runfreq must be set here.
|
|
|
23b4c9 |
- */
|
|
|
23b4c9 |
- if (source->ref <= 1)
|
|
|
23b4c9 |
- source->exp_timeout = timeout;
|
|
|
23b4c9 |
- else
|
|
|
23b4c9 |
- nap->exp_runfreq = (timeout + CHECK_RATIO - 1) / CHECK_RATIO;
|
|
|
23b4c9 |
+
|
|
|
23b4c9 |
+ set_exp_timeout(nap, NULL, timeout);
|
|
|
23b4c9 |
+ nap->exp_runfreq = (timeout + CHECK_RATIO - 1) / CHECK_RATIO;
|
|
|
23b4c9 |
|
|
|
23b4c9 |
mounts_mutex_lock(ap);
|
|
|
23b4c9 |
|