autofs-5.0.1 - add mount wait parameter From: Ian Kent <raven@themaw.net> Often delays when trying to mount from a server that is not reponding for some reason are undesirable. To try and prevent these delays we provide a configuration setting to limit the time that we wait for our spawned mount(8) process to complete before sending it a SIGTERM signal. This patch adds a configuration parameter to allow us to request we limit the time we wait for mount(8) to complete before send it a TERM signal. --- daemon/spawn.c | 3 ++- include/defaults.h | 2 ++ lib/defaults.c | 13 +++++++++++++ man/auto.master.5.in | 7 +++++++ redhat/autofs.sysconfig.in | 9 +++++++++ samples/autofs.conf.default.in | 9 +++++++++ 6 files changed, 42 insertions(+), 1 deletion(-) --- autofs-5.0.1.orig/daemon/spawn.c +++ autofs-5.0.1/daemon/spawn.c @@ -312,6 +312,7 @@ int spawn_mount(unsigned logopt, ...) unsigned int options; unsigned int retries = MTAB_LOCK_RETRIES; int update_mtab = 1, ret, printed = 0; + unsigned int wait = defaults_get_mount_wait(); char buf[PATH_MAX]; /* If we use mount locking we can't validate the location */ @@ -353,7 +354,7 @@ int spawn_mount(unsigned logopt, ...) va_end(arg); while (retries--) { - ret = do_spawn(logopt, -1, options, prog, (const char **) argv); + ret = do_spawn(logopt, wait, options, prog, (const char **) argv); if (ret & MTAB_NOTUPDATED) { struct timespec tm = {3, 0}; --- autofs-5.0.1.orig/include/defaults.h +++ autofs-5.0.1/include/defaults.h @@ -24,6 +24,7 @@ #define DEFAULT_TIMEOUT 600 #define DEFAULT_NEGATIVE_TIMEOUT 60 +#define DEFAULT_MOUNT_WAIT -1 #define DEFAULT_UMOUNT_WAIT 12 #define DEFAULT_BROWSE_MODE 1 #define DEFAULT_LOGGING 0 @@ -62,6 +63,7 @@ struct ldap_schema *defaults_get_schema( struct ldap_searchdn *defaults_get_searchdns(void); void defaults_free_searchdns(struct ldap_searchdn *); unsigned int defaults_get_append_options(void); +unsigned int defaults_get_mount_wait(void); unsigned int defaults_get_umount_wait(void); const char *defaults_get_auth_conf_file(void); unsigned int defaults_get_map_hash_table_size(void); --- autofs-5.0.1.orig/lib/defaults.c +++ autofs-5.0.1/lib/defaults.c @@ -45,6 +45,7 @@ #define ENV_NAME_VALUE_ATTR "VALUE_ATTRIBUTE" #define ENV_APPEND_OPTIONS "APPEND_OPTIONS" +#define ENV_MOUNT_WAIT "MOUNT_WAIT" #define ENV_UMOUNT_WAIT "UMOUNT_WAIT" #define ENV_AUTH_CONF_FILE "AUTH_CONF_FILE" @@ -323,6 +324,7 @@ unsigned int defaults_read_config(unsign check_set_config_value(key, ENV_NAME_ENTRY_ATTR, value, to_syslog) || check_set_config_value(key, ENV_NAME_VALUE_ATTR, value, to_syslog) || check_set_config_value(key, ENV_APPEND_OPTIONS, value, to_syslog) || + check_set_config_value(key, ENV_MOUNT_WAIT, value, to_syslog) || check_set_config_value(key, ENV_UMOUNT_WAIT, value, to_syslog) || check_set_config_value(key, ENV_AUTH_CONF_FILE, value, to_syslog) || check_set_config_value(key, ENV_MAP_HASH_TABLE_SIZE, value, to_syslog)) @@ -652,6 +654,17 @@ unsigned int defaults_get_append_options return res; } +unsigned int defaults_get_mount_wait(void) +{ + long wait; + + wait = get_env_number(ENV_MOUNT_WAIT); + if (wait < 0) + wait = DEFAULT_MOUNT_WAIT; + + return (unsigned int) wait; +} + unsigned int defaults_get_umount_wait(void) { long wait; --- autofs-5.0.1.orig/man/auto.master.5.in +++ autofs-5.0.1/man/auto.master.5.in @@ -175,6 +175,13 @@ Set the default timeout for caching fail 60). If the equivalent command line option is given it will override this setting. .TP +.B MOUNT_WAIT +Set the default time to wait for a response from a spawned mount(8) +before sending it a SIGTERM. Note that we still need to wait for the +RPC layer to timeout before the sub-process exits so this isn't ideal +but it is the best we can do. The default is to wait until mount(8) +returns without intervention. +.TP .B UMOUNT_WAIT Set the default time to wait for a response from a spawned umount(8) before sending it a SIGTERM. Note that we still need to wait for the --- autofs-5.0.1.orig/redhat/autofs.sysconfig.in +++ autofs-5.0.1/redhat/autofs.sysconfig.in @@ -14,6 +14,15 @@ TIMEOUT=300 # #NEGATIVE_TIMEOUT=60 # +# MOUNT_WAIT - time to wait for a response from umount(8). +# Setting this timeout can cause problems when +# mount would otherwise wait for a server that +# is temporarily unavailable, such as when it's +# restarting. The defailt of waiting for mount(8) +# usually results in a wait of around 3 minutes. +# +#MOUNT_WAIT=-1 +# # UMOUNT_WAIT - time to wait for a response from umount(8). # #UMOUNT_WAIT=12 --- autofs-5.0.1.orig/samples/autofs.conf.default.in +++ autofs-5.0.1/samples/autofs.conf.default.in @@ -14,6 +14,15 @@ TIMEOUT=300 # #NEGATIVE_TIMEOUT=60 # +# MOUNT_WAIT - time to wait for a response from umount(8). +# Setting this timeout can cause problems when +# mount would otherwise wait for a server that +# is temporarily unavailable, such as when it's +# restarting. The defailt of waiting for mount(8) +# usually results in a wait of around 3 minutes. +# +#MOUNT_WAIT=-1 +# # UMOUNT_WAIT - time to wait for a response from umount(8). # #UMOUNT_WAIT=12