diff options
author | Josef Bacik <josef@toxicpanda.com> | 2020-02-14 16:11:42 -0500 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2020-03-23 17:01:59 +0100 |
commit | 8c38938c7bb096313ad00c2bafa82af37636b0ec (patch) | |
tree | 6b364d2d7720b841cf368693aa077ecb2dcba386 /fs/btrfs/disk-io.h | |
parent | 0e996e7fcf2e3a7a5d13b0ed5f9cebc551bd94ba (diff) | |
download | linux-8c38938c7bb096313ad00c2bafa82af37636b0ec.tar.bz2 |
btrfs: move the root freeing stuff into btrfs_put_root
There are a few different ways to free roots, either you allocated them
yourself and you just do
free_extent_buffer(root->node);
free_extent_buffer(root->commit_node);
btrfs_put_root(root);
Which is the pattern for log roots. Or for snapshots/subvolumes that
are being dropped you simply call btrfs_free_fs_root() which does all
the cleanup for you.
Unify this all into btrfs_put_root(), so that we don't free up things
associated with the root until the last reference is dropped. This
makes the root freeing code much more significant.
The only caveat is at close_ctree() time we have to free the extent
buffers for all of our main roots (extent_root, chunk_root, etc) because
we have to drop the btree_inode and we'll run into issues if we hold
onto those nodes until ->kill_sb() time. This will be addressed in the
future when we kill the btree_inode.
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/disk-io.h')
-rw-r--r-- | fs/btrfs/disk-io.h | 16 |
1 files changed, 1 insertions, 15 deletions
diff --git a/fs/btrfs/disk-io.h b/fs/btrfs/disk-io.h index 59c885860bf8..cd629113f61c 100644 --- a/fs/btrfs/disk-io.h +++ b/fs/btrfs/disk-io.h @@ -76,7 +76,6 @@ void btrfs_btree_balance_dirty(struct btrfs_fs_info *fs_info); void btrfs_btree_balance_dirty_nodelay(struct btrfs_fs_info *fs_info); void btrfs_drop_and_free_fs_root(struct btrfs_fs_info *fs_info, struct btrfs_root *root); -void btrfs_free_fs_root(struct btrfs_root *root); #ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS struct btrfs_root *btrfs_alloc_dummy_root(struct btrfs_fs_info *fs_info); @@ -98,20 +97,7 @@ static inline struct btrfs_root *btrfs_grab_root(struct btrfs_root *root) return NULL; } -static inline void btrfs_put_root(struct btrfs_root *root) -{ - if (!root) - return; - 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_put_root(struct btrfs_root *root); void btrfs_mark_buffer_dirty(struct extent_buffer *buf); int btrfs_buffer_uptodate(struct extent_buffer *buf, u64 parent_transid, int atomic); |