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

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