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

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