All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] nfsmount.conf: New variables that explicitly set default (Release 2)
@ 2009-10-12 21:33 Steve Dickson
       [not found] ` <4AD3A0BA.3080104-AfCzQyP5zfLQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Steve Dickson @ 2009-10-12 21:33 UTC (permalink / raw)
  To: linux-nfs

Here is an update to my previous patch that allow the setting
of both the protocol version and network version from the 
mount configuration file. Here is the original justification:

    http://marc.info/?l=linux-nfs&m=125511238831199&w=2

The changes are:
   * Broken up the patch into three different patch with 
     of making it easier to review.

   * Changed the mount configuration variables from default_nfsvers
     and default_proto to defaultvers and defaultproto.


Comments?

steved.

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

* [PATCH 1/3] nfsmount.conf: New variables that explicitly set default (Release 2)
       [not found] ` <4AD3A0BA.3080104-AfCzQyP5zfLQT0dZR+AlfA@public.gmane.org>
@ 2009-10-12 21:37   ` Steve Dickson
  2009-10-12 21:38   ` [PATCH 2/3] " Steve Dickson
  2009-10-12 21:39   ` [PATCH 3/3] " Steve Dickson
  2 siblings, 0 replies; 4+ messages in thread
From: Steve Dickson @ 2009-10-12 21:37 UTC (permalink / raw)
  To: linux-nfs

commit 7c9406cbfb7cf4d694890c6ddf7f4597b026cb7a
Author: Steve Dickson <steved@redhat.com>
Date:   Mon Oct 12 16:48:21 2009 -0400

    Introducing the parsing of both 'defaultvers' and 'defaultproto'
    config variables which will be used to set the the default
    version and network protocol.
    
    A global variable is used to mark the fact these options
    are have be set.
    
    Signed-off-by: Steve Dickson <steved@redhat.com>

diff --git a/support/include/conffile.h b/support/include/conffile.h
index 672020a..da8e836 100644
--- a/support/include/conffile.h
+++ b/support/include/conffile.h
@@ -75,4 +75,12 @@ static inline void upper2lower(char *str)
 	while ((c = tolower(*str)))
 		*str++ = c;
 }
+
+/*
+ * Default Mount options
+ */
+#define DEFAULT_PROTO 0x1
+#define DEFAULT_VERS  0x2
+extern int config_default_opts;
+
 #endif				/* _CONFFILE_H_ */
diff --git a/utils/mount/configfile.c b/utils/mount/configfile.c
index d3285f8..ff1bb5f 100644
--- a/utils/mount/configfile.c
+++ b/utils/mount/configfile.c
@@ -197,6 +197,30 @@ int inline check_vers(char *mopt, char *field)
 	}
 	return 0;
 }
+
+/*
+ * See if there are any default values being set.
+ * If so mark the bit and turn the option into a 
+ * valid option.
+ */
+int config_default_opts;
+void inline set_default_bits(char *mopt)
+{
+	int dftlen = strlen("default");
+	char *field;
+
+	if (strncasecmp(mopt, "default", dftlen) != 0)
+		return;
+
+	field = mopt + dftlen;
+	if (strncasecmp(field, "proto", strlen("proto")) == 0) {
+		config_default_opts |= DEFAULT_PROTO;
+		strcpy(mopt, field);
+	} else if (strncasecmp(field, "vers", strlen("vers")) == 0) {
+			config_default_opts |= DEFAULT_VERS;
+			strcpy(mopt, field);
+	}
+}
 /*
  * Parse the given section of the configuration 
  * file to if there are any mount options set.
@@ -325,6 +349,7 @@ char *conf_get_mntopts(char *spec, char *mount_point,
 		strcat(config_opts, ",");
 	}
 	SLIST_FOREACH(entry, &head, entries) {
+		set_default_bits(entry->opt);
 		strcat(config_opts, entry->opt);
 		strcat(config_opts, ",");
 	}


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

* [PATCH 2/3] nfsmount.conf: New variables that explicitly set default (Release 2)
       [not found] ` <4AD3A0BA.3080104-AfCzQyP5zfLQT0dZR+AlfA@public.gmane.org>
  2009-10-12 21:37   ` [PATCH 1/3] " Steve Dickson
@ 2009-10-12 21:38   ` Steve Dickson
  2009-10-12 21:39   ` [PATCH 3/3] " Steve Dickson
  2 siblings, 0 replies; 4+ messages in thread
From: Steve Dickson @ 2009-10-12 21:38 UTC (permalink / raw)
  To: linux-nfs

commit c1cf5467f3e6355b8cb19ecda5688895b912bf49
Author: Steve Dickson <steved@redhat.com>
Date:   Mon Oct 12 17:08:59 2009 -0400

    If a mount fails due to the server not supporting the
    version or network proto and either one of those options
    were set as defaults in the configuration file, retry
    the mount, after removing the options from list optlist
    allow the mount to negotiate to the supported version
    or network protocol.
    
    Signed-off-by: Steve Dickson <steved@redhat.com>

diff --git a/utils/mount/stropts.c b/utils/mount/stropts.c
index 069bdc1..35b0797 100644
--- a/utils/mount/stropts.c
+++ b/utils/mount/stropts.c
@@ -92,6 +92,13 @@ struct nfsmount_info {
 				child;		/* forked bg child? */
 };
 
+#ifdef MOUNT_CONFIG
+#include "conffile.h"
+int inline config_defaults(struct nfsmount_info *mi);
+#else
+int inline config_defaults(struct nfsmount_info *mi) {return 0;}
+#endif
+
 /*
  * Obtain a retry timeout value based on the value of the "retry=" option.
  *
@@ -610,10 +617,22 @@ static int nfs_try_mount(struct nfsmount_info *mi)
 	case 2:
 	case 3:
 		result = nfs_try_mount_v3v2(mi);
+		if (result)
+			break;
+
+		if (config_defaults(mi))
+			result = nfs_try_mount_v3v2(mi);
 		break;
+
 	case 4:
 		result = nfs_try_mount_v4(mi);
+		if (result)
+			break;
+
+		if (config_defaults(mi))
+			result = nfs_try_mount_v3v2(mi);
 		break;
+
 	default:
 		errno = EIO;
 	}
@@ -819,3 +838,36 @@ int nfsmount_string(const char *spec, const char *node, const char *type,
 	free(mi.hostname);
 	return retval;
 }
+
+#ifdef MOUNT_CONFIG
+/*
+ * If the mount fails due to a ENOSUPPORT type of error
+ * and a default options were set in the configuration file
+ * try the mount again without that default options set.
+ */
+int inline config_defaults(struct nfsmount_info *mi)
+{
+	if (!config_default_opts)
+		return 0;
+
+	switch(mi->version) {
+	case 4:
+		if (errno != EPROTONOSUPPORT)
+			return 0;
+		break;
+	case 3:
+		if (errno != ESPIPE)
+			return 0;
+		break;
+	default:
+		return 0;
+	}
+	if (config_default_opts && DEFAULT_VERS)
+		po_remove_all(mi->options, "vers");
+
+	if (config_default_opts && DEFAULT_PROTO)
+		po_remove_all(mi->options, "proto");
+
+	return 1;
+}
+#endif


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

* [PATCH 3/3] nfsmount.conf: New variables that explicitly set default (Release 2)
       [not found] ` <4AD3A0BA.3080104-AfCzQyP5zfLQT0dZR+AlfA@public.gmane.org>
  2009-10-12 21:37   ` [PATCH 1/3] " Steve Dickson
  2009-10-12 21:38   ` [PATCH 2/3] " Steve Dickson
