1. 18 2月, 2015 2 次提交
    • J
      locks: remove conditional lock release in middle of flock_lock_file · 267f1128
      Jeff Layton 提交于
      As Linus pointed out:
      
          Say we have an existing flock, and now do a new one that conflicts. I
          see what looks like three separate bugs.
      
           - We go through the first loop, find a lock of another type, and
          delete it in preparation for replacing it
      
           - we *drop* the lock context spinlock.
      
           - BUG #1? So now there is no lock at all, and somebody can come in
          and see that unlocked state. Is that really valid?
      
           - another thread comes in while the first thread dropped the lock
          context lock, and wants to add its own lock. It doesn't see the
          deleted or pending locks, so it just adds it
      
           - the first thread gets the context spinlock again, and adds the lock
          that replaced the original
      
           - BUG #2? So now there are *two* locks on the thing, and the next
          time you do an unlock (or when you close the file), it will only
          remove/replace the first one.
      
      ...remove the "drop the spinlock" code in the middle of this function as
      it has always been suspicious. This should eliminate the potential race
      that can leave two locks for the same struct file on the list.
      
      He also pointed out another thing as a bug -- namely that you
      flock_lock_file removes the lock from the list unconditionally when
      doing a lock upgrade, without knowing whether it'll be able to set the
      new lock. Bruce pointed out that this is expected behavior and may help
      prevent certain deadlock situations.
      
      We may want to revisit that at some point, but it's probably best that
      we do so in the context of a different patchset.
      Reported-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NJeff Layton <jeff.layton@primarydata.com>
      267f1128
    • J
      locks: only remove leases associated with the file being closed · c4e136cd
      Jeff Layton 提交于
      We don't want to remove all leases just because one filp was closed.
      Signed-off-by: NJeff Layton <jeff.layton@primarydata.com>
      c4e136cd
  2. 17 2月, 2015 1 次提交
  3. 03 2月, 2015 2 次提交
    • C
      fs: add FL_LAYOUT lease type · 11afe9f7
      Christoph Hellwig 提交于
      This (ab-)uses the file locking code to allow filesystems to recall
      outstanding pNFS layouts on a file.  This new lease type is similar but
      not quite the same as FL_DELEG.  A FL_LAYOUT lease can always be granted,
      an a per-filesystem lock (XFS iolock for the initial implementation)
      ensures not FL_LAYOUT leases granted when we would need to recall them.
      
      Also included are changes that allow multiple outstanding read
      leases of different types on the same file as long as they have a
      differnt owner.  This wasn't a problem until now as nfsd never set
      FL_LEASE leases, and no one else used FL_DELEG leases, but given that
      nfsd will also issues FL_LAYOUT leases we will have to handle it now.
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      11afe9f7
    • C
      fs: track fl_owner for leases · 2ab99ee1
      Christoph Hellwig 提交于
      Just like for other lock types we should allow different owners to have
      a read lease on a file.  Currently this can't happen, but with the addition
      of pNFS layout leases we'll need this feature.
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      2ab99ee1
  4. 22 1月, 2015 1 次提交
  5. 17 1月, 2015 10 次提交
  6. 13 1月, 2015 1 次提交
  7. 08 10月, 2014 12 次提交
  8. 10 9月, 2014 6 次提交
  9. 22 8月, 2014 1 次提交
  10. 14 8月, 2014 3 次提交
    • J
      locks: move locks_free_lock calls in do_fcntl_add_lease outside spinlock · 2dfb928f
      Jeff Layton 提交于
      There's no need to call locks_free_lock here while still holding the
      i_lock. Defer that until the lock has been dropped.
      Acked-by: NJ. Bruce Fields <bfields@fieldses.org>
      Signed-off-by: NJeff Layton <jlayton@primarydata.com>
      2dfb928f
    • J
      locks: defer freeing locks in locks_delete_lock until after i_lock has been dropped · ed9814d8
      Jeff Layton 提交于
      In commit 72f98e72 (locks: turn lock_flocks into a spinlock), we
      moved from using the BKL to a global spinlock. With this change, we lost
      the ability to block in the fl_release_private operation.
      
      This is problematic for NFS (and probably some other filesystems as
      well). Add a new list_head argument to locks_delete_lock. If that
      argument is non-NULL, then queue any locks that we want to free to the
      list instead of freeing them.
      
      Then, add a new locks_dispose_list function that will walk such a list
      and call locks_free_lock on them after the i_lock has been dropped.
      
      Finally, change all of the callers of locks_delete_lock to pass in a
      list_head, except for lease_modify. That function can be called long
      after the i_lock has been acquired. Deferring the freeing of a lease
      after unlocking it in that function is non-trivial until we overhaul
      some of the spinlocking in the lease code.
      
      Currently though, no filesystem that sets fl_release_private supports
      leases, so this is not currently a problem. We'll eventually want to
      make the same change in the lease code, but it needs a lot more work
      before we can reasonably do so.
      Acked-by: NJ. Bruce Fields <bfields@fieldses.org>
      Signed-off-by: NJeff Layton <jlayton@primarydata.com>
      ed9814d8
    • J
      locks: don't reuse file_lock in __posix_lock_file · b84d49f9
      Jeff Layton 提交于
      Currently in the case where a new file lock completely replaces the old
      one, we end up overwriting the existing lock with the new info. This
      means that we have to call fl_release_private inside i_lock. Change the
      code to instead copy the info to new_fl, insert that lock into the
      correct spot and then delete the old lock. In a later patch, we'll defer
      the freeing of the old lock until after the i_lock has been dropped.
      Acked-by: NJ. Bruce Fields <bfields@fieldses.org>
      Signed-off-by: NJeff Layton <jlayton@primarydata.com>
      b84d49f9
  11. 12 8月, 2014 1 次提交