Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

btrfs: Add WARN_ON() for double lock in btrfs_tree_lock()

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>

authored by

Zhaolei and committed by
Chris Mason
166f66d0 9ed0dea0

+1
+1
fs/btrfs/locking.c
··· 241 241 */ 242 242 void btrfs_tree_lock(struct extent_buffer *eb) 243 243 { 244 + WARN_ON(eb->lock_owner == current->pid); 244 245 again: 245 246 wait_event(eb->read_lock_wq, atomic_read(&eb->blocking_readers) == 0); 246 247 wait_event(eb->write_lock_wq, atomic_read(&eb->blocking_writers) == 0);