nfsmount.conf: New variables that explicitly set default (Release 2)
Subsystems (2)
cover nfsmount.conf: New variables that explicitly set default (Release 2)
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.
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/3 nfsmount.conf: New variables that explicitly set default (Release 2)
commit 7c9406cbfb7cf4d694890c6ddf7f4597b026cb7a
Author: Steve Dickson <[email protected]> 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.
support/include/conffile.h +8 -0
@@ -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_ */
utils/mount/configfile.c +25 -0
@@ -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,"," ); }
PATCH 2/3 nfsmount.conf: New variables that explicitly set default (Release 2)
In reply to a message not in the archivecommit c1cf5467f3e6355b8cb19ecda5688895b912bf49
Author: Steve Dickson <[email protected]> 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.
utils/mount/stropts.c +52 -0
@@ -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
PATCH 3/3 nfsmount.conf: New variables that explicitly set default (Release 2)
In reply to a message not in the archivecommit c85cfe6d6f484cb02ee792a81c907b2274a98fd8
Author: Steve Dickson <[email protected]> Date: Mon Oct 12 17:16:56 2009 -0400
Added the defaultproto and defaultvers variable to the mount configuration file.
utils/mount/nfsmount.conf +18 -4
@@ -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