Commit 78418b86733462c913aea82e081594b1005751ba

Authored by Liu Bo
Committed by Greg Kroah-Hartman
1 parent 92d6a813b0

Btrfs: use down_read_nested to make lockdep silent

[ Upstream commit e321f8a801d7b4c40da8005257b05b9c2b51b072 ]

If @block_group is not @used_bg, it'll try to get @used_bg's lock without
droping @block_group 's lock and lockdep has throwed a scary deadlock warning
about it.
Fix it by using down_read_nested.

Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Showing 1 changed file with 2 additions and 1 deletions Side-by-side Diff

fs/btrfs/extent-tree.c
... ... @@ -7401,7 +7401,8 @@
7401 7401  
7402 7402 spin_unlock(&cluster->refill_lock);
7403 7403  
7404   - down_read(&used_bg->data_rwsem);
  7404 + /* We should only have one-level nested. */
  7405 + down_read_nested(&used_bg->data_rwsem, SINGLE_DEPTH_NESTING);
7405 7406  
7406 7407 spin_lock(&cluster->refill_lock);
7407 7408 if (used_bg == cluster->block_group)