Blame SOURCES/autofs-5.0.7-probe-each-nfs-version-in-turn-for-singleton-mounts.patch

4d476f
autofs-5.0.7 - probe each nfs version in turn for singleton mounts
4d476f
4d476f
From: Ian Kent <raven@themaw.net>
4d476f
4d476f
4d476f
---
4d476f
 CHANGELOG            |    1 +
4d476f
 include/replicated.h |    2 ++
4d476f
 modules/mount_nfs.c  |   35 ++++++++++++++++++++++++++++++++++-
4d476f
 modules/replicated.c |    8 ++++----
4d476f
 4 files changed, 41 insertions(+), 5 deletions(-)
4d476f
4d476f
diff --git a/CHANGELOG b/CHANGELOG
4d476f
index 39d7889..48e9806 100644
4d476f
--- a/CHANGELOG
4d476f
+++ b/CHANGELOG
4d476f
@@ -48,6 +48,7 @@
4d476f
 - fix master map mount options matching.
4d476f
 - fix master map bogus keywork match.
4d476f
 - fix fix map entry duplicate offset detection.
4d476f
+- probe each nfs version in turn for singleton mounts.
4d476f
 
4d476f
 25/07/2012 autofs-5.0.7
4d476f
 =======================
4d476f
diff --git a/include/replicated.h b/include/replicated.h
4d476f
index ff0e7b9..728f131 100644
4d476f
--- a/include/replicated.h
4d476f
+++ b/include/replicated.h
4d476f
@@ -68,6 +68,8 @@ struct host {
4d476f
 };
4d476f
 
4d476f
 void seed_random(void);
4d476f
+struct host *new_host(const char *, struct sockaddr *, size_t,
4d476f
+		      unsigned int, unsigned int, unsigned int);
4d476f
 void free_host_list(struct host **);
4d476f
 int parse_location(unsigned, struct host **, const char *, unsigned int);
4d476f
 int prune_host_list(unsigned, struct host **, unsigned int, int);
4d476f
diff --git a/modules/mount_nfs.c b/modules/mount_nfs.c
4d476f
index 5424d74..81ba3ca 100644
4d476f
--- a/modules/mount_nfs.c
4d476f
+++ b/modules/mount_nfs.c
4d476f
@@ -180,9 +180,42 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int
4d476f
 	 * We can't probe protocol rdma so leave it to mount.nfs(8)
4d476f
 	 * and and suffer the delay if a server isn't available.
4d476f
 	 */
4d476f
-	if (!rdma)
4d476f
+	if (rdma)
4d476f
+		goto dont_probe;
4d476f
+
4d476f
+	/*
4d476f
+	 * If this is a singleton mount, and NFSv4 only hasn't been asked
4d476f
+	 * for, and the default NFS protocol is set to v4 in the autofs
4d476f
+	 * configuration only probe NFSv4 and let mount.nfs(8) do fallback
4d476f
+	 * to NFSv3 (if it can). If the NFSv4 probe fails then probe as
4d476f
+	 * normal.
4d476f
+	 */
4d476f
+	if (!hosts->next &&
4d476f
+	    mount_default_proto == 4 &&
4d476f
+	    vers & NFS_VERS_MASK != 0 &&
4d476f
+	    vers & NFS4_VERS_MASK != 0) {
4d476f
+		unsigned int v4_probe_ok = 0;
4d476f
+		struct host *tmp = new_host(hosts->name,
4d476f
+					    hosts->addr, hosts->addr_len,
4d476f
+					    hosts->proximity,
4d476f
+					    hosts->weight, hosts->options);
4d476f
+		if (tmp) {
4d476f
+			tmp->rr = hosts->rr;
4d476f
+			prune_host_list(ap->logopt, &tmp,
4d476f
+					NFS4_VERS_MASK|TCP_SUPPORTED, port);
4d476f
+			/* If probe succeeds just try the mount with host in hosts */
4d476f
+			if (tmp) {
4d476f
+				v4_probe_ok = 1;
4d476f
+				free_host_list(&tmp);
4d476f
+			}
4d476f
+		}
4d476f
+		if (!v4_probe_ok)
4d476f
+			prune_host_list(ap->logopt, &hosts, vers, port);
4d476f
+	} else {
4d476f
 		prune_host_list(ap->logopt, &hosts, vers, port);
4d476f
+	}
4d476f
 
4d476f
+dont_probe:
4d476f
 	if (!hosts) {
4d476f
 		info(ap->logopt, MODPREFIX "no hosts available");
4d476f
 		return 1;
4d476f
diff --git a/modules/replicated.c b/modules/replicated.c
4d476f
index 6dbdade..0a044b9 100644
4d476f
--- a/modules/replicated.c
4d476f
+++ b/modules/replicated.c
4d476f
@@ -280,10 +280,10 @@ static unsigned int get_proximity(struct sockaddr *host_addr)
4d476f
 	return PROXIMITY_OTHER;
4d476f
 }
4d476f
 
4d476f
-static struct host *new_host(const char *name,
4d476f
-			     struct sockaddr *addr, size_t addr_len,
4d476f
-			     unsigned int proximity, unsigned int weight,
4d476f
-			     unsigned int options)
4d476f
+struct host *new_host(const char *name,
4d476f
+		      struct sockaddr *addr, size_t addr_len,
4d476f
+		      unsigned int proximity, unsigned int weight,
4d476f
+		      unsigned int options)
4d476f
 {
4d476f
 	struct host *new;
4d476f
 	struct sockaddr *tmp2;