1. 05 3月, 2015 1 次提交
    • J
      locks: fix fasync_struct memory leak in lease upgrade/downgrade handling · 0164bf02
      Jeff Layton 提交于
      Commit 8634b51f (locks: convert lease handling to file_lock_context)
      introduced a regression in the handling of lease upgrade/downgrades.
      
      In the event that we already have a lease on a file and are going to
      either upgrade or downgrade it, we skip doing any list insertion or
      deletion and simply re-call lm_setup on the existing lease.
      
      As of commit 8634b51f however, we end up calling lm_setup on the
      lease that was passed in, instead of on the existing lease. This causes
      us to leak the fasync_struct that was allocated in the event that there
      was not already an existing one (as it always appeared that there
      wasn't one).
      
      Fixes: 8634b51f (locks: convert lease handling to file_lock_context)
      Reported-and-Tested-by: NDaniel Wagner <daniel.wagner@bmw-carit.de>
      Signed-off-by: NJeff Layton <jeff.layton@primarydata.com>
      0164bf02
  2. 18 2月, 2015 3 次提交
    • J
      locks: fix list insertion when lock is split in two · 2e2f756f
      Jeff Layton 提交于
      In the case where we're splitting a lock in two, the current code
      the new "left" lock in the incorrect spot. It's inserted just
      before "right" when it should instead be inserted just before the
      new lock.
      
      When we add a new lock, set "fl" to that value so that we can
      add "left" before it.
      Reported-by: NAl Viro <viro@ZenIV.linux.org.uk>
      Signed-off-by: NJeff Layton <jeff.layton@primarydata.com>
      2e2f756f
    • 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
  3. 17 2月, 2015 1 次提交
  4. 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
  5. 22 1月, 2015 1 次提交
  6. 17 1月, 2015 10 次提交
  7. 13 1月, 2015 1 次提交
  8. 08 10月, 2014 12 次提交
  9. 10 9月, 2014 6 次提交
  10. 22 8月, 2014 1 次提交
  11. 14 8月, 2014 2 次提交
    • 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