1. 06 Sep, 2017 3 commits
    • NeilBrown's avatar
      NFS: flush data when locking a file to ensure cache coherence for mmap. · 779eafab
      NeilBrown authored
      When a byte range lock (or flock) is taken out on an NFS file, the
      validity of the cached data is checked and the inode is marked
      NFS_INODE_INVALID_DATA.  However the cached data isn't flushed from
      the page cache.
      
      This is sufficient for future read() requests or mmap() requests as
      they call nfs_revalidate_mapping() which performs the flush if
      necessary.
      
      However an existing mapping is not affected.  Accessing data through
      that mapping will continue to return old data even though the inode is
      marked NFS_INODE_INVALID_DATA.
      
      This can easily be confirmed using the 'nfs' tool in
        git://github.com/okirch/twopence-nfs.git
      and running
      
         nfs coherence FILENAME
      on one client, and
         nfs coherence -r FILENAME
      on another client.
      
      It appears that prior to Linux 2.6.0 this worked correctly.
      
      However commit:
      
      http://git.kernel.org/cgit/linux/kernel/git/history/history.git/commit/?id=ca9268fe3ddd075714005adecd4afbd7f9ab87d0
      
      removed the call to inode_invalidate_pages() from nfs_zap_caches().  I
      haven't tested this code, but inspection suggests that prior to this
      commit, file locking would invalidate all inode pages.
      
      This patch adds a call to nfs_revalidate_mapping() after a
      successful SETLK so that invalid data is flushed.  With this patch the
      above test passes.  To minimize impact (and possibly avoid a GETATTR
      call) this only happens if the mapping might be mapped into
      userspace.
      
      Cc: Olaf Kirch <okir@suse.com>
      Signed-off-by: default avatarNeilBrown <neilb@suse.com>
      Signed-off-by: default avatarTrond Myklebust <trond.myklebust@primarydata.com>
      779eafab
    • NeilBrown's avatar
      SUNRPC: remove some dead code. · f1ecbc21
      NeilBrown authored
      RPC_TASK_NO_RETRANS_TIMEOUT is set when cl_noretranstimeo
      is set, which happens when  RPC_CLNT_CREATE_NO_RETRANS_TIMEOUT is set,
      which happens when NFS_CS_NO_RETRANS_TIMEOUT is set.
      
      This flag means "don't resend on a timeout, only resend if the
      connection gets broken for some reason".
      
      cl_discrtry is set when RPC_CLNT_CREATE_DISCRTRY is set, which
      happens when NFS_CS_DISCRTRY is set.
      
      This flag means "always disconnect before resending".
      
      NFS_CS_NO_RETRANS_TIMEOUT and NFS_CS_DISCRTRY are both only set
      in nfs4_init_client(), and it always sets both.
      
      So we will never have a situation where only one of the flags is set.
      So this code, which tests if timeout retransmits are allowed, and
      disconnection is required, will never run.
      
      So it makes sense to remove this code as it cannot be tested and
      could confuse people reading the code (like me).
      
      (alternately we could leave it there with a comment saying
       it is never actually used).
      Signed-off-by: default avatarNeilBrown <neilb@suse.com>
      Signed-off-by: default avatarTrond Myklebust <trond.myklebust@primarydata.com>
      f1ecbc21
    • NeilBrown's avatar
      NFS: don't expect errors from mempool_alloc(). · 237f8306
      NeilBrown authored
      Commit fbe77c30 ("NFS: move rw_mode to nfs_pageio_header")
      reintroduced some pointless code that commit 518662e0 ("NFS: fix
      usage of mempools.") had recently removed.
      
      Remove it again.
      
      Cc: Benjamin Coddington <bcodding@redhat.com>
      Signed-off-by: default avatarNeilBrown <neilb@suse.com>
      Signed-off-by: default avatarTrond Myklebust <trond.myklebust@primarydata.com>
      237f8306
  2. 05 Sep, 2017 2 commits
    • Chuck Lever's avatar
      xprtrdma: Use xprt_pin_rqst in rpcrdma_reply_handler · 9590d083
      Chuck Lever authored
      Adopt the use of xprt_pin_rqst to eliminate contention between
      Call-side users of rb_lock and the use of rb_lock in
      rpcrdma_reply_handler.
      
      This replaces the mechanism introduced in 431af645 ("xprtrdma:
      Fix client lock-up after application signal fires").
      
      Use recv_lock to quickly find the completing rqst, pin it, then
      drop the lock. At that point invalidation and pull-up of the Reply
      XDR can be done. Both are often expensive operations.
      
      Finally, take recv_lock again to signal completion to the RPC
      layer. It also protects adjustment of "cwnd".
      
      This greatly reduces the amount of time a lock is held by the
      reply handler. Comparing lock_stat results shows a marked decrease
      in contention on rb_lock and recv_lock.
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      [trond.myklebust@primarydata.com: Remove call to rpcrdma_buffer_put() from
         the "out_norqst:" path in rpcrdma_reply_handler.]
      Signed-off-by: default avatarTrond Myklebust <trond.myklebust@primarydata.com>
      9590d083
    • Trond Myklebust's avatar
      Merge tag 'nfs-rdma-for-4.14-1' of git://git.linux-nfs.org/projects/anna/linux-nfs into linux-next · f9773b22
      Trond Myklebust authored
      NFS-over-RDMA client updates for Linux 4.14
      
      Bugfixes and cleanups:
      - Constify rpc_xprt_ops
      - Harden RPC call encoding and decoding
      - Clean up rpc call decoding to use xdr_streams
      - Remove unused variables from various structures
      - Refactor code to remove imul instructions
      - Rearrange rx_stats structure for better cacheline sharing
      f9773b22
  3. 22 Aug, 2017 1 commit
  4. 20 Aug, 2017 6 commits
    • Trond Myklebust's avatar
      Merge branch 'bugfixes' · 7af7a596
      Trond Myklebust authored
      7af7a596
    • Chuck Lever's avatar
      NFS: Fix NFSv2 security settings · 53a75f22
      Chuck Lever authored
      For a while now any NFSv2 mount where sec= is specified uses
      AUTH_NULL. If sec= is not specified, the mount uses AUTH_UNIX.
      Commit e68fd7c8 ("mount: use sec= that was specified on the
      command line") attempted to address a very similar problem with
      NFSv3, and should have fixed this too, but it has a bug.
      
      The MNTv1 MNT procedure does not return a list of security flavors,
      so our client makes up a list containing just AUTH_NULL. This should
      enable nfs_verify_authflavors() to assign the sec= specified flavor,
      but instead, it incorrectly sets it to AUTH_NULL.
      
      I expect this would also be a problem for any NFSv3 server whose
      MNTv3 MNT procedure returned a security flavor list containing only
      AUTH_NULL.
      
      Fixes: e68fd7c8 ("mount: use sec= that was specified on ... ")
      BugLink: https://bugzilla.linux-nfs.org/show_bug.cgi?id=310Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      Signed-off-by: default avatarTrond Myklebust <trond.myklebust@primarydata.com>
      53a75f22
    • NeilBrown's avatar
      NFSv4.1: don't use machine credentials for CLOSE when using 'sec=sys' · b79e87e0
      NeilBrown authored
      An NFSv4.1 client might close a file after the user who opened it has
      logged off.  In this case the user's credentials may no longer be
      valid, if they are e.g. kerberos credentials that have expired.
      
      NFSv4.1 has a mechanism to allow the client to use machine credentials
      to close a file.  However due to a short-coming in the RFC, a CLOSE
      with those credentials may not be possible if the file in question
      isn't exported to the same security flavor - the required PUTFH must
      be rejected when this is the case.
      
      Specifically if a server and client support kerberos in general and
      have used it to form a machine credential, but the file is only
      exported to "sec=sys", a PUTFH with the machine credentials will fail,
      so CLOSE is not possible.
      
      As RPC_AUTH_UNIX (used by sec=sys) credentials can never expire, there
      is no value in using the machine credential in place of them.
      So in that case, just use the users credentials for CLOSE etc, as you would
      in NFSv4.0
      Signed-off-by: default avatarNeil Brown <neilb@suse.com>
      Signed-off-by: default avatarNeilBrown <neilb@suse.com>
      Signed-off-by: default avatarTrond Myklebust <trond.myklebust@primarydata.com>
      b79e87e0
    • NeilBrown's avatar
      SUNRPC: ECONNREFUSED should cause a rebind. · fd01b259
      NeilBrown authored
      If you
       - mount and NFSv3 filesystem
       - do some file locking which requires the server
         to make a GRANT call back
       - unmount
       - mount again and do the same locking
      
      then the second attempt at locking suffers a 30 second delay.
      Unmounting and remounting causes lockd to stop and restart,
      which causes it to bind to a new port.
      The server still thinks the old port is valid and gets ECONNREFUSED
      when trying to contact it.
      ECONNREFUSED should be seen as a hard error that is not worth
      retrying.  Rebinding is the only reasonable response.
      
      This patch forces a rebind if that makes sense.
      Signed-off-by: default avatarNeilBrown <neilb@suse.com>
      Signed-off-by: default avatarTrond Myklebust <trond.myklebust@primarydata.com>
      fd01b259
    • Trond Myklebust's avatar
      NFS: Remove unused parameter gfp_flags from nfs_pageio_init() · 3bde7afd
      Trond Myklebust authored
      Now that the mirror allocation has been moved, the parameter can go.
      Also remove the redundant symbol export.
      Signed-off-by: default avatarTrond Myklebust <trond.myklebust@primarydata.com>
      3bde7afd
    • Trond Myklebust's avatar
      NFSv4: Fix up mirror allocation · 14abcb0b
      Trond Myklebust authored
      There are a number of callers of nfs_pageio_complete() that want to
      continue using the nfs_pageio_descriptor without needing to call
      nfs_pageio_init() again. Examples include nfs_pageio_resend() and
      nfs_pageio_cond_complete().
      
      The problem is that nfs_pageio_complete() also calls
      nfs_pageio_cleanup_mirroring(), which frees up the array of mirrors.
      This can lead to writeback errors, in the next call to
      nfs_pageio_setup_mirroring().
      
      Fix by simply moving the allocation of the mirrors to
      nfs_pageio_setup_mirroring().
      
      Link: https://bugzilla.kernel.org/show_bug.cgi?id=196709Reported-by: default avatarJianhongYin <yin-jianhong@163.com>
      Cc: stable@vger.kernel.org # 4.0+
      Signed-off-by: default avatarTrond Myklebust <trond.myklebust@primarydata.com>
      14abcb0b
  5. 18 Aug, 2017 2 commits
  6. 16 Aug, 2017 4 commits
  7. 15 Aug, 2017 22 commits