Chuck Lever [Fri, 28 Sep 2007 20:37:06 +0000 (16:37 -0400)]
text-based mount.nfs: Fix mounthost= processing
The 'mounthost=' option names a host where the mountd service is running.
The option is used to direct clients to use a different host for the mountd
procotol than the host where the NFS service is running.
The nfs(5) man page shows that the 'mounthost=' option takes a name, not
an address. The kernel's text-based mount option parsing logic expects an
IPv4 address. This is necessary because the kernel cannot itself resolve
hostnames to addresses.
Resolve the hostname and pass in a new mount option that contains the
resolved address, 'mountaddr=', to the kernel.
This requires a patch to the kernel to recognize the new 'mountaddr='
option, and to change the 'mounthost=' parsing logic to treat the value of
this option as a simple string.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Neil Brown <neilb@suse.de>
Chuck Lever [Fri, 28 Sep 2007 20:37:01 +0000 (16:37 -0400)]
text-based mount.nfs: Clean up helper functions that are no longer used
Remove older string parsing functions in the text-based mount.nfs
implementation that are now no longer used.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Neil Brown <neilb@suse.de>
Chuck Lever [Fri, 28 Sep 2007 20:36:56 +0000 (16:36 -0400)]
text-based mount.nfs: start using new mount option parsing facility
Use the new mount option parsing functions to handle existing mount
option string parsing needs in the text-based mount implementation.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Neil Brown <neilb@suse.de>
Chuck Lever [Fri, 28 Sep 2007 20:36:51 +0000 (16:36 -0400)]
text-based mount.nfs: add parser init and destroy calls
Introduce parser init and destroy calls in the main text-based mount
handling routines. Don't actually use the parsed option object yet.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Neil Brown <neilb@suse.de>
Chuck Lever [Fri, 28 Sep 2007 20:36:45 +0000 (16:36 -0400)]
text-based mount.nfs: prepare for more complex error exit handling
I'm about to add an object or two that needs to be freed before the main
functions exit. Prepare the logic by adding an 'out' label and some
goto's.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Neil Brown <neilb@suse.de>
Chuck Lever [Fri, 28 Sep 2007 20:36:40 +0000 (16:36 -0400)]
text-based mount.nfs: Use new parser to handle 'addr=' and 'clientaddr='
Introduce, but don't yet use, functions that will eventually replace
append_addr_opt() and append_clientaddr_opt().
Note the behavioral change in append_addr_opt() -- it simply removes
any previous 'addr=' rather than throwing an error.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Neil Brown <neilb@suse.de>
Chuck Lever [Fri, 28 Sep 2007 20:36:35 +0000 (16:36 -0400)]
text-based mount.nfs: parse option strings into lists
Adapt a parsing trick used by Python.
Parse mount option strings into an abstract data type so we don't have to
copy and/or tokenize the whole option string multiple times while trying
to manipulate the mount options. Then, just before calling the mount(2)
system call, convert the object back into a C string.
One major advantage of this approach is that we can copy the final version
of the mount options into /etc/mtab when we're done, instead of copying in
the original mount options that the user specified. Any fallback from NFS
v3 to NFS v2 or TCP to UDP that was done by mount.nfs will be reflected in
/etc/mtab.
This patch adds methods for creating and manipulating mount option data
objects.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Neil Brown <neilb@suse.de>
Chuck Lever [Fri, 28 Sep 2007 20:36:30 +0000 (16:36 -0400)]
mount.nfs: add new string tokenizer facility
To quote the strtok(3) man page: "Avoid using these functions."
OK. We've created our own. The main reason for this is that strtok(3)
doesn't handle quoted delimiters at all. We need to handle this:
context="foo,bar"
where 'context' is a single mount option that sets a token string that
possibly uses the same delimiter that the mount command uses to separate
options (that is, a comma).
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Neil Brown <neilb@suse.de>
Jeff Layton [Thu, 27 Sep 2007 10:54:04 +0000 (06:54 -0400)]
rpc.mountd: add new mode for handling netgroup-heavy configurations
If a host is a member of a large number of netgroups, it becomes easily
possible for client_compose to generate a m_hostname string that
overflows the maximum string length allowed by the kernel caches.
This patch adds a new mode for mountd where it will map IP address to IP
address in the auth.unix.ip cache. When this enabled, mountd doesn't
bother using client_compose to build the m_hostname string. It just
populates it with the dotted-quad ip address. When mountd handles a
mount request, it then has an IP address and a path. It then calls
client_check to check the host against export entries where the path has
already matched.
Since we don't bother looking up netgroups which have no relation to the
mount, this can be a big performance gain in netgroup-heavy
configurations. The downside is that every host has a corresponding
entry in the nfsd.export and nfsd.fh caches as well as the auth.unix.ip
cache.
The new behavior is automatically enabled if the length of all of the
concatenated netgroup names in the export table is longer than half
NFSCLNT_IDMAX. The rationale for this logic is that this should allow
for a host to be a member of a long list of netgroups while still
allowing for other matches.
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:58 +0000 (06:53 -0400)]
rpc.mountd: create client_resolve and change client_compose to take a hostent arg
This moves the resolution of IP address to hostent into a helper function
and has other functions call it. Having client_compose take a hostent arg
allows us to avoid an extra hostname lookup in the auth_authenticate
codepath as well. Instead of redoing this lookup in client_compose, we can
simply reuse the hostent that was already generated in auth_authenticate.
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:53 +0000 (06:53 -0400)]
rpc.mountd: make exportent->e_hostname a dynamically-allocated string
This makes the e_hostname field of the exportent into a pointer to a
dynamically allocated string. This is necessary since this is field is
often filled out from the m_hostname. This too adds a few
micro-optimizations as we can avoid copying the string in some places
and simply pass a pointer to the original string instead.
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: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:36 +0000 (11:29 -0400)]
Don't do_nfs_umount() for NFSv4 unmounts
No need to talk to mountd when unmounting nfs4 filesystems.
Signed-off-by: Kevin Coffman <kwc@citi.umich.edu>
Acked-by: Chuck Lever <chuck.lever@oracle.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:26 +0000 (11:29 -0400)]
umount.nfs: Refactor remount logic in umount.nfs
Clean up: move the remount logic into its own function. This makes it
easier to fix a bug in the next patch.
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:20 +0000 (11:29 -0400)]
umount.nfs: Fix white space damage in nfsumount.c
Replace leading blanks with tabs in del_mtab().
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:59 +0000 (11:28 -0400)]
text-based mount.nfs: Use "child" instead of "bg" for nfsmount_s
Match a recent change to nfs4mount_s -- eventually it will become clear why
these were renamed.
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:54 +0000 (11:28 -0400)]
mount.nfs: Don't leak mount_opts
A C string containing the user's requested mount options is constructed by
the main mount function in utils/mount/mount.c, but is never freed.
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:49 +0000 (11:28 -0400)]
mount.nfs: Don't leak extra_opts
The mount.nfs[4] command should properly release extra_opts before exiting.
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:44 +0000 (11:28 -0400)]
text-based mount.nfs: Fix memory leak in add_mtab()
The add_mtab() function in utils/mount/mount.c calls fix_opts_string() to
construct an /etc/mtab entry, but never frees the result.
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:38 +0000 (11:28 -0400)]
mount.nfs: teach [u]mount.nfs[4] to exit with EX_SUCCESS instead of 0
Use the newly defined EX_SUCCESS exit code in all the right places.
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>
Chuck Lever [Mon, 24 Sep 2007 15:28:28 +0000 (11:28 -0400)]
mount.nfs: Provide comments for public network functions
Clean up: Document public functions in util/mount/network.c with block
comments.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Neil Brown <neilb@suse.de>
Kevin Coffman [Fri, 7 Sep 2007 14:18:40 +0000 (10:18 -0400)]
Fix the usage message for gssd to reflect new option
Fix the usage message for gssd to reflect new -M option added in 1.1.0
Signed-off-by: Kevin Coffman <kwc@citi.umich.edu>
Signed-off-by: Neil Brown <neilb@suse.de>
Kevin Coffman [Fri, 7 Sep 2007 14:18:35 +0000 (10:18 -0400)]
Change to a dependency on libgssglue rather than libgssapi
From: Guillaume Rousse <Guillaume.Rousse@inria.fr>
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>
Chuck Lever [Tue, 4 Sep 2007 20:13:55 +0000 (16:13 -0400)]
mount.nfs: Update description of clientaddr= in nfs(5)
The description of clientaddr= in nfs(5) is out of date and omits some
other typical reasons for using it. Expand its description.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Neil Brown <neilb@suse.de>
Chuck Lever [Tue, 4 Sep 2007 20:13:50 +0000 (16:13 -0400)]
mount.nfs: restore admin-specified clientaddr option
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:53 +0000 (13:11 -0400)]
mount.nfs: Add a block comment before mount_error() and umount_error()
Add block comments before mount_error() and umount_error() to help
distinguish them from the other error reporting 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:48 +0000 (13:11 -0400)]
mount.nfs: Remove get_my_ipv4addr() from utils/mount/stropts.c
The get_my_ipv4addr() function is no longer used, so remove it from
utils/mount/stropts.c.
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:43 +0000 (13:11 -0400)]
mount.nfs: Use get_client_addr() to build clientaddr= option
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:27 +0000 (13:11 -0400)]
mount.nfs: Use dynamically allocated character buffers
Replace the use of static character arrays with buffers allocated via
xstrdup() in stropts.c.
I added a couple of extra length checks; not sure if these are really
necessary.
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:22 +0000 (13:11 -0400)]
mount.nfs: Remove get_my_ipv4addr() from append_addr_opt()
The result of the get_my_ipv4addr() function is not used in
append_addr_opt(), so remove the call and the ip_addr variable.
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 [Fri, 24 Aug 2007 17:11:11 +0000 (13:11 -0400)]
mount.nfs: Fix nfs4mount_s prototype.
The definition of nfs4mount_s in utils/mount/stropts.c doesn't match the
prototype declared in utils/mount/stropts.h.
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:18 +0000 (12:19 -0400)]
mount.nfs: Combine two verbose messages into one
A little less noise.
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:13 +0000 (12:19 -0400)]
mount.nfs: getport() should avoid modifying passed-in arguments
Defensive coding: getport() shouldn't alter the passed-in server address,
but should treat it as read only. Have it operate on a copy.
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>
Neil Brown [Fri, 24 Aug 2007 03:11:00 +0000 (13:11 +1000)]
mount: Small tidy up.
1/ remove confusing sentence from a comment.
2/ remove needless 'exit' - just fall through to common exit.
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:
$ watch "nfsstat --since /tmp/stats; nfsstat >/tmp/stats"
Signed-off-by: David M. Richter <richterd@citi.umich.edu>
Signed-off-by: Neil Brown <neilb@suse.de>
david m. richter [Mon, 13 Aug 2007 19:15:57 +0000 (15:15 -0400)]
nfsstat: #define stat header labels.
Make #defines for the stat header labels, use for output, and add
to struct statinfo. This will be used by a subsequent patch for
-S/--since.
Signed-off-by: David M. Richter <richterd@citi.umich.edu>
Signed-off-by: Neil Brown <neilb@suse.de>
david m. richter [Mon, 13 Aug 2007 19:15:48 +0000 (15:15 -0400)]
nfsstat: Remove some pointer comparisons against global statinfos.
Pass-in an "is_srv" arg instead of doing pointer comparisons
against the static statinfo arrays themselves.
Signed-off-by: David M. Richter <richterd@citi.umich.edu>
Signed-off-by: Neil Brown <neilb@suse.de>
david m. richter [Mon, 13 Aug 2007 19:15:40 +0000 (15:15 -0400)]
nfsstat: Obviate and remove copy_stats().
Rather than copying stats during --sleep, instead introduce a few
pointers and rearrange them to avoid the copy. Will be useful with
--since, too.
Signed-off-by: David M. Richter <richterd@citi.umich.edu>
Signed-off-by: Neil Brown <neilb@suse.de>
david m. richter [Mon, 13 Aug 2007 19:15:31 +0000 (15:15 -0400)]
nfsstat: rename *_tmp variables to *_old.
To make a subsequent patch a little clearer, make it explicit that
current *_tmp variables are actually always/only the "old" set used in
comparisons.
Signed-off-by: David M. Richter <richterd@citi.umich.edu>
Signed-off-by: Neil Brown <neilb@suse.de>
Neil Brown [Fri, 10 Aug 2007 23:52:29 +0000 (09:52 +1000)]
Restrict -i option to root.
As it is still under development, don't expose it - just in case.
Signed-off-by: Neil Brown <neilb@suse.de>
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>
Chuck Lever [Fri, 10 Aug 2007 22:19:50 +0000 (18:19 -0400)]
mount.nfs: Replace a "return 0; " that should be an "exit(0); "
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:45 +0000 (18:19 -0400)]
mount.nfs: Treat another UDP/TCP pair of strings like the rest
See the error messages at the end of utils/mount/network.c:get_socket()
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Neil Brown <neilb@suse.de>
Chuck Lever [Thu, 9 Aug 2007 21:37:01 +0000 (17:37 -0400)]
umount.nfs: Update umount.nfs(8)
Account for recent changes to the umount.nfs command.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Neil Brown <neilb@suse.de>
Chuck Lever [Thu, 9 Aug 2007 21:36:56 +0000 (17:36 -0400)]
mount.nfs: Update the mount.nfs(8) man page
Account for recent changes to the mount.nfs command.
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.
david m. richter [Tue, 7 Aug 2007 23:53:48 +0000 (19:53 -0400)]
nfsstat: include -Z/--sleep in the manpage
Add a little blurb about -Z/--sleep to the nfsstat manpage.
Signed-off-by: David M. Richter <richterd@citi.umich.edu>
Signed-off-by: Neil Brown <neilb@suse.de>
david m. richter [Tue, 7 Aug 2007 23:53:11 +0000 (19:53 -0400)]
nfsstat: rename --diff-stat to --sleep
As per Bruce Fields' suggestion, rename the clunky -D/--diff-stat
to the more-intuitive -Z/--sleep.
Signed-off-by: David M. Richter <richterd@citi.umich.edu>
Signed-off-by: Neil Brown <neilb@suse.de>
david m. richter [Tue, 7 Aug 2007 23:53:00 +0000 (19:53 -0400)]
nfsstat: fix a bug in diff_stats()
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>
david m. richter [Tue, 7 Aug 2007 23:52:50 +0000 (19:52 -0400)]
nfsstat: add a comment to has_stats()
Clarify what has_stats() is actually doing.
Signed-off-by: David M. Richter <richterd@citi.umich.edu>
Signed-off-by: Neil Brown <neilb@suse.de>
david m. richter [Tue, 7 Aug 2007 23:52:39 +0000 (19:52 -0400)]
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>
Jeff Layton [Mon, 6 Aug 2007 23:18:58 +0000 (19:18 -0400)]
fix regression with rmtab handling in newer nfs-utils code
commit
dbfcba5b03481d49f3e78946fe8fd066e2025545
incorrectly added some mountlist_add calls.
Removed them again.
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Neil Brown <neilb@suse.de>
Chuck Lever [Fri, 3 Aug 2007 17:24:15 +0000 (13:24 -0400)]
mount.nfs: Fix background mounts
The new mount.nfs helper does not support background mounts. Add support
for background mounts.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Neil Brown <neilb@suse.de>
Chuck Lever [Fri, 3 Aug 2007 17:24:10 +0000 (13:24 -0400)]
mount.nfs: Refactor mount logic to allow support for "bg" option
Refactor main() a bit to make adding support for "bg" option easier.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Neil Brown <neilb@suse.de>
Chuck Lever [Fri, 3 Aug 2007 17:24:05 +0000 (13:24 -0400)]
mount.nfs: restore bg argument to nfsmount() and nfs4mount()
To enable background mounting again, restore the "bg" argument to
nfsmount() and nfs4mount() that was recently removed.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
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:54 +0000 (13:23 -0400)]
mount.nfs: Always close the socket at the end of getport()
These days, none of get_socket()'s callers pass an RPC_ANYSOCK on to the
RPC code.
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>
Chuck Lever [Fri, 3 Aug 2007 17:23:44 +0000 (13:23 -0400)]
mount.nfs: Remove a redundant port assignment
getport() always fills in its port number before calling GETPORT. No need
for the caller to do this.
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:39 +0000 (13:23 -0400)]
mount.nfs: umount needs to pick up transport option from /etc/mtab
Now that umount's default transport protocol has become more flexible, it
will need to detect both proto=udp and proto=tcp in /etc/mtab.
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:34 +0000 (13:23 -0400)]
mount.nfs: fix printf's normally hidden behind NFS_MOUNT_DEBUG
After I enabled NFS_MOUNT_DEBUG the compiler started spitting out warnings.
Fix up commas, output formatting, and double-wide character support.
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:29 +0000 (13:23 -0400)]
mount.nfs: Support double-wide characters in printed strings
Previous NLS changes missed a spot or two. This patch tries to get
most of them, but probably misses a few more.
In errors.c:mount_errors() I've removed a period at the end of the error
messages; this is consistent with other error messages I've examined.
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:42 +0000 (17:39 -0400)]
nfsstat: just declare -D/--diff-stat's variables
Add the temp vars -D/--diff-stat will use. (just using a separate
patch to make the next one easier to read)
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:30 +0000 (17:39 -0400)]
nfsstat: use macros to declare struct statinfo arrays
Use macros to build the arrays of struct statinfos. This will
make adding the extra set of temporary variables needed by -D/--diff-stat
much easier.
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>
david m. richter [Tue, 31 Jul 2007 21:39:11 +0000 (17:39 -0400)]
nfsstat: add get_stats()
Share some of the existing statistics-gathering code by folding it
into a function, get_stats().
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:02 +0000 (17:39 -0400)]
nfsstat: add has_stats()
To help readability, add has_stats() and use it when deciding
whether to print.
Signed-off-by: David M. Richter <richterd@citi.umich.edu>
Signed-off-by: Neil Brown <neilb@suse.de>
Neil Brown [Mon, 30 Jul 2007 06:33:39 +0000 (16:33 +1000)]
Fix more 'prototype' warnings and other warnings.
Signed-off-by: Neil Brown <neilb@suse.de>
Chuck Lever [Sat, 28 Jul 2007 21:51:06 +0000 (17:51 -0400)]
mount.nfs: clean up a couple of printfs in fstab.c
Clean up for consistent use.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
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:55 +0000 (17:50 -0400)]
libnfs.a: eliminate conn.c and conn.h
conn.[ch] are now no longer needed. Clean them out and delete them.
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:45 +0000 (17:50 -0400)]
libnfs.a: move get_socket() function to utils/mount/network.c
Now we can address the real problem: that get_socket() depends on the
global variable "verbose" which is only available in the mount command.
Move get_socket() into utils/mount/network.c, and make it static.
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:35 +0000 (17:50 -0400)]
libnfs.a: move more mount-only functions out of libnfs.a
Continue clean-up with nfsvers_to_mnt() and mntvers_to_nfs().
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:24 +0000 (17:50 -0400)]
mount.nfs: clean up getport() function
Mostly comment clarification. Also replace some naked undocumented
integers with macros, and make getport() static.
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:14 +0000 (17:50 -0400)]
umount.nfs: eliminate a nearly empty header file.
Clean-up: move nfsumount() global declaration to nfs_mount.h, and remove
nfsumount.h.
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:09 +0000 (17:50 -0400)]
umount.nfs: Pass return codes from do_nfs_umount back
Do we really care about these return codes?
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:59 +0000 (17:49 -0400)]
umount.nfs: make _nfsumount() static
_nfsumount() is never called outside of nfsumount.c. Also give it a more
conventional name.
Note that it's return code is ignored. That will be addressed in a
subsequent patch.
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:54 +0000 (17:49 -0400)]
umount.nfs: make del_mtab() a static function
Clean-up: del_mtab() isn't used outside of nfsumount.c.
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:49 +0000 (17:49 -0400)]
Make sure nfs_call_umount's callers are handling its return code correctly
umount.nfs is treating nfs_call_umount's return code like a standard mount
return code (EX_SOMETHING) when its really an RPC return code.
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:38 +0000 (17:49 -0400)]
umount.nfs: make umount_usage() static
No good reason to export umount_usage. Make it static.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Neil Brown <neilb@suse.de>