1. 08 10月, 2014 7 次提交
    • J
      locks: give lm_break a return value · 4d01b7f5
      Jeff Layton 提交于
      Christoph suggests:
      
         "Add a return value to lm_break so that the lock manager can tell the
          core code "you can delete this lease right now".  That gets rid of
          the games with the timeout which require all kinds of race avoidance
          code in the users."
      
      Do that here and have the nfsd lease break routine use it when it detects
      that there was a race between setting up the lease and it being broken.
      Signed-off-by: NJeff Layton <jlayton@primarydata.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      4d01b7f5
    • J
      locks: move freeing of leases outside of i_lock · c45198ed
      Jeff Layton 提交于
      There was only one place where we still could free a file_lock while
      holding the i_lock -- lease_modify. Add a new list_head argument to the
      lm_change operation, pass in a private list when calling it, and fix
      those callers to dispose of the list once the lock has been dropped.
      Signed-off-by: NJeff Layton <jlayton@primarydata.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      c45198ed
    • J
      locks: define a lm_setup handler for leases · 1c7dd2ff
      Jeff Layton 提交于
      ...and move the fasync setup into it for fcntl lease calls. At the same
      time, change the semantics of how the file_lock double-pointer is
      handled. Up until now, on a successful lease return you got a pointer to
      the lock on the list. This is bad, since that pointer can no longer be
      relied on as valid once the inode->i_lock has been released.
      
      Change the code to instead just zero out the pointer if the lease we
      passed in ended up being used. Then the callers can just check to see
      if it's NULL after the call and free it if it isn't.
      
      The priv argument has the same semantics. The lm_setup function can
      zero the pointer out to signal to the caller that it should not be
      freed after the function returns.
      Signed-off-by: NJeff Layton <jlayton@primarydata.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      1c7dd2ff
    • J
      locks: plumb a "priv" pointer into the setlease routines · e6f5c789
      Jeff Layton 提交于
      In later patches, we're going to add a new lock_manager_operation to
      finish setting up the lease while still holding the i_lock.  To do
      this, we'll need to pass a little bit of info in the fcntl setlease
      case (primarily an fasync structure). Plumb the extra pointer into
      there in advance of that.
      
      We declare this pointer as a void ** to make it clear that this is
      private info, and that the caller isn't required to set this unless
      the lm_setup specifically requires it.
      Signed-off-by: NJeff Layton <jlayton@primarydata.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      e6f5c789
    • J
      nfsd: don't keep a pointer to the lease in nfs4_file · 0c637be8
      Jeff Layton 提交于
      Now that we don't need to pass in an actual lease pointer to
      vfs_setlease on unlock, we can stop tracking a pointer to the lease in
      the nfs4_file.
      
      Switch all of the places that check the fi_lease to check fi_deleg_file
      instead. We always set that at the same time so it will have the same
      semantics.
      
      Cc: J. Bruce Fields <bfields@fieldses.org>
      Signed-off-by: NJeff Layton <jlayton@primarydata.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      0c637be8
    • J
      locks: generic_delete_lease doesn't need a file_lock at all · 0efaa7e8
      Jeff Layton 提交于
      Ensure that it's OK to pass in a NULL file_lock double pointer on
      a F_UNLCK request and convert the vfs_setlease F_UNLCK callers to
      do just that.
      
      Finally, turn the BUG_ON in generic_setlease into a WARN_ON_ONCE
      with an error return. That's a problem we can handle without
      crashing the box if it occurs.
      Signed-off-by: NJeff Layton <jlayton@primarydata.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      0efaa7e8
    • J
      nfsd: fix potential lease memory leak in nfs4_setlease · 415b96c5
      Jeff Layton 提交于
      It's unlikely to ever occur, but if there were already a lease set on
      the file then we could end up getting back a different pointer on a
      successful setlease attempt than the one we allocated. If that happens,
      the one we allocated could leak.
      
      In practice, I don't think this will happen due to the fact that we only
      try to set up the lease once per nfs4_file, but this error handling is a
      bit more correct given the current lease API.
      
      Cc: J. Bruce Fields <bfields@fieldses.org>
      Signed-off-by: NJeff Layton <jlayton@primarydata.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      415b96c5
  2. 10 9月, 2014 2 次提交
  3. 29 8月, 2014 1 次提交
  4. 18 8月, 2014 2 次提交
    • J
      nfsd: call nfs4_put_deleg_lease outside of state_lock · afbda402
      Jeff Layton 提交于
      Currently, we hold the state_lock when releasing the lease. That's
      potentially problematic in the future if we allow for setlease methods
      that can sleep. Move the nfs4_put_deleg_lease call out of the delegation
      unhashing routine (which was always a bit goofy anyway), and into the
      unlocked sections of the callers of unhash_delegation_locked.
      Signed-off-by: NJeff Layton <jlayton@primarydata.com>
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      afbda402
    • J
      nfsd: protect lease-related nfs4_file fields with fi_lock · 6bcc034e
      Jeff Layton 提交于
      Currently these fields are protected with the state_lock, but that
      doesn't really make a lot of sense. These fields are "private" to the
      nfs4_file, and can be protected with the more granular fi_lock.
      
      The fi_lock is already held when setting these fields. Make the code
      hold the fp->fi_lock when clearing the lease-related fields in the
      nfs4_file, and no longer require that the state_lock be held when
      calling into this function.
      
      To prevent lock inversion with the i_lock, we also move the vfs_setlease
      and fput calls outside of the fi_lock. This also sets us up for allowing
      vfs_setlease calls to block in the future.
      
      Finally, remove a redundant NULL pointer check. unhash_delegation_locked
      locks the fp->fi_lock prior to that check, so fp in that function must
      never be NULL.
      Signed-off-by: NJeff Layton <jlayton@primarydata.com>
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      6bcc034e
  5. 06 8月, 2014 1 次提交
  6. 05 8月, 2014 23 次提交
  7. 02 8月, 2014 4 次提交