btrfs: add a leak check for roots
Now that we're going to start relying on getting ref counting right for roots, add a list to track allocated roots and print out any roots that aren't freed up at free_fs_info time. Hide this behind CONFIG_BTRFS_DEBUG because this will just be used for developers to verify they aren't breaking things. Reviewed-by: Nikolay Borisov <nborisov@suse.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:
committed by
David Sterba
parent
8260edba67
commit
bd647ce385
@@ -39,6 +39,7 @@ static inline u64 btrfs_sb_offset(int mirror)
|
||||
struct btrfs_device;
|
||||
struct btrfs_fs_devices;
|
||||
|
||||
void btrfs_check_leaked_roots(struct btrfs_fs_info *fs_info);
|
||||
void btrfs_init_fs_info(struct btrfs_fs_info *fs_info);
|
||||
int btrfs_verify_level_key(struct extent_buffer *eb, int level,
|
||||
struct btrfs_key *first_key, u64 parent_transid);
|
||||
@@ -101,8 +102,14 @@ static inline void btrfs_put_fs_root(struct btrfs_root *root)
|
||||
{
|
||||
if (!root)
|
||||
return;
|
||||
if (refcount_dec_and_test(&root->refs))
|
||||
if (refcount_dec_and_test(&root->refs)) {
|
||||
#ifdef CONFIG_BTRFS_DEBUG
|
||||
spin_lock(&root->fs_info->fs_roots_radix_lock);
|
||||
list_del_init(&root->leak_list);
|
||||
spin_unlock(&root->fs_info->fs_roots_radix_lock);
|
||||
#endif
|
||||
kfree(root);
|
||||
}
|
||||
}
|
||||
|
||||
void btrfs_mark_buffer_dirty(struct extent_buffer *buf);
|
||||
|
||||
Reference in New Issue
Block a user