btrfs: Add debug warning for new block group reservations
diff mbox

Message ID
State New
Headers show

Commit Message

Qu Wenruo May 26, 2016, 7:01 a.m. UTC
Since the we are using atomic and wait queue for block group
reservations and it's not controlled by lockdep, we need pay much more
attention to any modification to write path.

Or it's very easy to under flow block group reservations and cause lock

Add warning on for dec_block_group_reservations() if the reservations is
already minus.

Although such warning doesn't always catch the directly caller, but should
provides good enough clue for later debug.

Signed-off-by: Qu Wenruo <>
 fs/btrfs/extent-tree.c | 1 +
 1 file changed, 1 insertion(+)

diff mbox

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 9424864..3639b44 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -6243,6 +6243,7 @@  void btrfs_dec_block_group_reservations(struct btrfs_fs_info *fs_info,
 	if (atomic_dec_and_test(&bg->reservations))
+	WARN_ON(atomic_read(&bg->reservations) < 0)