Commit 9cfc8ba7 authored by Nikolay Borisov's avatar Nikolay Borisov Committed by David Sterba

btrfs: Remove special handling of EXTENT_BUFFER_UNMAPPED while freeing

Now that the whole of btrfs code has been audited for eb reference count
management it's time to remove the hunk in free_extent_buffer that
essentially considered the condition

  "eb->ref == 2 && EXTENT_BUFFER_DUMMY"

to equal "eb->ref = 1". Also remove the last location
which takes an extra reference count in alloc_test_extent_buffer.
Signed-off-by: default avatarNikolay Borisov <nborisov@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent df449714
...@@ -4893,13 +4893,6 @@ struct extent_buffer *alloc_test_extent_buffer(struct btrfs_fs_info *fs_info, ...@@ -4893,13 +4893,6 @@ struct extent_buffer *alloc_test_extent_buffer(struct btrfs_fs_info *fs_info,
check_buffer_tree_ref(eb); check_buffer_tree_ref(eb);
set_bit(EXTENT_BUFFER_IN_TREE, &eb->bflags); set_bit(EXTENT_BUFFER_IN_TREE, &eb->bflags);
/*
* We will free dummy extent buffer's if they come into
* free_extent_buffer with a ref count of 2, but if we are using this we
* want the buffers to stay in memory until we're done with them, so
* bump the ref count again.
*/
atomic_inc(&eb->refs);
return eb; return eb;
free_eb: free_eb:
btrfs_release_extent_buffer(eb); btrfs_release_extent_buffer(eb);
...@@ -5089,10 +5082,6 @@ void free_extent_buffer(struct extent_buffer *eb) ...@@ -5089,10 +5082,6 @@ void free_extent_buffer(struct extent_buffer *eb)
} }
spin_lock(&eb->refs_lock); spin_lock(&eb->refs_lock);
if (atomic_read(&eb->refs) == 2 &&
test_bit(EXTENT_BUFFER_UNMAPPED, &eb->bflags))
atomic_dec(&eb->refs);
if (atomic_read(&eb->refs) == 2 && if (atomic_read(&eb->refs) == 2 &&
test_bit(EXTENT_BUFFER_STALE, &eb->bflags) && test_bit(EXTENT_BUFFER_STALE, &eb->bflags) &&
!extent_buffer_under_io(eb) && !extent_buffer_under_io(eb) &&
......
...@@ -174,8 +174,12 @@ void btrfs_free_dummy_root(struct btrfs_root *root) ...@@ -174,8 +174,12 @@ void btrfs_free_dummy_root(struct btrfs_root *root)
/* Will be freed by btrfs_free_fs_roots */ /* Will be freed by btrfs_free_fs_roots */
if (WARN_ON(test_bit(BTRFS_ROOT_IN_RADIX, &root->state))) if (WARN_ON(test_bit(BTRFS_ROOT_IN_RADIX, &root->state)))
return; return;
if (root->node) if (root->node) {
/* One for allocate_extent_buffer */
free_extent_buffer(root->node); free_extent_buffer(root->node);
/* One for get_exent_buffer */
free_extent_buffer(root->node);
}
kfree(root); kfree(root);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment