Jeff Layton [Thu, 27 Sep 2007 10:53:48 +0000 (06:53 -0400)]
rpc.mountd: Change nfs_client->m_hostname to be a dynamically-allocated string
Change nfs_client->m_hostname to be dynamically allocated rather than a
fixed length array of size NFSCLNT_IDMAX. This also adds a bit of
micro-optimization in a few places since it reduces the amount of string
copying that needs to be done.
Signed-off-by: Jeff Layton <jlayton@redhat.com> Acked-by: Steve Dickson <steved@redhat.com> Signed-off-by: Neil Brown <neilb@suse.de>
Jeff Layton [Thu, 27 Sep 2007 10:53:43 +0000 (06:53 -0400)]
rpc.mountd: fix memory leak and error handling in nfsd_fh
nfsd_fh() uses strdup for creating found_path and doesn't check the
return value. It also doesn't free this memory when the function
returns. Check the return value of strdup and return immediately
if it's NULL. Also, free found_path on exit.
Signed-off-by: Jeff Layton <jlayton@redhat.com> Acked-by: Steve Dickson <steved@redhat.com> Signed-off-by: Neil Brown <neilb@suse.de>
Chuck Lever [Mon, 24 Sep 2007 15:29:31 +0000 (11:29 -0400)]
umount.nfs: umount doesn't recognize a busy file system
umount.nfs shouldn't remove a busy file system from /etc/mtab, and should
report and return an error. I also added an extra "goto" to make the flow
of control more clear, and to reduce the chance that a future change in
this logic will break it.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Neil Brown <neilb@suse.de>
Chuck Lever [Mon, 24 Sep 2007 15:29:15 +0000 (11:29 -0400)]
mount.nfs: Add error messages for errors reported by text-based mount(2)
The text-based mount(2) system call API can return some additional errors
that we would like to report correctly to our users. These should be safe
to use with the legacy mount(2) ABI as well.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Neil Brown <neilb@suse.de>
Chuck Lever [Mon, 24 Sep 2007 15:29:10 +0000 (11:29 -0400)]
text-based mount.nfs: Add text-based error reporting function
The mount_errors() function prints an error based on what just happened in
the user-space RPC library. This is meaningless for text-based mounts,
since they don't use the RPC library for most things.
Add a new error printing function that the text-based logic can use to
report an error.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Neil Brown <neilb@suse.de>
Chuck Lever [Mon, 24 Sep 2007 15:29:05 +0000 (11:29 -0400)]
mount.nfs: rename mount_errors()
The function mount_errors() actually reports RPC errors generated by the
user-land RPC library. We're about to add a similar function for reporting
system call errors via errno, so rename mount_errors() to be more specific
about what it does.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Neil Brown <neilb@suse.de>
Chuck Lever [Mon, 24 Sep 2007 15:28:33 +0000 (11:28 -0400)]
mount.nfs: add EX_SUCCESS exit code
We've had some recent trouble, especially in the umount code, that appears
to be due to functions returning a 1 or a 0 return code when they should be
returning a mount exit code (such as EX_FAIL) or a 0.
To help clearly distinguish these two classes of functions, define an
EX_SUCCESS exit code, which is equal to zero.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Neil Brown <neilb@suse.de>
Use the renamed library libgssglue rather than libgssapi.
Also bump the required version for librpcsecgss (to the one that
also requires libgssglue rather than libgssapi).
Signed-off-by: Kevin Coffman <kwc@citi.umich.edu> Signed-off-by: Neil Brown <neilb@suse.de>
Revert an earlier change to make specifying the clientaddr= option illegal.
Jeff Layton pointed out that admins may want to specify the clientaddr=
option to advertise a different callback address when accessing an NFSv4
server through a NAT router.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Neil Brown <neilb@suse.de>
Chuck Lever [Fri, 24 Aug 2007 17:11:38 +0000 (13:11 -0400)]
mount.nfs: Create a new API to find out client's address
Provide a version of clnt_ping() that discovers the client's address, but
doesn't do an RPC ping. The in-kernel text-based mount code already does
a ping, so all we need here is address discovery.
As well, add a block comment in front of clnt_ping() that hopefully
elucidates the differences.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Neil Brown <neilb@suse.de>
Chuck Lever [Fri, 24 Aug 2007 17:11:32 +0000 (13:11 -0400)]
mount.nfs: Refactor parse_devname and fill_ipv4_addr
We will eventually need the server address in both append_addr_opt()
and append_clientaddr_opt(). Call parse_devname() and fill_ipv4_addr()
from the top level functions.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Neil Brown <neilb@suse.de>
Chuck Lever [Fri, 24 Aug 2007 17:11:16 +0000 (13:11 -0400)]
mount.nfs: Don't allow the user to specify addr= or clientaddr=.
The current mount.nfs implementation doesn't allow users to specify their
own addr= or clientaddr= option. The new string-based interface does
allow this, even though nfs(5) does not document 'addr=' and specifically
forbids adding 'clientaddr='.
Make the addition of either option by the user a permanent error.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Neil Brown <neilb@suse.de>
Chuck Lever [Tue, 21 Aug 2007 16:19:08 +0000 (12:19 -0400)]
mount.nfs: Replace fork() with daemon() for backgrounding mounts
Neil recommended this change to address a problem with background mount
processes handling signals properly during an init level change. It is
also useful for preventing background mount processes from reporting
progress on the parent's tty, which is generally just annoying noise.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Neil Brown <neilb@suse.de>
david m. richter [Mon, 13 Aug 2007 19:16:14 +0000 (15:16 -0400)]
nfsstat: Add -S/--since flag.
Read statistics from the file given with -S/--since and display
the difference between those and the current statistics. Valid stat files
are those in the form of /proc/net/rpc/nfs, /proc/net/rpc/nfsd, or any
"pretty" output from nfsstat itself. Statistics that are missing from a
"pretty" stat file are treated as zeroes.
Similar to Neil Brown's suggestion, one might use this in
conjunction with watch(1) like this:
Chuck Lever [Fri, 10 Aug 2007 22:20:01 +0000 (18:20 -0400)]
mount.nfs: Enable mount.nfs to do text-based mount support
A new command line option, "-i", is added to mount.nfs to force the use of
the string interface for testing purposes. "-s", "-t", and "-r" are
already taken or have legacy meaning so I picked "-i".
At some later point, when everyone is comfortable with the string mount
option parsing implementation, we will add a switch based on kernel
version, and remove the "-i" command line option. For now, I am more
comfortable enabling it by hand instead.
Since this is a temporary arrangement, I'm leaving the option undocumented
in the mount.nfs man page.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Neil Brown <neilb@suse.de>
Chuck Lever [Fri, 10 Aug 2007 22:19:55 +0000 (18:19 -0400)]
mount.nfs: Add new files for supporting string-ified mount options
Introduce support files which contain code that builds string mount
options and passes them to the kernel. This is a pre-requisite for
actually enabling /sbin/mount.nfs to do text-based mounts.
This is only partially complete at the moment, but is presented so that
folks can start banging on the kernel mount option string parsing code.
There are clearly still parts that are not implemented quite yet, such
as bg and retry support, but it should be enough to get going.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Neil Brown <neilb@suse.de>
Jeff Layton [Tue, 7 Aug 2007 12:01:08 +0000 (08:01 -0400)]
nfs-utils: specify a create mode with open(...O_CREAT) call in xflock
The xflock function can create a file via open() with O_CREAT, but does
not specify the create mode when it does so. I think 0644 should be
appropriate given the current usage of this function.
Signed-off-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Neil Brown <neilb@suse.de>
Neil Brown [Thu, 9 Aug 2007 01:23:24 +0000 (11:23 +1000)]
Remove ARCH-specific compile flags for ALPHA.
-mno-fp-regs -ffixed-8
are used for compiling the kernel on alphas, and it seems they
were copied into nfs-utils long ago, even though they have no
relevance now.
As we now use floating point (just a little bit in nfsstat), remove
these pointless flags.
Fix a bug in diff_stats() that causes false-positives in
has_stats(), which can result in a bunch of zeros being displayed instead
of suppressed as intended.
Signed-off-by: David M. Richter <richterd@citi.umich.edu> Signed-off-by: Neil Brown <neilb@suse.de>
nfsstat: display 3 additional NFSv4 client op counters
Display three extra NFSv4 client counters that are already exposed
in /proc/net/rpc/nfs: GETACL, SETACL, and FS_LOCATIONS. Won't cause
trouble on older kernels that might lack those counters.
Signed-off-by: David M. Richter <richterd@citi.umich.edu> Signed-off-by: Neil Brown <neilb@suse.de>
Chuck Lever [Fri, 3 Aug 2007 17:24:00 +0000 (13:24 -0400)]
mount.nfs: get_socket() may clobber errno, but preserves .re_errno
get_socket() guarantees that rpc_createerr.cf_error.re_errno is set
correctly after an error, but it can wipe errno if it has to print an error
message. Make sure that clnt_ping() checks the correct error code when
get_socket() returns.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Neil Brown <neilb@suse.de>
Chuck Lever [Fri, 3 Aug 2007 17:23:49 +0000 (13:23 -0400)]
mount.nfs: Shorter timeout for TCP connects
The standard TCP connect timeout on Linux is 75 seconds, which can be
too long in some cases. The timeout itself can be altered on a system-wide
basis, but we'd like mount to have it's own connect timeout that's tunable,
and defaults to a shorter value.
The get_socket() function is a utility function that does TCP connects for
getport, clnt_ping, and other functions. Add logic there to use a
non-blocking connect() and select() in order to time out a connect
operation that's taking too long.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Neil Brown <neilb@suse.de>
david m. richter [Tue, 31 Jul 2007 21:39:49 +0000 (17:39 -0400)]
nfsstat: add -D/--diff-stat
Add -D/--diff-stat: instead of immediately displaying total
collected NFS stats and exiting, nfsstat will take a snapshot of current
statistics and pause until the user hits ^C, at which point it takes a
second snapshot and then prints out the difference of the two; i.e.,
only the statistics collected during the pause.
Signed-off-by: David M. Richter <richterd@citi.umich.edu> Signed-off-by: Neil Brown <neilb@suse.de>
david m. richter [Tue, 31 Jul 2007 21:39:23 +0000 (17:39 -0400)]
nfsstat: standardize naming of opcount arrays
Standardized Naming 2: Make the client and server "call counts"
arrays' variable names reflect/include the actual text labels from the
/proc files -- e.g., "cltv2info" becomes "cltproc2info". A subsequent
patch will rely on this naming scheme.
Signed-off-by: David M. Richter <richterd@citi.umich.edu> Signed-off-by: Neil Brown <neilb@suse.de>
david m. richter [Tue, 31 Jul 2007 21:39:16 +0000 (17:39 -0400)]
nfsstat: standardize naming of server variables
Standardized Naming 1: Instead of having a variety of different
server-related variable name prefixes ("srv", "svr", "svc", "SVC"), set
them all to "srv" or "SRV". A subsequent patch will rely on this naming
scheme.
Signed-off-by: David M. Richter <richterd@citi.umich.edu> Signed-off-by: Neil Brown <neilb@suse.de>
Chuck Lever [Sat, 28 Jul 2007 21:51:00 +0000 (17:51 -0400)]
libnfs.a: eliminate another dependency on a global variable
The file support/nfs/fstab.c, which is linked into libnfs.a, depends on the
global variable "verbose." This variable is defined and used only in the
mount command, and the functions in fstab.c are used only by the mount
command.
Move fstab.c and support/include/fstab.h to utils/mount. This file
placement is also consistent with at least one other mount helper,
mount.ocfs2.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Neil Brown <neilb@suse.de>
Chuck Lever [Sat, 28 Jul 2007 21:50:50 +0000 (17:50 -0400)]
mount.nfs: use nfs_error instead of fprintf in get_socket()
Use nfs_error() where appropriate. I used "goto" here to reduce string
splitting and indenting past the point of readability. Gee, it would be
nice if C had proper exception handling...
Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Neil Brown <neilb@suse.de>
Chuck Lever [Sat, 28 Jul 2007 21:50:40 +0000 (17:50 -0400)]
libnfs.a: move clnt_ping() to utils/mount
Continue clean up of mount functionality in libnfs.a by moving clnt_ping()
to utils/mount/network.c. Note that socklen_t is an unsigned int... the
i386 gcc compiler threw a signedness warning about the 3rd argument of
getsockname().
Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Neil Brown <neilb@suse.de>
Chuck Lever [Sat, 28 Jul 2007 21:50:30 +0000 (17:50 -0400)]
libnfs.a: move mnt_{open, close}clnt calls to utils/mount/network.c
It turns out that get_socket() accesses a global variable, "verbose," that
is only available in the mount command; yet it's in libnfs.a. This creates
an undocumented API dependency that will bite someone someday. This
mount-specific functionality doesn't really belong in libnfs.a anyway.
The simplest way to resolve this is to move all of the functions in
support/nfs/conn.c into utils/mount. network.c seems like the logical
place to put these. An added benefit is we eventually get to make
get_socket() static.
Let's start with the mnt_{open,close}clnt functions.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Neil Brown <neilb@suse.de>
Chuck Lever [Sat, 28 Jul 2007 21:50:19 +0000 (17:50 -0400)]
mount.nfs: fix hang when getport() uses TCP against unavailable servers
If get_socket() can't get us an open TCP socket, we know the server is
down, so make getport() exit early instead of hanging. This logic is
copied from clnt_ping().
Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Neil Brown <neilb@suse.de>
Chuck Lever [Sat, 28 Jul 2007 21:50:04 +0000 (17:50 -0400)]
umount.nfs: Make do_nfs_mount use conventional EX_ style return codes
do_nfs_mount() should return EX_ style return codes and not 1 or 0 in order
to distinguish between usage errors and other problems (such as EX_FILEIO
or RPC errors).
Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Neil Brown <neilb@suse.de>
Chuck Lever [Sat, 28 Jul 2007 21:49:43 +0000 (17:49 -0400)]
umount.nfs: move nfs_call_umount to network.c
nfs_call_umount() is shared by nfsmount.c and nfsumount.c, and manages a
network function (building the RPC umount call to the server's MNT daemon).
So move it to network.c with other network-related functions.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Neil Brown <neilb@suse.de>
Chuck Lever [Sat, 28 Jul 2007 21:49:28 +0000 (17:49 -0400)]
umount.nfs: some umount.nfs error return codes are confusing
umount.nfs should return the standard EX_ mount return codes. At some
point in the past, it was returning 0 for failure and 1 for success, and
some of these have been changed and some haven't. See if we can rectify
this.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Neil Brown <neilb@suse.de>
J. Bruce Fields [Thu, 26 Jul 2007 20:30:46 +0000 (16:30 -0400)]
Use __fpurge to ensure single-line writes to cache files
On a recent Debian/Sid machine, I saw libc retrying stdio writes that
returned write errors. The result is that if an export downcall returns
an error (which it can in normal operation, since it currently
(incorrectly) returns -ENOENT on any negative downcall), then subsequent
downcalls will write multiple lines (including the original line that
received the error).
The result is that the server fails to respond to any rpc call that
refers to an unexported mount point (such as a readdir of a directory
containing such a mountpoint), so client commands hang.
I don't know whether this libc behavior is correct or expected, but it
seems safest to add the __fpurge() (suggested by Neil) to ensure data is
thrown away.
Signed-off-by: "J. Bruce Fields" <bfields@citi.umich.edu> Signed-off-by: Neil Brown <neilb@suse.de>
Chuck Lever [Mon, 16 Jul 2007 20:29:22 +0000 (16:29 -0400)]
mount.nfs: Error handling clean-up
o Use nfs_error( _() ) instead of fprintf(stderr,
o Use the mount return code macros instead of bare integers
o Free mount_point after it has been canonicalized
Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Neil Brown <neilb@suse.de>