autofs-5.0.5 - mount using address for rr When a host has multiple addresses, mount using individual address so we can take advantage of the probing and response time calculation that's already been done. --- include/replicated.h | 1 + modules/mount_nfs.c | 23 +++++++++++++++++++++-- modules/replicated.c | 11 ++++++++--- 3 files changed, 30 insertions(+), 5 deletions(-) --- autofs-5.0.1.orig/include/replicated.h +++ autofs-5.0.1/include/replicated.h @@ -53,6 +53,7 @@ struct host { char *name; char *addr; size_t addr_len; + unsigned int rr; char *path; unsigned int version; unsigned int options; --- autofs-5.0.1.orig/modules/mount_nfs.c +++ autofs-5.0.1/modules/mount_nfs.c @@ -227,8 +227,27 @@ int mount_mount(struct autofs_point *ap, /* Not a local host - do an NFS mount */ - loc = malloc(strlen(this->name) + 1 + strlen(this->path) + 1); - strcpy(loc, this->name); + if (this->rr && this->addr) { + socklen_t len = INET_ADDRSTRLEN; + char n_buf[len + 1]; + const char *n_addr; + n_addr = get_addr_string(this->addr, n_buf, len); + loc = malloc(strlen(n_addr) + strlen(this->path) + 4); + if (!loc) { + char *estr = strerror_r(errno, buf, MAX_ERR_BUF); + error(ap->logopt, "malloc: %s", estr); + goto forced_fail; + } + strcpy(loc, n_addr); + } else { + loc = malloc(strlen(this->name) + strlen(this->path) + 2); + if (!loc) { + char *estr = strerror_r(errno, buf, MAX_ERR_BUF); + error(ap->logopt, "malloc: %s", estr); + goto forced_fail; + } + strcpy(loc, this->name); + } strcat(loc, ":"); strcat(loc, this->path); --- autofs-5.0.1.orig/modules/replicated.c +++ autofs-5.0.1/modules/replicated.c @@ -271,7 +271,7 @@ static unsigned int get_proximity(const static struct host *new_host(const char *name, const char *addr, size_t addr_len, unsigned int proximity, unsigned int weight, - unsigned int options) + unsigned int rr, unsigned int options) { struct host *new; char *tmp1, *tmp2; @@ -304,6 +304,7 @@ static struct host *new_host(const char new->addr = tmp2; new->proximity = proximity; new->weight = weight; + new->rr = rr; new->options = options; return new; @@ -986,6 +987,7 @@ static int add_host_addrs(struct host ** int ghn_errno, ret; struct host *new; unsigned int prx; + int rr = 0; saddr.sin_family = AF_INET; if (inet_aton(host, &saddr.sin_addr)) { @@ -1015,7 +1017,7 @@ static int add_host_addrs(struct host ** if (prx == PROXIMITY_ERROR) return 0; - if (!(new = new_host(host, thost, sizeof(saddr.sin_addr), prx, weight, options))) + if (!(new = new_host(host, thost, sizeof(saddr.sin_addr), prx, weight, 0, options))) return 0; if (!add_host(list, new)) @@ -1039,6 +1041,9 @@ static int add_host_addrs(struct host ** return 0; } + haddr = phe->h_addr_list; + if (++haddr) + rr++; for (haddr = phe->h_addr_list; *haddr; haddr++) { struct in_addr tt; @@ -1057,7 +1062,7 @@ static int add_host_addrs(struct host ** return 0; memcpy(&tt, *haddr, sizeof(struct in_addr)); - if (!(new = new_host(host, *haddr, phe->h_length, prx, weight, options))) + if (!(new = new_host(host, *haddr, phe->h_length, prx, weight, rr, options))) return 0; if (!add_host(list, new)) {