Blame SOURCES/autofs-5.1.2-check-NFS-server-availability-on-local-mount-fallback.patch

306fa1
autofs-5.1.2 - check NFS server availability on local mount fallback
306fa1
306fa1
From: Ian Kent <raven@themaw.net>
306fa1
306fa1
The availability probe isn't done for anything autofs thinks is a
306fa1
local mount because it's the local machine.
306fa1
306fa1
It first tries a bind mount and if that fails it falls back to trying
306fa1
a local NFS mount. If the local NFS server is not running mount.nfs(8)
306fa1
can suffer a lengthy timeout.
306fa1
306fa1
So check for the bind mount fallback case and check if an NFS server
306fa1
is responding before trying the mount.
306fa1
306fa1
Signed-off-by: Ian Kent <raven@themaw.net>
306fa1
---
306fa1
 CHANGELOG           |    1 +
306fa1
 lib/rpc_subs.c      |   11 +++++++++++
306fa1
 modules/mount_nfs.c |   15 ++++++++++++++-
306fa1
 3 files changed, 26 insertions(+), 1 deletion(-)
306fa1
306fa1
--- autofs-5.0.7.orig/CHANGELOG
306fa1
+++ autofs-5.0.7/CHANGELOG
306fa1
@@ -215,6 +215,7 @@
306fa1
 - make lookup_nss_read_master() return nss status.
306fa1
 - make set_direct_mount_catatonic() more general.
306fa1
 - set autofs mounts catatonic at exit.
306fa1
+- check NFS server availability on local mount fallback.
306fa1
 
306fa1
 25/07/2012 autofs-5.0.7
306fa1
 =======================
306fa1
--- autofs-5.0.7.orig/lib/rpc_subs.c
306fa1
+++ autofs-5.0.7/lib/rpc_subs.c
306fa1
@@ -1053,6 +1053,7 @@ static int __rpc_ping(const char *host,
306fa1
 
306fa1
 int rpc_ping(const char *host, long seconds, long micros, unsigned int option)
306fa1
 {
306fa1
+	unsigned long vers4 = NFS4_VERSION;
306fa1
 	unsigned long vers3 = NFS3_VERSION;
306fa1
 	unsigned long vers2 = NFS2_VERSION;
306fa1
 	int status;
306fa1
@@ -1065,6 +1066,12 @@ int rpc_ping(const char *host, long seco
306fa1
 	if (status > 0)
306fa1
 		return RPC_PING_V3 | RPC_PING_UDP;
306fa1
 
306fa1
+	/* UDP isn't recommended for NFSv4, don't bother checking it.
306fa1
+	status = __rpc_ping(host, vers4, IPPROTO_UDP, seconds, micros, option);
306fa1
+	if (status > 0)
306fa1
+		return RPC_PING_V4 | RPC_PING_UDP;
306fa1
+	*/
306fa1
+
306fa1
 	status = __rpc_ping(host, vers2, IPPROTO_TCP, seconds, micros, option);
306fa1
 	if (status > 0)
306fa1
 		return RPC_PING_V2 | RPC_PING_TCP;
306fa1
@@ -1073,6 +1080,10 @@ int rpc_ping(const char *host, long seco
306fa1
 	if (status > 0)
306fa1
 		return RPC_PING_V3 | RPC_PING_TCP;
306fa1
 
306fa1
+	status = __rpc_ping(host, vers4, IPPROTO_TCP, seconds, micros, option);
306fa1
+	if (status > 0)
306fa1
+		return RPC_PING_V4 | RPC_PING_TCP;
306fa1
+
306fa1
 	return status;
306fa1
 }
306fa1
 
306fa1
--- autofs-5.0.7.orig/modules/mount_nfs.c
306fa1
+++ autofs-5.0.7/modules/mount_nfs.c
306fa1
@@ -347,6 +347,19 @@ dont_probe:
306fa1
 		strcat(loc, ":");
306fa1
 		strcat(loc, this->path);
306fa1
 
306fa1
+		/* If this is a fallback from a bind mount failure
306fa1
+		 * check if the local NFS server is available to try
306fa1
+		 * and prevent lengthy mount failure waits.
306fa1
+		 */
306fa1
+		if (this->proximity == PROXIMITY_LOCAL) {
306fa1
+			char *host = this->name ? this->name : "localhost";
306fa1
+			int ret;
306fa1
+
306fa1
+			ret = rpc_ping(host, 2, 0, RPC_CLOSE_DEFAULT);
306fa1
+			if (ret <= 0)
306fa1
+				goto next;
306fa1
+		}
306fa1
+
306fa1
 		if (nfsoptions && *nfsoptions) {
306fa1
 			debug(ap->logopt,
306fa1
 			      MODPREFIX "calling mount -t %s " SLOPPY 
306fa1
@@ -369,7 +382,7 @@ dont_probe:
306fa1
 			free_host_list(&hosts);
306fa1
 			return 0;
306fa1
 		}
306fa1
-
306fa1
+next:
306fa1
 		free(loc);
306fa1
 		this = this->next;
306fa1
 	}