mirror of
https://github.com/torvalds/linux.git
synced 2024-12-03 17:41:22 +00:00
btrfs: WARN_ON_ONCE() in our leak detection code
fstests looks for WARN_ON's in dmesg. Add WARN_ON_ONCE() to our leak detection code (enabled only in debug builds) so that fstests will fail if these things trip at all. This will allow us to easily catch problems with our reference counting that may otherwise go unnoticed. Reviewed-by: Neal Gompa <neal@gompa.dev> Reviewed-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: Josef Bacik <josef@toxicpanda.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
592a0ce9e2
commit
8fd2b12e6a
@ -1244,6 +1244,7 @@ void btrfs_check_leaked_roots(struct btrfs_fs_info *fs_info)
|
||||
btrfs_err(fs_info, "leaked root %s refcount %d",
|
||||
btrfs_root_name(&root->root_key, buf),
|
||||
refcount_read(&root->refs));
|
||||
WARN_ON_ONCE(1);
|
||||
while (refcount_read(&root->refs) > 1)
|
||||
btrfs_put_root(root);
|
||||
btrfs_put_root(root);
|
||||
|
@ -48,6 +48,7 @@ static inline void btrfs_extent_state_leak_debug_check(void)
|
||||
extent_state_in_tree(state),
|
||||
refcount_read(&state->refs));
|
||||
list_del(&state->leak_list);
|
||||
WARN_ON_ONCE(1);
|
||||
kmem_cache_free(extent_state_cache, state);
|
||||
}
|
||||
}
|
||||
|
@ -82,6 +82,7 @@ void btrfs_extent_buffer_leak_debug_check(struct btrfs_fs_info *fs_info)
|
||||
eb->start, eb->len, atomic_read(&eb->refs), eb->bflags,
|
||||
btrfs_header_owner(eb));
|
||||
list_del(&eb->leak_list);
|
||||
WARN_ON_ONCE(1);
|
||||
kmem_cache_free(extent_buffer_cache, eb);
|
||||
}
|
||||
spin_unlock_irqrestore(&fs_info->eb_leak_lock, flags);
|
||||
|
Loading…
Reference in New Issue
Block a user