diff mbox series

[7/9] btrfs: assert tree lock is held when searching for free space entries

Message ID 524c29c4f899918f9597a6ea6af1e86d99117bc7.1683196407.git.fdmanana@suse.com (mailing list archive)
State New, archived
Headers show
Series btrfs: some free space cache fixes and updates | expand

Commit Message

Filipe Manana May 4, 2023, 11:04 a.m. UTC
From: Filipe Manana <fdmanana@suse.com>

When searching for a free space entry by offset, at tree_search_offset(),
we are supposed to have the btrfs_free_space_ctl's 'tree_lock' held, so
assert that. We have multiple callers of tree_search_offset(), and all
currently hold the necessary lock before calling it.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
 fs/btrfs/free-space-cache.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Anand Jain May 5, 2023, 9:44 a.m. UTC | #1
LGTM.

Reviewed-by: Anand Jain <anand.jain@oracle.com>
diff mbox series

Patch

diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index 31d9bb958dc7..84e09ac50103 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -1721,6 +1721,8 @@  tree_search_offset(struct btrfs_free_space_ctl *ctl,
 	struct rb_node *n = ctl->free_space_offset.rb_node;
 	struct btrfs_free_space *entry = NULL, *prev = NULL;
 
+	lockdep_assert_held(&ctl->tree_lock);
+
 	/* find entry that is closest to the 'offset' */
 	while (n) {
 		entry = rb_entry(n, struct btrfs_free_space, offset_index);