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

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