|
Ian Kent |
cc4062 |
autofs-5.0.5 - fix random selection for host on different network
|
|
Ian Kent |
cc4062 |
|
|
Ian Kent |
cc4062 |
From: Ian Kent <raven@themaw.net>
|
|
Ian Kent |
cc4062 |
|
|
Ian Kent |
cc4062 |
When we select from a list of hosts from which we can mount the list
|
|
Ian Kent |
cc4062 |
is ordered by response time within proximity.
|
|
Ian Kent |
cc4062 |
|
|
Ian Kent |
cc4062 |
This is intended for normal selection but when using random selection
|
|
Ian Kent |
cc4062 |
if any hosts are on another network (and so considered further away)
|
|
Ian Kent |
cc4062 |
they will never be at the head of the list and so are unlikely to be
|
|
Ian Kent |
cc4062 |
used. This leads to a limited set of hosts being used for mounts which
|
|
Ian Kent |
cc4062 |
usually isn't what's required when the random selection option is used.
|
|
Ian Kent |
cc4062 |
---
|
|
Ian Kent |
cc4062 |
|
|
Ian Kent |
cc4062 |
CHANGELOG | 1 +
|
|
Ian Kent |
cc4062 |
include/replicated.h | 2 +-
|
|
Ian Kent |
cc4062 |
modules/mount_nfs.c | 2 +-
|
|
Ian Kent |
cc4062 |
modules/replicated.c | 28 ++++++++++++++++++++--------
|
|
Ian Kent |
cc4062 |
4 files changed, 23 insertions(+), 10 deletions(-)
|
|
Ian Kent |
cc4062 |
|
|
Ian Kent |
cc4062 |
|
|
Ian Kent |
cc4062 |
--- autofs-5.0.5.orig/CHANGELOG
|
|
Ian Kent |
cc4062 |
+++ autofs-5.0.5/CHANGELOG
|
|
Ian Kent |
cc4062 |
@@ -30,6 +30,7 @@
|
|
Ian Kent |
cc4062 |
- add simple bind authentication.
|
|
Ian Kent |
cc4062 |
- fix master map source server unavailable handling.
|
|
Ian Kent |
cc4062 |
- add autofs_ldap_auth.conf man page.
|
|
Ian Kent |
cc4062 |
+- fix random selection for host on different network.
|
|
Ian Kent |
cc4062 |
|
|
Ian Kent |
cc4062 |
03/09/2009 autofs-5.0.5
|
|
Ian Kent |
cc4062 |
-----------------------
|
|
Ian Kent |
cc4062 |
--- autofs-5.0.5.orig/include/replicated.h
|
|
Ian Kent |
cc4062 |
+++ autofs-5.0.5/include/replicated.h
|
|
Ian Kent |
cc4062 |
@@ -64,7 +64,7 @@ struct host {
|
|
Ian Kent |
cc4062 |
|
|
Ian Kent |
cc4062 |
void seed_random(void);
|
|
Ian Kent |
cc4062 |
void free_host_list(struct host **);
|
|
Ian Kent |
cc4062 |
-int parse_location(unsigned, struct host **, const char *);
|
|
Ian Kent |
cc4062 |
+int parse_location(unsigned, struct host **, const char *, unsigned int);
|
|
Ian Kent |
cc4062 |
int prune_host_list(unsigned, struct host **, unsigned int, const char *, unsigned int);
|
|
Ian Kent |
cc4062 |
void dump_host_list(struct host *);
|
|
Ian Kent |
cc4062 |
|
|
Ian Kent |
cc4062 |
--- autofs-5.0.5.orig/modules/mount_nfs.c
|
|
Ian Kent |
cc4062 |
+++ autofs-5.0.5/modules/mount_nfs.c
|
|
Ian Kent |
cc4062 |
@@ -137,7 +137,7 @@ int mount_mount(struct autofs_point *ap,
|
|
Ian Kent |
cc4062 |
else if (mount_default_proto == 4)
|
|
Ian Kent |
cc4062 |
vers = vers | NFS4_VERS_MASK;
|
|
Ian Kent |
cc4062 |
|
|
Ian Kent |
cc4062 |
- if (!parse_location(ap->logopt, &hosts, what)) {
|
|
Ian Kent |
cc4062 |
+ if (!parse_location(ap->logopt, &hosts, what, random_selection)) {
|
|
Ian Kent |
cc4062 |
info(ap->logopt, MODPREFIX "no hosts available");
|
|
Ian Kent |
cc4062 |
return 1;
|
|
Ian Kent |
cc4062 |
}
|
|
Ian Kent |
cc4062 |
--- autofs-5.0.5.orig/modules/replicated.c
|
|
Ian Kent |
cc4062 |
+++ autofs-5.0.5/modules/replicated.c
|
|
Ian Kent |
cc4062 |
@@ -1041,13 +1041,23 @@ int prune_host_list(unsigned logopt, str
|
|
Ian Kent |
cc4062 |
|
|
Ian Kent |
cc4062 |
static int add_new_host(struct host **list,
|
|
Ian Kent |
cc4062 |
const char *host, unsigned int weight,
|
|
Ian Kent |
cc4062 |
- struct addrinfo *host_addr)
|
|
Ian Kent |
cc4062 |
+ struct addrinfo *host_addr,
|
|
Ian Kent |
cc4062 |
+ unsigned int random_selection)
|
|
Ian Kent |
cc4062 |
{
|
|
Ian Kent |
cc4062 |
struct host *new;
|
|
Ian Kent |
cc4062 |
unsigned int prx;
|
|
Ian Kent |
cc4062 |
int addr_len;
|
|
Ian Kent |
cc4062 |
|
|
Ian Kent |
cc4062 |
- prx = get_proximity(host_addr->ai_addr);
|
|
Ian Kent |
cc4062 |
+ /*
|
|
Ian Kent |
cc4062 |
+ * If we are using random selection we pretend all hosts are at
|
|
Ian Kent |
cc4062 |
+ * the same proximity so hosts further away don't get excluded.
|
|
Ian Kent |
cc4062 |
+ * We can't use PROXIMITY_LOCAL or we won't perform an RPC ping
|
|
Ian Kent |
cc4062 |
+ * to remove hosts that may be down.
|
|
Ian Kent |
cc4062 |
+ */
|
|
Ian Kent |
cc4062 |
+ if (random_selection)
|
|
Ian Kent |
cc4062 |
+ prx = PROXIMITY_SUBNET;
|
|
Ian Kent |
cc4062 |
+ else
|
|
Ian Kent |
cc4062 |
+ prx = get_proximity(host_addr->ai_addr);
|
|
Ian Kent |
cc4062 |
/*
|
|
Ian Kent |
cc4062 |
* If we tried to add an IPv6 address and we don't have IPv6
|
|
Ian Kent |
cc4062 |
* support return success in the hope of getting an IPv4
|
|
Ian Kent |
cc4062 |
@@ -1071,7 +1081,8 @@ static int add_new_host(struct host **li
|
|
Ian Kent |
cc4062 |
return 1;
|
|
Ian Kent |
cc4062 |
}
|
|
Ian Kent |
cc4062 |
|
|
Ian Kent |
cc4062 |
-static int add_host_addrs(struct host **list, const char *host, unsigned int weight)
|
|
Ian Kent |
cc4062 |
+static int add_host_addrs(struct host **list, const char *host,
|
|
Ian Kent |
cc4062 |
+ unsigned int weight, unsigned int random_selection)
|
|
Ian Kent |
cc4062 |
{
|
|
Ian Kent |
cc4062 |
struct addrinfo hints, *ni, *this;
|
|
Ian Kent |
cc4062 |
int ret;
|
|
Ian Kent |
cc4062 |
@@ -1087,7 +1098,7 @@ static int add_host_addrs(struct host **
|
|
Ian Kent |
cc4062 |
|
|
Ian Kent |
cc4062 |
this = ni;
|
|
Ian Kent |
cc4062 |
while (this) {
|
|
Ian Kent |
cc4062 |
- ret = add_new_host(list, host, weight, this);
|
|
Ian Kent |
cc4062 |
+ ret = add_new_host(list, host, weight, this, random_selection);
|
|
Ian Kent |
cc4062 |
if (!ret)
|
|
Ian Kent |
cc4062 |
break;
|
|
Ian Kent |
cc4062 |
this = this->ai_next;
|
|
Ian Kent |
cc4062 |
@@ -1110,7 +1121,7 @@ try_name:
|
|
Ian Kent |
cc4062 |
|
|
Ian Kent |
cc4062 |
this = ni;
|
|
Ian Kent |
cc4062 |
while (this) {
|
|
Ian Kent |
cc4062 |
- ret = add_new_host(list, host, weight, this);
|
|
Ian Kent |
cc4062 |
+ ret = add_new_host(list, host, weight, this, random_selection);
|
|
Ian Kent |
cc4062 |
if (!ret)
|
|
Ian Kent |
cc4062 |
break;
|
|
Ian Kent |
cc4062 |
this = this->ai_next;
|
|
Ian Kent |
cc4062 |
@@ -1197,7 +1208,8 @@ static char *seek_delim(const char *s)
|
|
Ian Kent |
cc4062 |
return NULL;
|
|
Ian Kent |
cc4062 |
}
|
|
Ian Kent |
cc4062 |
|
|
Ian Kent |
cc4062 |
-int parse_location(unsigned logopt, struct host **hosts, const char *list)
|
|
Ian Kent |
cc4062 |
+int parse_location(unsigned logopt, struct host **hosts,
|
|
Ian Kent |
cc4062 |
+ const char *list, unsigned int random_selection)
|
|
Ian Kent |
cc4062 |
{
|
|
Ian Kent |
cc4062 |
char *str, *p, *delim;
|
|
Ian Kent |
cc4062 |
unsigned int empty = 1;
|
|
Ian Kent |
cc4062 |
@@ -1252,7 +1264,7 @@ int parse_location(unsigned logopt, stru
|
|
Ian Kent |
cc4062 |
}
|
|
Ian Kent |
cc4062 |
|
|
Ian Kent |
cc4062 |
if (p != delim) {
|
|
Ian Kent |
cc4062 |
- if (!add_host_addrs(hosts, p, weight)) {
|
|
Ian Kent |
cc4062 |
+ if (!add_host_addrs(hosts, p, weight, random_selection)) {
|
|
Ian Kent |
cc4062 |
if (empty) {
|
|
Ian Kent |
cc4062 |
p = next;
|
|
Ian Kent |
cc4062 |
continue;
|
|
Ian Kent |
cc4062 |
@@ -1274,7 +1286,7 @@ int parse_location(unsigned logopt, stru
|
|
Ian Kent |
cc4062 |
*delim = '\0';
|
|
Ian Kent |
cc4062 |
next = delim + 1;
|
|
Ian Kent |
cc4062 |
|
|
Ian Kent |
cc4062 |
- if (!add_host_addrs(hosts, p, weight)) {
|
|
Ian Kent |
cc4062 |
+ if (!add_host_addrs(hosts, p, weight, random_selection)) {
|
|
Ian Kent |
cc4062 |
p = next;
|
|
Ian Kent |
cc4062 |
continue;
|
|
Ian Kent |
cc4062 |
}
|