btrfs: Add WARN_ON() for double lock in btrfs_tree_lock()
authorZhaolei <zhaolei@cn.fujitsu.com>
Thu, 6 Aug 2015 14:39:36 +0000 (22:39 +0800)
committerChris Mason <clm@fb.com>
Sun, 9 Aug 2015 14:07:14 +0000 (07:07 -0700)
When a task trying to double lock a extent buffer, there are no
lockdep warning about it because this lock may be in "blocking_lock"
state, and make us hard to debug.

This patch add a WARN_ON() for above condition, it can not report
all deadlock cases(as lock between tasks), but at least helps us
some.

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: Chris Mason <clm@fb.com>
fs/btrfs/locking.c

index f8229ef1b46df098a3b04260c4f943db3e924d49..d7e6baf1b2054f1998608902385bc5016020c2cf 100644 (file)
@@ -241,6 +241,7 @@ void btrfs_tree_read_unlock_blocking(struct extent_buffer *eb)
  */
 void btrfs_tree_lock(struct extent_buffer *eb)
 {
+       WARN_ON(eb->lock_owner == current->pid);
 again:
        wait_event(eb->read_lock_wq, atomic_read(&eb->blocking_readers) == 0);
        wait_event(eb->write_lock_wq, atomic_read(&eb->blocking_writers) == 0);