public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
* mount.nfs: protocol fallback when server doesn't support TCP
@ 2010-08-26  2:06 Neil Brown
  2010-08-26 14:51 ` Chuck Lever
  0 siblings, 1 reply; 14+ messages in thread
From: Neil Brown @ 2010-08-26  2:06 UTC (permalink / raw)
  To: Chuck Lever; +Cc: Linux NFS Mailing list


Currently if the server doesn't support TCP (and so doesn't support NFSv4)
we don't fall-back to NFSv3.  This is because 'ECONNREFUSED' isn't deemed to
be a suitable error for falling back.  Rather we wait for about 2 minutes,
then give up.

There is some justification for this:  ECONNREFUSED could just mean that the
server isn't quite ready yet.

I'm not really sure what the best thing to do here would be.  We don't really
want to try v3 and have fail only because it was just enough later that nfsd
is now responding.

Maybe the ideal would be to do a portmap probe and only fall back to v3 if
portmap confirm that v3 is supported and v4 isn't.

For now I just present this patch which allows fallback to v3 providing tcp
wasn't explicitly requested.

Thoughts?

NeilBrown

diff --git a/utils/mount/stropts.c b/utils/mount/stropts.c
index 0241400..fb8c108 100644
--- a/utils/mount/stropts.c
+++ b/utils/mount/stropts.c
@@ -762,6 +762,25 @@ static int nfs_try_mount(struct nfsmount_info *mi)
 			errno = 0;
 			result = nfs_try_mount_v4(mi);
 			if (errno != EPROTONOSUPPORT) {
+				/* If server only handles UDP, then v4 will have
+				 * received ECONNREFUSED for TCP, so fall through
+				 * to v3v2 which can try udp, but only if tcp
+				 * wasn't explicitly requested
+				 */
+				if (errno == ECONNREFUSED) {
+					static const char *nfs_proto_tbl[] = {
+						"udp",
+						"tcp",
+						NULL
+					};
+					char *p;
+
+					if (po_rightmost(mi->options, nfs_proto_tbl) == 1)
+						break;
+					p = po_get(mi->options, "proto");
+					if (p && strcmp(p, "tcp") == 0)
+						break;
+				} else
 				/* 
 				 * To deal with legacy Linux servers that don't
 				 * automatically export a pseudo root, retry

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2010-09-08 18:53 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-26  2:06 mount.nfs: protocol fallback when server doesn't support TCP Neil Brown
2010-08-26 14:51 ` Chuck Lever
2010-08-26 15:27   ` Jim Rees
2010-08-26 16:09     ` Chuck Lever
2010-08-30  0:30   ` Neil Brown
2010-08-30 19:29     ` Chuck Lever
2010-08-31  1:00       ` Neil Brown
2010-08-31 16:38         ` Chuck Lever
2010-09-07  1:32           ` Neil Brown
2010-09-07 17:37             ` Chuck Lever
2010-09-08  2:35               ` Neil Brown
2010-09-08 18:52                 ` Chuck Lever
2010-08-31 20:29         ` Chuck Lever
2010-09-07  0:02           ` Neil Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox