public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/7] Patches for nfs-utils-1.1.3
@ 2008-06-30 17:10 Chuck Lever
       [not found] ` <20080630170420.9905.90111.stgit-ewv44WTpT0t9HhUboXbp9zCvJB+x5qRC@public.gmane.org>
  0 siblings, 1 reply; 9+ messages in thread
From: Chuck Lever @ 2008-06-30 17:10 UTC (permalink / raw)
  To: steved; +Cc: linux-nfs

Hi Steve-

Please consider these patches to be part of nfs-utils-1.1.3.  They include a
number of clean-ups, as well as support for the new "sloppy" option which
should help automounter.  Kernel support for "sloppy" is in Trond's devel
branch now, and should be upstream in 2.6.27.

The getaddrinfo(3) changes enable the mount.nfs and umount.nfs commands for
IPv6 in the future, but should be harmless to include now.  I would like to
know if there are any problems with this before we push forward with IPv6, so
please consider this for 1.1.3.

---

Chuck Lever (7):
      text-based mount command: pass "sloppy" when -s is set
      mount command: move function to get kernel version to separate header
      mount: Introduce IPv6-aware DNS resolver API function
      nfs-utils: Add dependency for getaddrinfo(3) in configure.ac
      mount command: don't include headers multiple times
      text-based mount command: Make "internal error" message more explicit
      Python scripts:  Report bandwidth in "kB/s" instead of "Kb/s"


 configure.ac                   |    3 ++
 tools/mountstats/mountstats.py |    8 ++--
 tools/nfs-iostat/nfs-iostat.py |    2 +
 utils/mount/Makefile.am        |    2 +
 utils/mount/error.c            |    7 +++-
 utils/mount/error.h            |    5 +++
 utils/mount/fstab.h            |    7 ++--
 utils/mount/mount.c            |   18 +--------
 utils/mount/mount_constants.h  |    6 ++-
 utils/mount/network.c          |   78 ++++++++++++++++++++++++++++++----------
 utils/mount/network.h          |    7 ++++
 utils/mount/nfs_mount.h        |    6 ++-
 utils/mount/nfsmount.c         |    5 +--
 utils/mount/parse_opt.h        |    5 +++
 utils/mount/stropts.c          |   22 ++++++++++-
 utils/mount/stropts.h          |    5 +++
 utils/mount/token.h            |    5 +++
 utils/mount/version.h          |   51 ++++++++++++++++++++++++++
 18 files changed, 183 insertions(+), 59 deletions(-)
 create mode 100644 utils/mount/version.h

-- 
Chuck Lever
chu ckl eve rat ora cle dot com

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

* [PATCH 1/7] Python scripts: Report bandwidth in "kB/s" instead of "Kb/s"
       [not found] ` <20080630170420.9905.90111.stgit-ewv44WTpT0t9HhUboXbp9zCvJB+x5qRC@public.gmane.org>
@ 2008-06-30 17:10   ` Chuck Lever
  2008-06-30 17:10   ` [PATCH 2/7] text-based mount command: Make "internal error" message more explicit Chuck Lever
                     ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Chuck Lever @ 2008-06-30 17:10 UTC (permalink / raw)
  To: steved; +Cc: linux-nfs

The proper abbreviation for kilobytes per second is kB/s.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---

 tools/mountstats/mountstats.py |    8 ++++----
 tools/nfs-iostat/nfs-iostat.py |    2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)


diff --git a/tools/mountstats/mountstats.py b/tools/mountstats/mountstats.py
index f55595e..c475c9e 100644
--- a/tools/mountstats/mountstats.py
+++ b/tools/mountstats/mountstats.py
@@ -317,7 +317,7 @@ class DeviceData:
         else:
             print '\t0.00'
 
-        # reads:  ops/s, Kb/s, avg rtt, and avg exe
+        # reads:  ops/s, kB/s, avg rtt, and avg exe
         # XXX: include avg xfer size and retransmits?
         read_rpc_stats = self.__rpc_data['READ']
         ops = float(read_rpc_stats[0])
@@ -325,7 +325,7 @@ class DeviceData:
         rtt = float(read_rpc_stats[6])
         exe = float(read_rpc_stats[7])
 
-        print '\treads:\tops/s\t\tKb/s\t\tavg RTT (ms)\tavg exe (ms)'
+        print '\treads:\tops/s\t\tkB/s\t\tavg RTT (ms)\tavg exe (ms)'
         print '\t\t%.2f' % (ops / sample_time),
         print '\t\t%.2f' % (kilobytes / sample_time),
         if ops != 0:
@@ -335,7 +335,7 @@ class DeviceData:
             print '\t\t0.00',
             print '\t\t0.00'
 
-        # writes:  ops/s, Kb/s, avg rtt, and avg exe
+        # writes:  ops/s, kB/s, avg rtt, and avg exe
         # XXX: include avg xfer size and retransmits?
         write_rpc_stats = self.__rpc_data['WRITE']
         ops = float(write_rpc_stats[0])
@@ -343,7 +343,7 @@ class DeviceData:
         rtt = float(write_rpc_stats[6])
         exe = float(write_rpc_stats[7])
 
-        print '\twrites:\tops/s\t\tKb/s\t\tavg RTT (ms)\tavg exe (ms)'
+        print '\twrites:\tops/s\t\tkB/s\t\tavg RTT (ms)\tavg exe (ms)'
         print '\t\t%.2f' % (ops / sample_time),
         print '\t\t%.2f' % (kilobytes / sample_time),
         if ops != 0:
diff --git a/tools/nfs-iostat/nfs-iostat.py b/tools/nfs-iostat/nfs-iostat.py
index 649c1bd..9626d42 100644
--- a/tools/nfs-iostat/nfs-iostat.py
+++ b/tools/nfs-iostat/nfs-iostat.py
@@ -344,7 +344,7 @@ class DeviceData:
 
         op += ':'
         print '%s' % op.lower().ljust(15),
-        print '  ops/s\t\t   Kb/s\t\t  Kb/op\t\tretrans\t\tavg RTT (ms)\tavg exe (ms)'
+        print '  ops/s\t\t   kB/s\t\t  kB/op\t\tretrans\t\tavg RTT (ms)\tavg exe (ms)'
 
         print '\t\t%7.3f' % (ops / sample_time),
         print '\t%7.3f' % (kilobytes / sample_time),


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

* [PATCH 2/7] text-based mount command: Make "internal error" message more explicit
       [not found] ` <20080630170420.9905.90111.stgit-ewv44WTpT0t9HhUboXbp9zCvJB+x5qRC@public.gmane.org>
  2008-06-30 17:10   ` [PATCH 1/7] Python scripts: Report bandwidth in "kB/s" instead of "Kb/s" Chuck Lever
@ 2008-06-30 17:10   ` Chuck Lever
  2008-06-30 17:10   ` [PATCH 3/7] mount command: don't include headers multiple times Chuck Lever
                     ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Chuck Lever @ 2008-06-30 17:10 UTC (permalink / raw)
  To: steved; +Cc: linux-nfs

The text-based mount command displays the rather inexplicable "mount:
internal error" whenever it encounters a problem that is entirely
unexpected by its designers.

Let's beef that error message up to include instructions about reporting
the problem, and fix the error code returned by the mount option rewriting
logic so that also will no longer report "internal error".  An error in there
should generally only occur if there was an invalid mount option specified.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---

 utils/mount/error.c   |    7 ++++++-
 utils/mount/stropts.c |    7 ++++---
 2 files changed, 10 insertions(+), 4 deletions(-)


diff --git a/utils/mount/error.c b/utils/mount/error.c
index 147e919..5fd5705 100644
--- a/utils/mount/error.c
+++ b/utils/mount/error.c
@@ -231,8 +231,13 @@ void mount_error(const char *spec, const char *mount_point, int error)
 		rpc_mount_errors((char *)spec, 0, 0);
 		break;
 	case EIO:
+		nfs_error(_("%s: mount system call failed"), progname);
+		break;
 	case EFAULT:
-		nfs_error(_("%s: internal error"), progname);
+		nfs_error(_("%s: encountered unexpected error condition."),
+				progname);
+		nfs_error(_("%s: please report the error to" PACKAGE_BUGREPORT),
+				progname);
 		break;
 	default:
 		nfs_error(_("%s: %s"),
diff --git a/utils/mount/stropts.c b/utils/mount/stropts.c
index 967fd69..c8148c4 100644
--- a/utils/mount/stropts.c
+++ b/utils/mount/stropts.c
@@ -356,12 +356,13 @@ static struct mount_options *rewrite_mount_options(char *str)
 	clnt_addr_t nfs_server = { };
 	int p;
 
-	errno = EIO;
-
 	options = po_split(str);
-	if (!options)
+	if (!options) {
+		errno = EFAULT;
 		return NULL;
+	}
 
+	errno = EINVAL;
 	option = po_get(options, "addr");
 	if (option) {
 		nfs_server.saddr.sin_family = AF_INET;


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

* [PATCH 3/7] mount command: don't include headers multiple times
       [not found] ` <20080630170420.9905.90111.stgit-ewv44WTpT0t9HhUboXbp9zCvJB+x5qRC@public.gmane.org>
  2008-06-30 17:10   ` [PATCH 1/7] Python scripts: Report bandwidth in "kB/s" instead of "Kb/s" Chuck Lever
  2008-06-30 17:10   ` [PATCH 2/7] text-based mount command: Make "internal error" message more explicit Chuck Lever
@ 2008-06-30 17:10   ` Chuck Lever
  2008-06-30 17:10   ` [PATCH 4/7] nfs-utils: Add dependency for getaddrinfo(3) in configure.ac Chuck Lever
                     ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Chuck Lever @ 2008-06-30 17:10 UTC (permalink / raw)
  To: steved; +Cc: linux-nfs

Clean up: add the traditional pre-processor safety check in headers under
utils/mount to prevent them from being included multiple times.

For headers that already have this, use a more unique macro name to reduce the
probability that some other header may use the same macro.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---

 utils/mount/error.h           |    5 +++++
 utils/mount/fstab.h           |    7 +++----
 utils/mount/mount_constants.h |    6 +++---
 utils/mount/network.h         |    5 +++++
 utils/mount/nfs_mount.h       |    6 +++---
 utils/mount/parse_opt.h       |    5 +++++
 utils/mount/stropts.h         |    5 +++++
 utils/mount/token.h           |    5 +++++
 8 files changed, 34 insertions(+), 10 deletions(-)


diff --git a/utils/mount/error.h b/utils/mount/error.h
index 8b8e9ae..7126de5 100644
--- a/utils/mount/error.h
+++ b/utils/mount/error.h
@@ -21,6 +21,9 @@
  *
  */
 
+#ifndef _NFS_UTILS_MOUNT_ERROR_H
+#define _NFS_UTILS_MOUNT_ERROR_H
+
 char *nfs_strerror(int);
 
 void mount_error(const char *, const char *, int);
@@ -28,3 +31,5 @@ void rpc_mount_errors(char *, int, int);
 void sys_mount_errors(char *, int, int, int);
 
 void umount_error(int, const char *);
+
+#endif	/* _NFS_UTILS_MOUNT_ERROR_H */
diff --git a/utils/mount/fstab.h b/utils/mount/fstab.h
index 64c8355..37f17e1 100644
--- a/utils/mount/fstab.h
+++ b/utils/mount/fstab.h
@@ -1,5 +1,5 @@
-#ifndef _NFS_FSTAB_H
-#define _NFS_FSTAB_H
+#ifndef _NFS_UTILS_MOUNT_FSTAB_H
+#define _NFS_UTILS_MOUNT_FSTAB_H
 
 #include "nfs_mntent.h"
 
@@ -26,5 +26,4 @@ void lock_mtab (void);
 void unlock_mtab (void);
 void update_mtab (const char *special, struct mntent *with);
 
-#endif /* _NFS_FSTAB_H */
-
+#endif	/* _NFS_UTILS_MOUNT_FSTAB_H */
diff --git a/utils/mount/mount_constants.h b/utils/mount/mount_constants.h
index 4f3c729..cbfb099 100644
--- a/utils/mount/mount_constants.h
+++ b/utils/mount/mount_constants.h
@@ -1,5 +1,5 @@
-#ifndef _NFS_MOUNT_CONSTANTS_H
-#define _NFS_MOUNT_CONSTANTS_H
+#ifndef _NFS_UTILS_MOUNT_CONSTANTS_H
+#define _NFS_UTILS_MOUNT_CONSTANTS_H
 
 #ifndef MS_DIRSYNC
 #define MS_DIRSYNC	128	/* Directory modifications are synchronous */
@@ -64,4 +64,4 @@ if we have a stack or plain mount - mount atop of it, forming a stack. */
 #define MS_MGC_MSK 0xffff0000	/* magic flag number mask */
 #endif
 
-#endif /* _NFS_MOUNT_CONSTANTS_H */
+#endif	/* _NFS_UTILS_MOUNT_CONSTANTS_H */
diff --git a/utils/mount/network.h b/utils/mount/network.h
index 99ecc1e..e0a5dd5 100644
--- a/utils/mount/network.h
+++ b/utils/mount/network.h
@@ -21,6 +21,9 @@
  *
  */
 
+#ifndef _NFS_UTILS_MOUNT_NETWORK_H
+#define _NFS_UTILS_MOUNT_NETWORK_H
+
 #include <rpc/pmap_prot.h>
 #include <rpc/clnt.h>
 
@@ -60,3 +63,5 @@ unsigned long nfsvers_to_mnt(const unsigned long);
 
 CLIENT *mnt_openclnt(clnt_addr_t *, int *);
 void mnt_closeclnt(CLIENT *, int);
+
+#endif	/* _NFS_UTILS_MOUNT_NETWORK_H */
diff --git a/utils/mount/nfs_mount.h b/utils/mount/nfs_mount.h
index 7df8fb2..2becfb1 100644
--- a/utils/mount/nfs_mount.h
+++ b/utils/mount/nfs_mount.h
@@ -8,8 +8,8 @@
  * so it is easiest to ignore the kernel altogether (at compile time).
  */
 
-#ifndef _NFS_MOUNT_H
-#define _NFS_MOUNT_H
+#ifndef _NFS_UTILS_MOUNT_NFS_MOUNT_H
+#define _NFS_UTILS_MOUNT_NFS_MOUNT_H
 
 #include <netinet/in.h>
 #include <arpa/inet.h>
@@ -83,4 +83,4 @@ struct nfs_mount_data {
 int	nfsmount(const char *, const char *, int , char **, int, int);
 int	nfsumount(int, char **);
 
-#endif /* _NFS_MOUNT_H */
+#endif	/* _NFS_UTILS_MOUNT_NFS_MOUNT_H */
diff --git a/utils/mount/parse_opt.h b/utils/mount/parse_opt.h
index e7924dd..fb003c3 100644
--- a/utils/mount/parse_opt.h
+++ b/utils/mount/parse_opt.h
@@ -21,6 +21,9 @@
  *
  */
 
+#ifndef _NFS_UTILS_PARSE_OPT_H
+#define _NFS_UTILS_PARSE_OPT_H
+
 typedef enum {
 	PO_FAILED = 0,
 	PO_SUCCEEDED = 1,
@@ -50,3 +53,5 @@ char *			po_get(struct mount_options *, char *);
 po_rightmost_t		po_rightmost(struct mount_options *, char *, char *);
 po_found_t		po_remove_all(struct mount_options *, char *);
 void			po_destroy(struct mount_options *);
+
+#endif	/* _NFS_UTILS_PARSE_OPT_H */
diff --git a/utils/mount/stropts.h b/utils/mount/stropts.h
index b926d68..b4fd888 100644
--- a/utils/mount/stropts.h
+++ b/utils/mount/stropts.h
@@ -21,5 +21,10 @@
  *
  */
 
+#ifndef _NFS_UTILS_MOUNT_STROPTS_H
+#define _NFS_UTILS_MOUNT_STROPTS_H
+
 int nfsmount_string(const char *, const char *, const char *, int,
 			char **, int, int);
+
+#endif	/* _NFS_UTILS_MOUNT_STROPTS_H */
diff --git a/utils/mount/token.h b/utils/mount/token.h
index 47762dc..5a675ed 100644
--- a/utils/mount/token.h
+++ b/utils/mount/token.h
@@ -21,9 +21,14 @@
  *
  */
 
+#ifndef _NFS_UTILS_MOUNT_TOKEN_H
+#define _NFS_UTILS_MOUNT_TOKEN_H
+
 struct tokenizer_state;
 
 char *next_token(struct tokenizer_state *);
 struct tokenizer_state *init_tokenizer(char *, char);
 int tokenizer_error(struct tokenizer_state *);
 void end_tokenizer(struct tokenizer_state *);
+
+#endif	/* _NFS_UTILS_MOUNT_TOKEN_H */


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

* [PATCH 4/7] nfs-utils: Add dependency for getaddrinfo(3) in configure.ac
       [not found] ` <20080630170420.9905.90111.stgit-ewv44WTpT0t9HhUboXbp9zCvJB+x5qRC@public.gmane.org>
                     ` (2 preceding siblings ...)
  2008-06-30 17:10   ` [PATCH 3/7] mount command: don't include headers multiple times Chuck Lever
@ 2008-06-30 17:10   ` Chuck Lever
  2008-06-30 17:10   ` [PATCH 5/7] mount: Introduce IPv6-aware DNS resolver API function Chuck Lever
                     ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Chuck Lever @ 2008-06-30 17:10 UTC (permalink / raw)
  To: steved; +Cc: linux-nfs

Lots of parts of nfs-utils already depend on getaddrinfo(3).

We could find each instance where getaddrinfo(3) is invoked, wrap it with
#ifdef HAVE_GETADDRINFO, and provide equivalent logic without it, but that's
a whole lot of work... and no-one has complained about this so far.

So as a clean-up, let's simply add a hard dependency for it in configure.ac,
and call it a day.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---

 configure.ac |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)


diff --git a/configure.ac b/configure.ac
index 6ecbf55..d508c28 100644
--- a/configure.ac
+++ b/configure.ac
@@ -172,6 +172,9 @@ AC_CHECK_FUNC(connect, ,
       AC_CHECK_LIB(socket, connect, [LIBSOCKET="-lsocket"],
                 AC_MSG_ERROR(Function 'socket' not found.), $LIBNSL))
 
+AC_CHECK_FUNC(getaddrinfo, , ,
+                AC_MSG_ERROR(Function 'getaddrinfo' not found.))
+
 AC_CHECK_LIB(crypt, crypt, [LIBCRYPT="-lcrypt"])
 if test "$enable_nfsv4" = yes; then
     AC_CHECK_LIB(event, event_dispatch, [libevent=1], AC_MSG_ERROR([libevent needed for nfsv4 support]))


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

* [PATCH 5/7] mount: Introduce IPv6-aware DNS resolver API function
       [not found] ` <20080630170420.9905.90111.stgit-ewv44WTpT0t9HhUboXbp9zCvJB+x5qRC@public.gmane.org>
                     ` (3 preceding siblings ...)
  2008-06-30 17:10   ` [PATCH 4/7] nfs-utils: Add dependency for getaddrinfo(3) in configure.ac Chuck Lever
@ 2008-06-30 17:10   ` Chuck Lever
  2008-06-30 17:10   ` [PATCH 6/7] mount command: move function to get kernel version to separate header Chuck Lever
                     ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Chuck Lever @ 2008-06-30 17:10 UTC (permalink / raw)
  To: steved; +Cc: linux-nfs

Introduce a new DNS resolver function in utils/mount/network.c that uses
getaddrinfo(3), which supports AF_INET6, to resolve host names.

Replace the guts of nfs_gethostbyname() with a call to the new function.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---

 utils/mount/network.c |   78 +++++++++++++++++++++++++++++++++++++------------
 utils/mount/network.h |    2 +
 2 files changed, 61 insertions(+), 19 deletions(-)


diff --git a/utils/mount/network.c b/utils/mount/network.c
index ab7f6d0..30a4d40 100644
--- a/utils/mount/network.c
+++ b/utils/mount/network.c
@@ -144,32 +144,72 @@ static const unsigned long probe_mnt3_first[] = {
 };
 
 /**
+ * nfs_name_to_address - resolve hostname to an IPv4 or IPv6 socket address
+ * @hostname: pointer to C string containing DNS hostname to resolve
+ * @sap: pointer to buffer to fill with socket address
+ * @len: IN: size of buffer to fill; OUT: size of socket address
+ *
+ * Returns 1 and places a socket address at @sap if successful;
+ * otherwise zero.
+ */
+int nfs_name_to_address(const char *hostname,
+			const sa_family_t af_hint,
+			struct sockaddr *sap, socklen_t *salen)
+{
+	struct addrinfo *gai_results;
+	struct addrinfo gai_hint = {
+		.ai_family	= af_hint,
+		.ai_flags	= AI_ADDRCONFIG,
+	};
+	socklen_t len = *salen;
+	int error, ret = 0;
+
+	if (af_hint == AF_INET6)
+		gai_hint.ai_flags |= AI_V4MAPPED|AI_ALL;
+
+	*salen = 0;
+
+	error = getaddrinfo(hostname, NULL, &gai_hint, &gai_results);
+	if (error) {
+		nfs_error(_("%s: DNS resolution failed for %s: %s"),
+			progname, hostname, (error == EAI_SYSTEM ?
+				strerror(errno) : gai_strerror(error)));
+		return ret;
+	}
+
+	switch (gai_results->ai_addr->sa_family) {
+	case AF_INET:
+	case AF_INET6:
+		if (len >= gai_results->ai_addrlen) {
+			*salen = gai_results->ai_addrlen;
+			memcpy(sap, gai_results->ai_addr, *salen);
+			ret = 1;
+		}
+		break;
+	default:
+		/* things are really broken if we get here, so warn */
+		nfs_error(_("%s: unrecognized DNS resolution results for %s"),
+				progname, hostname);
+		break;
+	}
+
+	freeaddrinfo(gai_results);
+	return ret;
+}
+
+/**
  * nfs_gethostbyname - resolve a hostname to an IPv4 address
  * @hostname: pointer to a C string containing a DNS hostname
  * @saddr: returns an IPv4 address 
  *
  * Returns 1 if successful, otherwise zero.
  */
-int nfs_gethostbyname(const char *hostname, struct sockaddr_in *saddr)
+int nfs_gethostbyname(const char *hostname, struct sockaddr_in *sin)
 {
-	struct hostent *hp;
-
-	saddr->sin_family = AF_INET;
-	if (!inet_aton(hostname, &saddr->sin_addr)) {
-		if ((hp = gethostbyname(hostname)) == NULL) {
-			nfs_error(_("%s: can't get address for %s\n"),
-					progname, hostname);
-			return 0;
-		} else {
-			if (hp->h_length > sizeof(*saddr)) {
-				nfs_error(_("%s: got bad hp->h_length\n"),
-						progname);
-				hp->h_length = sizeof(*saddr);
-			}
-			memcpy(&saddr->sin_addr, hp->h_addr, hp->h_length);
-		}
-	}
-	return 1;
+	socklen_t len = sizeof(*sin);
+
+	return nfs_name_to_address(hostname, AF_INET,
+					(struct sockaddr *)sin, &len);
 }
 
 /*
diff --git a/utils/mount/network.h b/utils/mount/network.h
index e0a5dd5..9de13b5 100644
--- a/utils/mount/network.h
+++ b/utils/mount/network.h
@@ -51,6 +51,8 @@ static const struct timeval RETRY_TIMEOUT = { 3, 0 };
 
 int probe_bothports(clnt_addr_t *, clnt_addr_t *);
 int nfs_gethostbyname(const char *, struct sockaddr_in *);
+int nfs_name_to_address(const char *, const sa_family_t,
+		struct sockaddr *, socklen_t *);
 int get_client_address(struct sockaddr_in *, struct sockaddr_in *);
 int nfs_call_umount(clnt_addr_t *, dirpath *);
 int clnt_ping(struct sockaddr_in *, const unsigned long,


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

* [PATCH 6/7] mount command: move function to get kernel version to separate header
       [not found] ` <20080630170420.9905.90111.stgit-ewv44WTpT0t9HhUboXbp9zCvJB+x5qRC@public.gmane.org>
                     ` (4 preceding siblings ...)
  2008-06-30 17:10   ` [PATCH 5/7] mount: Introduce IPv6-aware DNS resolver API function Chuck Lever
@ 2008-06-30 17:10   ` Chuck Lever
  2008-06-30 17:10   ` [PATCH 7/7] text-based mount command: pass "sloppy" when -s is set Chuck Lever
  2008-07-15 19:30   ` [PATCH 0/7] Patches for nfs-utils-1.1.3 Steve Dickson
  7 siblings, 0 replies; 9+ messages in thread
From: Chuck Lever @ 2008-06-30 17:10 UTC (permalink / raw)
  To: steved; +Cc: linux-nfs

Share the code that reports the version of the running kernel.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---

 utils/mount/Makefile.am |    2 +-
 utils/mount/mount.c     |   18 +----------------
 utils/mount/nfsmount.c  |    5 ++---
 utils/mount/version.h   |   51 +++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 55 insertions(+), 21 deletions(-)
 create mode 100644 utils/mount/version.h


diff --git a/utils/mount/Makefile.am b/utils/mount/Makefile.am
index 27a01de..5a94631 100644
--- a/utils/mount/Makefile.am
+++ b/utils/mount/Makefile.am
@@ -13,7 +13,7 @@ mount_nfs_SOURCES = mount.c error.c network.c fstab.c token.c parse_opt.c \
 		    nfsmount.c nfs4mount.c stropts.c\
 		    nfsumount.c \
 		    mount_constants.h error.h network.h fstab.h token.h parse_opt.h \
-		    nfs4_mount.h nfs_mount4.h stropts.h
+		    nfs4_mount.h nfs_mount4.h stropts.h version.h
 
 mount_nfs_LDADD = ../../support/nfs/libnfs.a \
 		  ../../support/export/libexport.a
diff --git a/utils/mount/mount.c b/utils/mount/mount.c
index d7271a1..a7d5733 100644
--- a/utils/mount/mount.c
+++ b/utils/mount/mount.c
@@ -29,7 +29,6 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <sys/mount.h>
-#include <sys/utsname.h>
 #include <getopt.h>
 #include <mntent.h>
 #include <pwd.h>
@@ -47,6 +46,7 @@
 #include "error.h"
 #include "network.h"
 #include "stropts.h"
+#include "version.h"
 
 char *progname;
 int nfs_mount_data_version;
@@ -146,22 +146,6 @@ static const struct opt_map opt_map[] = {
   { NULL,	0, 0, 0		}
 };
 
-#define MAKE_VERSION(p,q,r)	(65536 * (p) + 256 * (q) + (r))
-
-int linux_version_code(void)
-{
-	struct utsname my_utsname;
-	int p, q, r;
-
-	if (uname(&my_utsname) == 0) {
-		p = atoi(strtok(my_utsname.release, "."));
-		q = atoi(strtok(NULL, "."));
-		r = atoi(strtok(NULL, "."));
-		return MAKE_VERSION(p,q,r);
-	}
-	return 0;
-}
-
 /*
  * Choose the version of the nfs_mount_data structure that is appropriate
  * for the kernel that is doing the mount.
diff --git a/utils/mount/nfsmount.c b/utils/mount/nfsmount.c
index 6a04518..b343a1f 100644
--- a/utils/mount/nfsmount.c
+++ b/utils/mount/nfsmount.c
@@ -67,6 +67,7 @@
 #include "nls.h"
 #include "error.h"
 #include "network.h"
+#include "version.h"
 
 #ifndef NFS_PORT
 #define NFS_PORT 2049
@@ -95,8 +96,6 @@ extern char *progname;
 extern int verbose;
 extern int sloppy;
 
-extern int linux_version_code(void);
-
 static inline enum clnt_stat
 nfs3_mount(CLIENT *clnt, mnt3arg_t *mnt3arg, mnt3res_t *mnt3res)
 {
@@ -808,7 +807,7 @@ noauth_flavors:
 	 * to avoid problems with multihomed hosts.
 	 * --Swen
 	 */
-	if (linux_version_code() <= 0x01030a && fsock != -1
+	if (linux_version_code() <= MAKE_VERSION(1, 3, 10) && fsock != -1
 	    && connect(fsock, (struct sockaddr *) nfs_saddr,
 		       sizeof (*nfs_saddr)) < 0) {
 		perror(_("nfs connect"));
diff --git a/utils/mount/version.h b/utils/mount/version.h
new file mode 100644
index 0000000..46552a1
--- /dev/null
+++ b/utils/mount/version.h
@@ -0,0 +1,51 @@
+/*
+ * version.h -- get running kernel version
+ *
+ * Copyright (C) 2008 Oracle.  All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 021110-1307, USA.
+ *
+ */
+
+#ifndef _NFS_UTILS_MOUNT_VERSION_H
+#define _NFS_UTILS_MOUNT_VERSION_H
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <sys/utsname.h>
+
+static inline unsigned int MAKE_VERSION(unsigned int p, unsigned int q,
+					unsigned int r)
+{
+	return (65536 * p) + (256 * q) + r;
+}
+
+static inline unsigned int linux_version_code(void)
+{
+	struct utsname my_utsname;
+	unsigned int p, q, r;
+
+	if (uname(&my_utsname))
+		return 0;
+
+	p = atoi(strtok(my_utsname.release, "."));
+	q = atoi(strtok(NULL, "."));
+	r = atoi(strtok(NULL, "."));
+	return MAKE_VERSION(p, q, r);
+}
+
+#endif	/* _NFS_UTILS_MOUNT_VERSION_H */


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

* [PATCH 7/7] text-based mount command: pass "sloppy" when -s is set
       [not found] ` <20080630170420.9905.90111.stgit-ewv44WTpT0t9HhUboXbp9zCvJB+x5qRC@public.gmane.org>
                     ` (5 preceding siblings ...)
  2008-06-30 17:10   ` [PATCH 6/7] mount command: move function to get kernel version to separate header Chuck Lever
@ 2008-06-30 17:10   ` Chuck Lever
  2008-07-15 19:30   ` [PATCH 0/7] Patches for nfs-utils-1.1.3 Steve Dickson
  7 siblings, 0 replies; 9+ messages in thread
From: Chuck Lever @ 2008-06-30 17:10 UTC (permalink / raw)
  To: steved; +Cc: linux-nfs

Currently the "-s" option is ignored by the text-based mount interface.  To
notify the kernel that sloppy mount option parsing is needed, add "sloppy"
to the string of mount options passed to the kernel.

The 2.6.23 - 2.6.26 kernels will fail the mount if "sloppy" is present, as
they won't recognize it.  To prevent them from ever seeing this option,
have the mount command check the kernel version before appending the option.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---

 utils/mount/stropts.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)


diff --git a/utils/mount/stropts.c b/utils/mount/stropts.c
index c8148c4..34b4134 100644
--- a/utils/mount/stropts.c
+++ b/utils/mount/stropts.c
@@ -45,6 +45,7 @@
 #include "error.h"
 #include "network.h"
 #include "parse_opt.h"
+#include "version.h"
 
 #ifdef HAVE_RPCSVC_NFS_PROT_H
 #include <rpcsvc/nfs_prot.h>
@@ -76,6 +77,7 @@
 extern int nfs_mount_data_version;
 extern char *progname;
 extern int verbose;
+extern int sloppy;
 
 struct nfsmount_info {
 	const char		*spec,		/* server:/path */
@@ -287,6 +289,16 @@ static int verify_lock_option(struct mount_options *options)
 	return 1;
 }
 
+static int nfs_append_sloppy_option(struct mount_options *options)
+{
+	if (!sloppy || linux_version_code() < MAKE_VERSION(2, 6, 27))
+		return 1;
+
+	if (po_append(options, "sloppy") == PO_FAILED)
+		return 0;
+	return 1;
+}
+
 /*
  * Set up mandatory NFS mount options.
  *
@@ -309,6 +321,9 @@ static int nfs_validate_options(struct nfsmount_info *mi)
 			return 0;
 	}
 
+	if (!nfs_append_sloppy_option(mi->options))
+		return 0;
+
 	if (!append_addr_option(&saddr, mi->options))
 		return 0;
 


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

* Re: [PATCH 0/7] Patches for nfs-utils-1.1.3
       [not found] ` <20080630170420.9905.90111.stgit-ewv44WTpT0t9HhUboXbp9zCvJB+x5qRC@public.gmane.org>
                     ` (6 preceding siblings ...)
  2008-06-30 17:10   ` [PATCH 7/7] text-based mount command: pass "sloppy" when -s is set Chuck Lever
@ 2008-07-15 19:30   ` Steve Dickson
  7 siblings, 0 replies; 9+ messages in thread
From: Steve Dickson @ 2008-07-15 19:30 UTC (permalink / raw)
  To: Chuck Lever; +Cc: linux-nfs



Chuck Lever wrote:
> Hi Steve-
> 
> Please consider these patches to be part of nfs-utils-1.1.3.  They include a
> number of clean-ups, as well as support for the new "sloppy" option which
> should help automounter.  Kernel support for "sloppy" is in Trond's devel
> branch now, and should be upstream in 2.6.27.
> 
> The getaddrinfo(3) changes enable the mount.nfs and umount.nfs commands for
> IPv6 in the future, but should be harmless to include now.  I would like to
> know if there are any problems with this before we push forward with IPv6, so
> please consider this for 1.1.3.
> 
> ---
> 
> Chuck Lever (7):
>       text-based mount command: pass "sloppy" when -s is set
>       mount command: move function to get kernel version to separate header
>       mount: Introduce IPv6-aware DNS resolver API function
>       nfs-utils: Add dependency for getaddrinfo(3) in configure.ac
>       mount command: don't include headers multiple times
>       text-based mount command: Make "internal error" message more explicit
>       Python scripts:  Report bandwidth in "kB/s" instead of "Kb/s"
> 
> 
>  configure.ac                   |    3 ++
>  tools/mountstats/mountstats.py |    8 ++--
>  tools/nfs-iostat/nfs-iostat.py |    2 +
>  utils/mount/Makefile.am        |    2 +
>  utils/mount/error.c            |    7 +++-
>  utils/mount/error.h            |    5 +++
>  utils/mount/fstab.h            |    7 ++--
>  utils/mount/mount.c            |   18 +--------
>  utils/mount/mount_constants.h  |    6 ++-
>  utils/mount/network.c          |   78 ++++++++++++++++++++++++++++++----------
>  utils/mount/network.h          |    7 ++++
>  utils/mount/nfs_mount.h        |    6 ++-
>  utils/mount/nfsmount.c         |    5 +--
>  utils/mount/parse_opt.h        |    5 +++
>  utils/mount/stropts.c          |   22 ++++++++++-
>  utils/mount/stropts.h          |    5 +++
>  utils/mount/token.h            |    5 +++
>  utils/mount/version.h          |   51 ++++++++++++++++++++++++++
>  18 files changed, 183 insertions(+), 59 deletions(-)
>  create mode 100644 utils/mount/version.h
> 

All seven patches are committed...

steved.


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

end of thread, other threads:[~2008-07-15 19:31 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-30 17:10 [PATCH 0/7] Patches for nfs-utils-1.1.3 Chuck Lever
     [not found] ` <20080630170420.9905.90111.stgit-ewv44WTpT0t9HhUboXbp9zCvJB+x5qRC@public.gmane.org>
2008-06-30 17:10   ` [PATCH 1/7] Python scripts: Report bandwidth in "kB/s" instead of "Kb/s" Chuck Lever
2008-06-30 17:10   ` [PATCH 2/7] text-based mount command: Make "internal error" message more explicit Chuck Lever
2008-06-30 17:10   ` [PATCH 3/7] mount command: don't include headers multiple times Chuck Lever
2008-06-30 17:10   ` [PATCH 4/7] nfs-utils: Add dependency for getaddrinfo(3) in configure.ac Chuck Lever
2008-06-30 17:10   ` [PATCH 5/7] mount: Introduce IPv6-aware DNS resolver API function Chuck Lever
2008-06-30 17:10   ` [PATCH 6/7] mount command: move function to get kernel version to separate header Chuck Lever
2008-06-30 17:10   ` [PATCH 7/7] text-based mount command: pass "sloppy" when -s is set Chuck Lever
2008-07-15 19:30   ` [PATCH 0/7] Patches for nfs-utils-1.1.3 Steve Dickson

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