1. 18 Jun, 2009 16 commits
    • Chuck Lever's avatar
      NFS: More "sloppy" parsing problems · a5a16bae
      Chuck Lever authored
      Specifying "port=-5" with the kernel's current mount option parser
      generates "unrecognized mount option".  If "sloppy" is set, this
      causes the mount to succeed and use the default values; the desired
      behavior is that, since this is a valid option with an invalid value,
      the mount should fail, even with "sloppy."
      
      To properly handle "sloppy" parsing, we need to distinguish between
      correct options with invalid values, and incorrect options.  We will
      need to parse integer values by hand, therefore, and not rely on
      match_token().
      
      For instance, these must all fail with "invalid value":
      
      	port=12345678
      	port=-5
      	port=samuel
      
      and not with "unrecognized option," as they do currently.
      
      Thus, for the sake of match_token() we need to treat the values for
      these options as strings, and do the conversion to integers using
      strict_strtol().
      
      This is basically the same solution we used for the earlier "retry="
      fix (commit ecbb3845), except in this case the kernel actually has to
      parse the value, rather than ignore it.
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
      a5a16bae
    • Chuck Lever's avatar
      NFS: Invalid mount option values should always fail, even with "sloppy" · d23c45fd
      Chuck Lever authored
      Ian Kent reports:
      
      "I've noticed a couple of other regressions with the options vers
      and proto option of mount.nfs(8).
      
      The commands:
      
      mount -t nfs -o vers=<invalid version> <server>:/<path> /<mountpoint>
      mount -t nfs -o proto=<invalid proto> <server>:/<path> /<mountpoint>
      
      both immediately fail.
      
      But if the "-s" option is also used they both succeed with the
      mount falling back to defaults (by the look of it).
      
      In the past these failed even when the sloppy option was given, as
      I think they should. I believe the sloppy option is meant to allow
      the mount command to still function for mount options (for example
      in shared autofs maps) that exist on other Unix implementations but
      aren't present in the Linux mount.nfs(8). So, an invalid value
      specified for a known mount option is different to an unknown mount
      option and should fail appropriately."
      
      See RH bugzilla 486266.
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
      d23c45fd
    • Chuck Lever's avatar
      NFS: Remove unused XDR decoder functions · 065015e5
      Chuck Lever authored
      Clean up: Remove xdr_decode_fhstatus() and xdr_decode_fhstatus3(), now
      that they are unused.
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
      065015e5
    • Chuck Lever's avatar
      NFS: Update MNT and MNT3 reply decoding functions · 8e02f6b9
      Chuck Lever authored
      Solder xdr_stream-based XDR decoding functions into the in-kernel mountd
      client that are more careful about checking data types and watching for
      buffer overflows.  The new MNT3 decoder includes support for auth-flavor
      list decoding.
      
      The "_sz" macro for MNT3 replies was missing the size of the file handle.
      I've added this back, and included the size of the auth flavor array.
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
      8e02f6b9
    • Chuck Lever's avatar
      NFS: add XDR decoder for mountd version 3 auth-flavor lists · a14017db
      Chuck Lever authored
      Introduce an xdr_stream-based XDR decoder that can unpack the auth-
      flavor list returned in a MNT3 reply.
      
      The nfs_mount() function's caller allocates an array, and passes the
      size and a pointer to it.  The decoder decodes all the flavors it can
      into the array, and returns the number of decoded flavors.
      
      If the caller is not interested in the auth flavors, it can pass a
      value of zero as the size of the pre-allocated array.
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
      a14017db
    • Chuck Lever's avatar
      NFS: add new file handle decoders to in-kernel mountd client · 4fdcd996
      Chuck Lever authored
      Introduce xdr_stream-based XDR file handle decoders to the in-kernel
      mountd client.  These are more careful than the existing decoder
      functions about buffer overflows and data type and range checking.
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
      4fdcd996
    • Chuck Lever's avatar
      NFS: Add separate mountd status code decoders for each mountd version · fb125295
      Chuck Lever authored
      Introduce data structures and xdr_stream-based decoding functions for
      unmarshalling mountd status codes properly.
      
      Mountd version 3 uses specific standard error return codes that are
      not errno values and not NFS3ERR_ values.  These have a well-defined
      standard mapping to local errno values.  Introduce data structures
      and a decoder function that map these status codes to local errno
      values properly.  This is new functionality (but not used yet).
      
      Version 1 mountd status values are defined by RFC 1094 as UNIX error
      values (errno values).  Errno values on heterogeneous systems do not
      necessarily match each other.  To avoid exposing possibly incorrect
      errno values to upper layers, the current XDR decoder converts all
      non-zero MNT version 1 status codes to -EACCES.
      
      The OpenGroup XNFS standard provides a mapping similar to but smaller
      than the version 3 error codes.  Implement a decoder that uses the XNFS
      error codes, replacing the current decoder.
      
      For both mountd protocol versions, map unrecognized errors to -EACCES.
      
      Finally we introduce a replacement data structure for mnt_fhstatus
      at this time, which is used by the new XDR decoders.  In addition to
      documenting that the status value returned by the XDR decoders is
      always an errno, this new structure will be expanded in subsequent
      patches.
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
      fb125295
    • Chuck Lever's avatar
      NFS: remove unused function in fs/nfs/mount_clnt.c · 99835db4
      Chuck Lever authored
      Clean up: remove xdr_encode_dirpath() now that it has been replaced.
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
      99835db4
    • Chuck Lever's avatar
      NFS: Use xdr_stream-based XDR encoder for MNT's dirpath argument · 29a1bd6b
      Chuck Lever authored
      Check the length of the supplied dirpath, and see that it fits
      properly in the RPC buffer.
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
      29a1bd6b
    • Chuck Lever's avatar
      NFS: Clean up MNT program definitions · 2ad78097
      Chuck Lever authored
      Clean up:  Relocate MNT program procedure number definitions to the
      only file that uses them.  Relocate the version number definitions,
      which are shared, to nfs.h.  Remove duplicate program number
      definitions.
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
      2ad78097
    • Chuck Lever's avatar
      lockd: Don't bother with RPC ping for NSM upcalls · 0e5c2632
      Chuck Lever authored
      Cut NSM upcall RPC traffic in half -- don't do a NULL call first.
      The cases where a ping would be helpful are rare.
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
      0e5c2632
    • Chuck Lever's avatar
      lockd: Update NSM state from SM_MON replies · 6c9dc425
      Chuck Lever authored
      When rpc.statd starts up in user space at boot time, it attempts to
      write the latest NSM local state number into
      /proc/sys/fs/nfs/nsm_local_state.
      
      If lockd.ko isn't loaded yet (as is the case in most configurations),
      that file doesn't exist, thus the kernel's NSM state remains set to
      its initial value of zero during lockd operation.
      
      This is a problem because rpc.statd and lockd use the NSM state number
      to prevent repeated lock recovery on rebooted hosts.  If lockd sends
      a zero NSM state, but then a delayed SM_NOTIFY with a real NSM state
      number is received, there is no way for lockd or rpc.statd to
      distinguish that stale SM_NOTIFY from an actual reboot.  Thus lock
      recovery could be performed after the rebooted host has already
      started reclaiming locks, and those locks will be lost.
      
      We could change /etc/init.d/nfslock so it always modprobes lockd.ko
      before starting rpc.statd.  However, if lockd.ko is ever unloaded
      and reloaded, we are back at square one, since the NSM state is not
      preserved across an unload/reload cycle.  This may happen frequently
      on clients that use automounter.  A period of NFS inactivity causes
      lockd.ko to be unloaded, and the kernel loses its NSM state setting.
      
      Instead, let's use the fact that rpc.statd plants the local system's
      NSM state in every SM_MON (and SM_UNMON) reply.  lockd performs a
      synchronous SM_MON upcall to the local rpc.statd _before_ sending its
      first NLM request to a new remote.  This would permit rpc.statd to
      provide the current NSM state to lockd, even after lockd.ko had been
      unloaded and reloaded.
      
      Note that NLMPROC_LOCK arguments are constructed before the
      nsm_monitor() call, so we have to rearrange argument construction very
      slightly to make this all work out.
      
      And, the kernel appears to treat NSM state as a u32 (see struct
      nlm_args and nsm_res).  Make nsm_local_state a u32 as well, to ensure
      we don't get bogus comparison results.
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
      6c9dc425
    • Chuck Lever's avatar
      NFS: Fix false error return from nfs_callback_up() if ipv6.ko is not available · 18fc3164
      Chuck Lever authored
      Clear "ret" if the error return from svc_create_xprt(AF_INET6) was
      -EAFNOSUPORT.  Otherwise, callback start-up will succeed, but
      nfs_callback_up() will return -EAFNOSUPPORT anyway, and the first
      NFSv4 mount attempt after a reboot will fail.
      
      Bug introduced by commit f738f517 in 2.6.30-rc1.
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
      18fc3164
    • Chuck Lever's avatar
      NFS: Return error code from nfs_callback_up() to user space · a21bdd9b
      Chuck Lever authored
      If the kernel cannot start the NFSv4 callback service during a mount
      request, it returns -ENOMEM to user space, resulting in this message:
      
         mount.nfs4: Cannot allocate memory
      
      Adjust nfs_alloc_client() and nfs_get_client() to pass NFSv4 callback
      start-up errors back to user space so a less mysterious error message
      can be displayed by the mount command.
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
      a21bdd9b
    • Chuck Lever's avatar
      NFS: Do not display the setting of the "intr" mount option · c381ad2c
      Chuck Lever authored
      The "intr" mount option has been deprecated for a while, but
      /proc/mounts continues to display "nointr" whether "intr" or "nointr"
      has been specified for a mount point.
      
      Since these options do not have any effect, simply do not display
      them.
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
      c381ad2c
    • Suresh Jayaraman's avatar
      NFS: add support for splice writes · bf40d343
      Suresh Jayaraman authored
      Adds support for splice writes. It effectively calls
      generic_file_splice_write() to do the writes.
      
      We need not worry about O_APPEND case as the combination of splice()
      writes and O_APPEND is disallowed. This patch propagates NFS write
      errors back to the caller. The number of bytes written via splice are
      being added to NFSIO_NORMALWRITTENBYTES as these are effectively
      cached writes.
      Signed-off-by: default avatarSuresh Jayaraman <sjayaraman@suse.de>
      Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
      bf40d343
  2. 17 Jun, 2009 24 commits