@ 2009-10-12 21:39   ` Steve Dickson
  2 siblings, 0 replies; 4+ messages in thread
From: Steve Dickson @ 2009-10-12 21:39 UTC (permalink / raw)
  To: linux-nfs

commit c85cfe6d6f484cb02ee792a81c907b2274a98fd8
Author: Steve Dickson <steved@redhat.com>
Date:   Mon Oct 12 17:16:56 2009 -0400

    Added the defaultproto and defaultvers variable to the mount
    configuration file.
    
    Signed-off-by: Steve Dickson <steved@redhat.com>

diff --git a/utils/mount/nfsmount.conf b/utils/mount/nfsmount.conf
index 991838f..0d65056 100644
--- a/utils/mount/nfsmount.conf
+++ b/utils/mount/nfsmount.conf
@@ -28,10 +28,24 @@
 # This statically named section defines global mount 
 # options that can be applied on all NFS mount.
 #
-# Protocol Version [2,3]
-# Nfsvers=3
-#
-# Network Transport [udp,tcp,rdma] (Note: values are case sensitive)
+# Protocol Version [2,3,4]
+# This defines the default protocol version which will
+# be used to start the negotiation with the server.
+# defaultvers=4
+#
+# Setting this option makes it mandatory the server supports the
+# given version. The mount will fail if the given version is 
+# not support by the server. 
+# Nfsvers=4
+#
+# Network Protocol [udp,tcp,rdma] (Note: values are case sensitive)
+# This defines the default network protocol which will
+# be used to start the negotiation with the server.
+# defaultproto=tcp
+#
+# Setting this option makes it mandatory the server supports the
+# given network protocol. The mount will fail if the given network
+# protocol is not supported by the server.
 # Proto=tcp
 #
 # The number of times a request will be retired before 


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

end of thread, other threads:[~2009-10-12 21:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-12 21:33 [PATCH 0/3] nfsmount.conf: New variables that explicitly set default (Release 2) Steve Dickson
     [not found] ` <4AD3A0BA.3080104-AfCzQyP5zfLQT0dZR+AlfA@public.gmane.org>
2009-10-12 21:37   ` [PATCH 1/3] " Steve Dickson
2009-10-12 21:38   ` [PATCH 2/3] " Steve Dickson
2009-10-12 21:39   ` [PATCH 3/3] " Steve Dickson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.