diff mbox series

[07/11] btrfs: assert correct lock is held at btrfs_select_ref_head()

Message ID 83affb7dc94093940cba2485afedb9d661191335.1685363099.git.fdmanana@suse.com (mailing list archive)
State New, archived
Headers show
Series btrfs: some delayed refs optimizations and cleanups | expand

Commit Message

Filipe Manana May 29, 2023, 3:17 p.m. UTC
From: Filipe Manana <fdmanana@suse.com>

The function btrfs_select_ref_head() iterates over the red black tree of
delayed reference heads, which is protected by the spinlock in the delayed
refs root. The function doesn't take the lock, it's taken by its single
caller, btrfs_obtain_ref_head(), because it needs to call that function
and btrfs_delayed_ref_lock() in the same critical section (delimited by
that spinlock). So assert at btrfs_select_ref_head() that we are holding
the expected lock.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
 fs/btrfs/delayed-ref.c | 1 +
 1 file changed, 1 insertion(+)
diff mbox series

Patch

diff --git a/fs/btrfs/delayed-ref.c b/fs/btrfs/delayed-ref.c
index e4579e66a57a..c61af9012a82 100644
--- a/fs/btrfs/delayed-ref.c
+++ b/fs/btrfs/delayed-ref.c
@@ -506,6 +506,7 @@  struct btrfs_delayed_ref_head *btrfs_select_ref_head(
 {
 	struct btrfs_delayed_ref_head *head;
 
+	lockdep_assert_held(&delayed_refs->lock);
 again:
 	head = find_ref_head(delayed_refs, delayed_refs->run_delayed_start,
 			     true);