1. 16 Jul, 2012 9 commits
    • Chuck Lever's avatar
      NFS: Clean up nfs41_check_expired_stateid() · 3e60ffdd
      Chuck Lever authored
      Clean up: Instead of open-coded flag manipulation, use test_bit() and
      clear_bit() just like all other accessors of the state->flag field.
      This also eliminates several unnecessary implicit integer type
      conversions.
      
      To make it absolutely clear what is going on, a number of comments
      are introduced.
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
      3e60ffdd
    • Chuck Lever's avatar
      NFS: State reclaim clears OPEN and LOCK state · eb64cf96
      Chuck Lever authored
      The "state->flags & flags" test in nfs41_check_expired_stateid()
      allows the state manager to squelch a TEST_STATEID operation when
      it is known for sure that a state ID is no longer valid.  If the
      lease was purged, for example, the client already knows that state
      ID is now defunct.
      
      But open recovery is still needed for that inode.
      
      To force a call to nfs4_open_expired(), change the default return
      value for nfs41_check_expired_stateid() to force open recovery, and
      the default return value for nfs41_check_locks() to force lock
      recovery, if the requested flags are clear.  Fix suggested by Bryan
      Schumaker.
      
      Also, the presence of a delegation state ID must not prevent normal
      open recovery.  The delegation state ID must be cleared if it was
      revoked, but once cleared I don't think it's presence or absence has
      any bearing on whether open recovery is still needed.  So the logic
      is adjusted to ignore the TEST_STATEID result for the delegation
      state ID.
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
      eb64cf96
    • Chuck Lever's avatar
      NFS: Don't free a state ID the server does not recognize · 89af2739
      Chuck Lever authored
      The result of a TEST_STATEID operation can indicate a few different
      things:
      
        o If NFS_OK is returned, then the client can continue using the
          state ID under test, and skip recovery.
      
        o RFC 5661 says that if the state ID was revoked, then the client
          must perform an explicit FREE_STATEID before trying to re-open.
      
        o If the server doesn't recognize the state ID at all, then no
          FREE_STATEID is needed, and the client can immediately continue
          with open recovery.
      
      Let's err on the side of caution: if the server clearly tells us the
      state ID is unknown, we skip the FREE_STATEID.  For any other error,
      we issue a FREE_STATEID.  Sometimes that FREE_STATEID will be
      unnecessary, but leaving unused state IDs on the server needlessly
      ties up resources.
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
      89af2739
    • Chuck Lever's avatar
      NFS: Fix up TEST_STATEID and FREE_STATEID return code handling · 377e507d
      Chuck Lever authored
      The TEST_STATEID and FREE_STATEID operations can return
      -NFS4ERR_BAD_STATEID, -NFS4ERR_OLD_STATEID, or -NFS4ERR_DEADSESSION.
      
      nfs41_{test,free}_stateid() should not pass these errors to
      nfs4_handle_exception() during state recovery, since that will
      recursively kick off state recovery again, resulting in a deadlock.
      
      In particular, when the TEST_STATEID operation returns NFS4_OK,
      res.status can contain one of these errors.  _nfs41_test_stateid()
      replaces NFS4_OK with the value in res.status, which is then returned
      to callers.
      
      But res.status is not passed through nfs4_stat_to_errno(), and thus is
      a positive NFS4ERR value.  Currently callers are only interested in
      !NFS4_OK, and nfs4_handle_exception() ignores positive values.
      
      Thus the res.status values are currently ignored by
      nfs4_handle_exception() and won't cause the deadlock above.  Thanks to
      this missing negative, it is only when these operations fail (which
      is very rare) that a deadlock can occur.
      
      Bryan agrees the original intent was to return res.status as a
      negative NFS4ERR value to callers of nfs41_test_stateid().
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
      377e507d
    • Andy Adamson's avatar
      NFSv4.1 do not send LAYOUTRETURN on emtpy plh_segs list · 293b3b06
      Andy Adamson authored
      mark_matching_lsegs_invalid() resets the mds_threshold counters and can
      dereference the layout hdr on an initial empty plh_segs list. It returns 0 both
      in the case of an initial empty list and in a non-emtpy list that was cleared
      by calls to mark_lseg_invalid.
      
      Don't send a LAYOUTRETURN if the list was initially empty.
      Signed-off-by: default avatarAndy Adamson <andros@netapp.com>
      Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
      293b3b06
    • Andy Adamson's avatar
      NFSv4.1 mark layout when already returned · 366d5052
      Andy Adamson authored
      When the file layout driver is fencing a DS, _pnfs_return_layout can be
      called mulitple times per inode due to in-flight i/o referencing lsegs on it's
      plh_segs list.
      
      Remember that LAYOUTRETURN has been called, and do not call it again.
      Allow LAYOUTRETURNs after a subsequent LAYOUTGET.
      Signed-off-by: default avatarAndy Adamson <andros@netapp.com>
      Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
      366d5052
    • Andy Adamson's avatar
    • Andy Adamson's avatar
      NFSv4.1 return the LAYOUT for each file with failed DS connection I/O · 82c7c7a5
      Andy Adamson authored
      First mark the deviceid invalid to prevent any future use. Then fence all
      files involved in I/O to a DS with a connection error by sending a
      LAYOUTRETURN.
      Signed-off-by: default avatarAndy Adamson <andros@netapp.com>
      Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
      82c7c7a5
    • Trond Myklebust's avatar
      Merge commit '9249e17f' into nfs-for-3.6 · 8626e4a4
      Trond Myklebust authored
      Resolve conflicts with the VFS atomic open and sget changes.
      
      Conflicts:
      	fs/nfs/nfs4proc.c
      8626e4a4
  2. 14 Jul, 2012 31 commits