|
Ian Kent |
36ee82 |
diff -up autofs-5.0.2/include/replicated.h.random-selection-fix autofs-5.0.2/include/replicated.h
|
|
Ian Kent |
36ee82 |
--- autofs-5.0.2/include/replicated.h.random-selection-fix 2007-06-18 15:18:08.000000000 +0800
|
|
Ian Kent |
36ee82 |
+++ autofs-5.0.2/include/replicated.h 2007-11-20 14:55:28.000000000 +0900
|
|
Ian Kent |
36ee82 |
@@ -63,7 +63,7 @@ struct host {
|
|
Ian Kent |
36ee82 |
void seed_random(void);
|
|
Ian Kent |
36ee82 |
void free_host_list(struct host **);
|
|
Ian Kent |
36ee82 |
int parse_location(struct host **, const char *);
|
|
Ian Kent |
36ee82 |
-int prune_host_list(struct host **, unsigned int, const char *);
|
|
Ian Kent |
36ee82 |
+int prune_host_list(struct host **, unsigned int, const char *, unsigned int);
|
|
Ian Kent |
36ee82 |
void dump_host_list(struct host *);
|
|
Ian Kent |
36ee82 |
|
|
Ian Kent |
36ee82 |
#endif
|
|
Ian Kent |
36ee82 |
diff -up autofs-5.0.2/include/automount.h.random-selection-fix autofs-5.0.2/include/automount.h
|
|
Ian Kent |
36ee82 |
--- autofs-5.0.2/include/automount.h.random-selection-fix 2007-11-20 14:55:28.000000000 +0900
|
|
Ian Kent |
36ee82 |
+++ autofs-5.0.2/include/automount.h 2007-11-20 14:55:28.000000000 +0900
|
|
Ian Kent |
36ee82 |
@@ -448,6 +448,8 @@ struct autofs_point {
|
|
Ian Kent |
36ee82 |
enum states state; /* Current state */
|
|
Ian Kent |
36ee82 |
int state_pipe[2]; /* State change router pipe */
|
|
Ian Kent |
36ee82 |
unsigned dir_created; /* Directory created for this mount? */
|
|
Ian Kent |
36ee82 |
+ unsigned random_selection; /* Use random policy when selecting a
|
|
Ian Kent |
36ee82 |
+ * host from which to mount */
|
|
Ian Kent |
36ee82 |
struct autofs_point *parent; /* Owner of mounts list for submount */
|
|
Ian Kent |
36ee82 |
pthread_mutex_t mounts_mutex; /* Protect mount lists */
|
|
Ian Kent |
36ee82 |
pthread_cond_t mounts_cond; /* Submounts condition variable */
|
|
Ian Kent |
36ee82 |
diff -up autofs-5.0.2/modules/mount_nfs.c.random-selection-fix autofs-5.0.2/modules/mount_nfs.c
|
|
Ian Kent |
36ee82 |
--- autofs-5.0.2/modules/mount_nfs.c.random-selection-fix 2007-11-20 14:55:28.000000000 +0900
|
|
Ian Kent |
36ee82 |
+++ autofs-5.0.2/modules/mount_nfs.c 2007-11-20 14:55:28.000000000 +0900
|
|
Ian Kent |
36ee82 |
@@ -137,7 +137,7 @@ int mount_mount(struct autofs_point *ap,
|
|
Ian Kent |
36ee82 |
warn(ap->logopt, MODPREFIX "no hosts available");
|
|
Ian Kent |
36ee82 |
return 1;
|
|
Ian Kent |
36ee82 |
}
|
|
Ian Kent |
36ee82 |
- prune_host_list(&hosts, vers, nfsoptions);
|
|
Ian Kent |
36ee82 |
+ prune_host_list(&hosts, vers, nfsoptions, ap->random_selection);
|
|
Ian Kent |
36ee82 |
|
|
Ian Kent |
36ee82 |
if (!hosts) {
|
|
Ian Kent |
36ee82 |
warn(ap->logopt, MODPREFIX "no hosts available");
|
|
Ian Kent |
36ee82 |
diff -up autofs-5.0.2/modules/replicated.c.random-selection-fix autofs-5.0.2/modules/replicated.c
|
|
Ian Kent |
36ee82 |
--- autofs-5.0.2/modules/replicated.c.random-selection-fix 2007-11-20 14:55:28.000000000 +0900
|
|
Ian Kent |
36ee82 |
+++ autofs-5.0.2/modules/replicated.c 2007-11-20 14:55:28.000000000 +0900
|
|
Ian Kent |
36ee82 |
@@ -74,8 +74,6 @@
|
|
Ian Kent |
36ee82 |
#define max(x, y) (x >= y ? x : y)
|
|
Ian Kent |
36ee82 |
#define mmax(x, y, z) (max(x, y) == x ? max(x, z) : max(y, z))
|
|
Ian Kent |
36ee82 |
|
|
Ian Kent |
36ee82 |
-extern unsigned int random_selection;
|
|
Ian Kent |
36ee82 |
-
|
|
Ian Kent |
36ee82 |
void seed_random(void)
|
|
Ian Kent |
36ee82 |
{
|
|
Ian Kent |
36ee82 |
int fd;
|
|
Ian Kent |
36ee82 |
@@ -392,7 +390,7 @@ static unsigned short get_port_option(co
|
|
Ian Kent |
36ee82 |
static unsigned int get_nfs_info(struct host *host,
|
|
Ian Kent |
36ee82 |
struct conn_info *pm_info, struct conn_info *rpc_info,
|
|
Ian Kent |
36ee82 |
const char *proto, unsigned int version,
|
|
Ian Kent |
36ee82 |
- const char *options)
|
|
Ian Kent |
36ee82 |
+ const char *options, unsigned int random_selection)
|
|
Ian Kent |
36ee82 |
{
|
|
Ian Kent |
36ee82 |
char *have_port_opt = options ? strstr(options, "port=") : NULL;
|
|
Ian Kent |
36ee82 |
struct pmap parms;
|
|
Ian Kent |
36ee82 |
@@ -535,7 +533,9 @@ done_ver:
|
|
Ian Kent |
36ee82 |
return supported;
|
|
Ian Kent |
36ee82 |
}
|
|
Ian Kent |
36ee82 |
|
|
Ian Kent |
36ee82 |
-static int get_vers_and_cost(struct host *host, unsigned int version, const char *options)
|
|
Ian Kent |
36ee82 |
+static int get_vers_and_cost(struct host *host,
|
|
Ian Kent |
36ee82 |
+ unsigned int version, const char *options,
|
|
Ian Kent |
36ee82 |
+ unsigned int random_selection)
|
|
Ian Kent |
36ee82 |
{
|
|
Ian Kent |
36ee82 |
struct conn_info pm_info, rpc_info;
|
|
Ian Kent |
36ee82 |
time_t timeout = RPC_TIMEOUT;
|
|
Ian Kent |
36ee82 |
@@ -559,7 +559,9 @@ static int get_vers_and_cost(struct host
|
|
Ian Kent |
36ee82 |
vers &= version;
|
|
Ian Kent |
36ee82 |
|
|
Ian Kent |
36ee82 |
if (version & UDP_REQUESTED) {
|
|
Ian Kent |
36ee82 |
- supported = get_nfs_info(host, &pm_info, &rpc_info, "udp", vers, options);
|
|
Ian Kent |
36ee82 |
+ supported = get_nfs_info(host,
|
|
Ian Kent |
36ee82 |
+ &pm_info, &rpc_info, "udp", vers,
|
|
Ian Kent |
36ee82 |
+ options, random_selection);
|
|
Ian Kent |
36ee82 |
if (supported) {
|
|
Ian Kent |
36ee82 |
ret = 1;
|
|
Ian Kent |
36ee82 |
host->version |= (supported << 8);
|
|
Ian Kent |
36ee82 |
@@ -567,7 +569,9 @@ static int get_vers_and_cost(struct host
|
|
Ian Kent |
36ee82 |
}
|
|
Ian Kent |
36ee82 |
|
|
Ian Kent |
36ee82 |
if (version & TCP_REQUESTED) {
|
|
Ian Kent |
36ee82 |
- supported = get_nfs_info(host, &pm_info, &rpc_info, "tcp", vers, options);
|
|
Ian Kent |
36ee82 |
+ supported = get_nfs_info(host,
|
|
Ian Kent |
36ee82 |
+ &pm_info, &rpc_info, "tcp", vers,
|
|
Ian Kent |
36ee82 |
+ options, random_selection);
|
|
Ian Kent |
36ee82 |
if (supported) {
|
|
Ian Kent |
36ee82 |
ret = 1;
|
|
Ian Kent |
36ee82 |
host->version |= supported;
|
|
Ian Kent |
36ee82 |
@@ -577,7 +581,9 @@ static int get_vers_and_cost(struct host
|
|
Ian Kent |
36ee82 |
return ret;
|
|
Ian Kent |
36ee82 |
}
|
|
Ian Kent |
36ee82 |
|
|
Ian Kent |
36ee82 |
-static int get_supported_ver_and_cost(struct host *host, unsigned int version, const char *options)
|
|
Ian Kent |
36ee82 |
+static int get_supported_ver_and_cost(struct host *host,
|
|
Ian Kent |
36ee82 |
+ unsigned int version, const char *options,
|
|
Ian Kent |
36ee82 |
+ unsigned int random_selection)
|
|
Ian Kent |
36ee82 |
{
|
|
Ian Kent |
36ee82 |
char *have_port_opt = options ? strstr(options, "port=") : NULL;
|
|
Ian Kent |
36ee82 |
struct conn_info pm_info, rpc_info;
|
|
Ian Kent |
36ee82 |
@@ -695,7 +701,9 @@ done:
|
|
Ian Kent |
36ee82 |
return 0;
|
|
Ian Kent |
36ee82 |
}
|
|
Ian Kent |
36ee82 |
|
|
Ian Kent |
36ee82 |
-int prune_host_list(struct host **list, unsigned int vers, const char *options)
|
|
Ian Kent |
36ee82 |
+int prune_host_list(struct host **list,
|
|
Ian Kent |
36ee82 |
+ unsigned int vers, const char *options,
|
|
Ian Kent |
36ee82 |
+ unsigned int random_selection)
|
|
Ian Kent |
36ee82 |
{
|
|
Ian Kent |
36ee82 |
struct host *this, *last, *first;
|
|
Ian Kent |
36ee82 |
struct host *new = NULL;
|
|
Ian Kent |
36ee82 |
@@ -734,7 +742,8 @@ int prune_host_list(struct host **list,
|
|
Ian Kent |
36ee82 |
break;
|
|
Ian Kent |
36ee82 |
|
|
Ian Kent |
36ee82 |
if (this->name) {
|
|
Ian Kent |
36ee82 |
- status = get_vers_and_cost(this, vers, options);
|
|
Ian Kent |
36ee82 |
+ status = get_vers_and_cost(this, vers,
|
|
Ian Kent |
36ee82 |
+ options, random_selection);
|
|
Ian Kent |
36ee82 |
if (!status) {
|
|
Ian Kent |
36ee82 |
if (this == first) {
|
|
Ian Kent |
36ee82 |
first = next;
|
|
Ian Kent |
36ee82 |
@@ -824,7 +833,9 @@ int prune_host_list(struct host **list,
|
|
Ian Kent |
36ee82 |
remove_host(list, this);
|
|
Ian Kent |
36ee82 |
add_host(&new, this);
|
|
Ian Kent |
36ee82 |
} else {
|
|
Ian Kent |
36ee82 |
- status = get_supported_ver_and_cost(this, selected_version, options);
|
|
Ian Kent |
36ee82 |
+ status = get_supported_ver_and_cost(this,
|
|
Ian Kent |
36ee82 |
+ selected_version, options,
|
|
Ian Kent |
36ee82 |
+ random_selection);
|
|
Ian Kent |
36ee82 |
if (status) {
|
|
Ian Kent |
36ee82 |
this->version = selected_version;
|
|
Ian Kent |
36ee82 |
remove_host(list, this);
|
|
Ian Kent |
36ee82 |
diff -up autofs-5.0.2/daemon/automount.c.random-selection-fix autofs-5.0.2/daemon/automount.c
|
|
Ian Kent |
36ee82 |
--- autofs-5.0.2/daemon/automount.c.random-selection-fix 2007-11-20 14:55:28.000000000 +0900
|
|
Ian Kent |
36ee82 |
+++ autofs-5.0.2/daemon/automount.c 2007-11-20 14:55:28.000000000 +0900
|
|
Ian Kent |
36ee82 |
@@ -52,9 +52,9 @@ const char *confdir = AUTOFS_CONF_DIR; /
|
|
Ian Kent |
36ee82 |
|
|
Ian Kent |
36ee82 |
const char *global_options; /* Global option, from command line */
|
|
Ian Kent |
36ee82 |
|
|
Ian Kent |
36ee82 |
-static char *pid_file = NULL; /* File in which to keep pid */
|
|
Ian Kent |
36ee82 |
-unsigned int random_selection; /* use random policy when selecting
|
|
Ian Kent |
36ee82 |
- * which multi-mount host to mount */
|
|
Ian Kent |
36ee82 |
+static char *pid_file = NULL; /* File in which to keep pid */
|
|
Ian Kent |
36ee82 |
+unsigned int global_random_selection; /* use random policy when selecting
|
|
Ian Kent |
36ee82 |
+ * which multi-mount host to mount */
|
|
Ian Kent |
36ee82 |
static int start_pipefd[2];
|
|
Ian Kent |
36ee82 |
static int st_stat = 0;
|
|
Ian Kent |
36ee82 |
static int *pst_stat = &st_stat;
|
|
Ian Kent |
36ee82 |
@@ -1469,7 +1469,7 @@ int main(int argc, char *argv[])
|
|
Ian Kent |
36ee82 |
timeout = defaults_get_timeout();
|
|
Ian Kent |
36ee82 |
ghost = defaults_get_browse_mode();
|
|
Ian Kent |
36ee82 |
logging = defaults_get_logging();
|
|
Ian Kent |
36ee82 |
- random_selection = 0;
|
|
Ian Kent |
36ee82 |
+ global_random_selection = 0;
|
|
Ian Kent |
36ee82 |
global_options = NULL;
|
|
Ian Kent |
36ee82 |
have_global_options = 0;
|
|
Ian Kent |
36ee82 |
foreground = 0;
|
|
Ian Kent |
36ee82 |
@@ -1510,7 +1510,7 @@ int main(int argc, char *argv[])
|
|
Ian Kent |
36ee82 |
exit(0);
|
|
Ian Kent |
36ee82 |
|
|
Ian Kent |
36ee82 |
case 'r':
|
|
Ian Kent |
36ee82 |
- random_selection = 1;
|
|
Ian Kent |
36ee82 |
+ global_random_selection = 1;
|
|
Ian Kent |
36ee82 |
break;
|
|
Ian Kent |
36ee82 |
|
|
Ian Kent |
36ee82 |
case 'O':
|
|
Ian Kent |
36ee82 |
diff -up autofs-5.0.2/lib/master_tok.l.random-selection-fix autofs-5.0.2/lib/master_tok.l
|
|
Ian Kent |
36ee82 |
--- autofs-5.0.2/lib/master_tok.l.random-selection-fix 2007-11-20 14:55:28.000000000 +0900
|
|
Ian Kent |
36ee82 |
+++ autofs-5.0.2/lib/master_tok.l 2007-11-20 14:55:28.000000000 +0900
|
|
Ian Kent |
36ee82 |
@@ -324,6 +324,7 @@ OPTTOUT (-t{OPTWS}|-t{OPTWS}={OPTWS}|--
|
|
Ian Kent |
36ee82 |
-g|--ghost|-?browse { return(OPT_GHOST); }
|
|
Ian Kent |
36ee82 |
-v|--verbose { return(OPT_VERBOSE); }
|
|
Ian Kent |
36ee82 |
-d|--debug { return(OPT_DEBUG); }
|
|
Ian Kent |
36ee82 |
+ -r|--random-multimount-selection { return(OPT_RANDOM); }
|
|
Ian Kent |
36ee82 |
|
|
Ian Kent |
36ee82 |
{OPTWS}","{OPTWS} { return(COMMA); }
|
|
Ian Kent |
36ee82 |
|
|
Ian Kent |
36ee82 |
diff -up autofs-5.0.2/lib/master_parse.y.random-selection-fix autofs-5.0.2/lib/master_parse.y
|
|
Ian Kent |
36ee82 |
--- autofs-5.0.2/lib/master_parse.y.random-selection-fix 2007-11-20 14:55:28.000000000 +0900
|
|
Ian Kent |
36ee82 |
+++ autofs-5.0.2/lib/master_parse.y 2007-11-20 14:55:28.000000000 +0900
|
|
Ian Kent |
36ee82 |
@@ -56,6 +56,8 @@ static char *type;
|
|
Ian Kent |
36ee82 |
static char *format;
|
|
Ian Kent |
36ee82 |
static long timeout;
|
|
Ian Kent |
36ee82 |
static unsigned ghost;
|
|
Ian Kent |
36ee82 |
+extern unsigned global_random_selection;
|
|
Ian Kent |
36ee82 |
+static unsigned random_selection;
|
|
Ian Kent |
36ee82 |
static char **tmp_argv;
|
|
Ian Kent |
36ee82 |
static int tmp_argc;
|
|
Ian Kent |
36ee82 |
static char **local_argv;
|
|
Ian Kent |
36ee82 |
@@ -93,7 +95,7 @@ static int master_fprintf(FILE *, char *
|
|
Ian Kent |
36ee82 |
|
|
Ian Kent |
36ee82 |
%token COMMENT
|
|
Ian Kent |
36ee82 |
%token MAP
|
|
Ian Kent |
36ee82 |
-%token OPT_TIMEOUT OPT_NOGHOST OPT_GHOST OPT_VERBOSE OPT_DEBUG
|
|
Ian Kent |
36ee82 |
+%token OPT_TIMEOUT OPT_NOGHOST OPT_GHOST OPT_VERBOSE OPT_DEBUG OPT_RANDOM
|
|
Ian Kent |
36ee82 |
%token COLON COMMA NL DDASH
|
|
Ian Kent |
36ee82 |
%type <strtype> map
|
|
Ian Kent |
36ee82 |
%type <strtype> options
|
|
Ian Kent |
36ee82 |
@@ -174,6 +176,7 @@ line:
|
|
Ian Kent |
36ee82 |
| PATH COLON { master_notify($1); YYABORT; }
|
|
Ian Kent |
36ee82 |
| PATH OPTION { master_notify($2); YYABORT; }
|
|
Ian Kent |
36ee82 |
| PATH NILL { master_notify($2); YYABORT; }
|
|
Ian Kent |
36ee82 |
+ | PATH OPT_RANDOM { master_notify($1); YYABORT; }
|
|
Ian Kent |
36ee82 |
| PATH OPT_DEBUG { master_notify($1); YYABORT; }
|
|
Ian Kent |
36ee82 |
| PATH OPT_TIMEOUT { master_notify($1); YYABORT; }
|
|
Ian Kent |
36ee82 |
| PATH OPT_GHOST { master_notify($1); YYABORT; }
|
|
Ian Kent |
36ee82 |
@@ -543,6 +546,7 @@ daemon_option: OPT_TIMEOUT NUMBER { time
|
|
Ian Kent |
36ee82 |
| OPT_GHOST { ghost = 1; }
|
|
Ian Kent |
36ee82 |
| OPT_VERBOSE { verbose = 1; }
|
|
Ian Kent |
36ee82 |
| OPT_DEBUG { debug = 1; }
|
|
Ian Kent |
36ee82 |
+ | OPT_RANDOM { random_selection = 1; }
|
|
Ian Kent |
36ee82 |
;
|
|
Ian Kent |
36ee82 |
|
|
Ian Kent |
36ee82 |
mount_option: OPTION
|
|
Ian Kent |
36ee82 |
@@ -600,6 +604,7 @@ static void local_init_vars(void)
|
|
Ian Kent |
36ee82 |
debug = 0;
|
|
Ian Kent |
36ee82 |
timeout = -1;
|
|
Ian Kent |
36ee82 |
ghost = defaults_get_browse_mode();
|
|
Ian Kent |
36ee82 |
+ random_selection = global_random_selection;
|
|
Ian Kent |
36ee82 |
tmp_argv = NULL;
|
|
Ian Kent |
36ee82 |
tmp_argc = 0;
|
|
Ian Kent |
36ee82 |
local_argv = NULL;
|
|
Ian Kent |
36ee82 |
@@ -790,6 +795,7 @@ int master_parse_entry(const char *buffe
|
|
Ian Kent |
36ee82 |
}
|
|
Ian Kent |
36ee82 |
set_mnt_logging(ap);
|
|
Ian Kent |
36ee82 |
}
|
|
Ian Kent |
36ee82 |
+ entry->ap->random_selection = random_selection;
|
|
Ian Kent |
36ee82 |
|
|
Ian Kent |
36ee82 |
/*
|
|
Ian Kent |
36ee82 |
source = master_find_map_source(entry, type, format,
|
|
Ian Kent |
36ee82 |
diff -up autofs-5.0.2/man/auto.master.5.in.random-selection-fix autofs-5.0.2/man/auto.master.5.in
|
|
Ian Kent |
36ee82 |
--- autofs-5.0.2/man/auto.master.5.in.random-selection-fix 2007-11-20 14:55:28.000000000 +0900
|
|
Ian Kent |
36ee82 |
+++ autofs-5.0.2/man/auto.master.5.in 2007-11-20 14:55:28.000000000 +0900
|
|
Ian Kent |
36ee82 |
@@ -146,6 +146,12 @@ to prevent symlinking of local NFS mount
|
|
Ian Kent |
36ee82 |
prevent bind mounting of local NFS filesystems as well. If you need to
|
|
Ian Kent |
36ee82 |
prevent bind mounting for only specific entrys in a map then this
|
|
Ian Kent |
36ee82 |
can be done by adding the "port=" mount option to the given entries.
|
|
Ian Kent |
36ee82 |
+.TP
|
|
Ian Kent |
36ee82 |
+.I "\-r, \-\-random-multimount-selection"
|
|
Ian Kent |
36ee82 |
+Enables the use of ramdom selection when choosing a host from a
|
|
Ian Kent |
36ee82 |
+list of replicated servers. This option is applied to this mount
|
|
Ian Kent |
36ee82 |
+only, overriding the global setting that may be specified on the
|
|
Ian Kent |
36ee82 |
+command line.
|
|
Ian Kent |
36ee82 |
.SH GENERAL SYSTEM DEFAULTS CONFIGURATION
|
|
Ian Kent |
36ee82 |
.P
|
|
Ian Kent |
36ee82 |
The default value of several general settings may be changed in the
|