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

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