Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>

authored by

Nikolay Borisov and committed by
David Sterba
9cfc8ba7 df449714

+5 -12
-11
fs/btrfs/extent_io.c
··· 4893 4893 check_buffer_tree_ref(eb); 4894 4894 set_bit(EXTENT_BUFFER_IN_TREE, &eb->bflags); 4895 4895 4896 - /* 4897 - * We will free dummy extent buffer's if they come into 4898 - * free_extent_buffer with a ref count of 2, but if we are using this we 4899 - * want the buffers to stay in memory until we're done with them, so 4900 - * bump the ref count again. 4901 - */ 4902 - atomic_inc(&eb->refs); 4903 4896 return eb; 4904 4897 free_eb: 4905 4898 btrfs_release_extent_buffer(eb); ··· 5082 5089 } 5083 5090 5084 5091 spin_lock(&eb->refs_lock); 5085 - if (atomic_read(&eb->refs) == 2 && 5086 - test_bit(EXTENT_BUFFER_UNMAPPED, &eb->bflags)) 5087 - atomic_dec(&eb->refs); 5088 - 5089 5092 if (atomic_read(&eb->refs) == 2 && 5090 5093 test_bit(EXTENT_BUFFER_STALE, &eb->bflags) && 5091 5094 !extent_buffer_under_io(eb) &&
+5 -1
fs/btrfs/tests/btrfs-tests.c
··· 174 174 /* Will be freed by btrfs_free_fs_roots */ 175 175 if (WARN_ON(test_bit(BTRFS_ROOT_IN_RADIX, &root->state))) 176 176 return; 177 - if (root->node) 177 + if (root->node) { 178 + /* One for allocate_extent_buffer */ 178 179 free_extent_buffer(root->node); 180 + /* One for get_exent_buffer */ 181 + free_extent_buffer(root->node); 182 + } 179 183 kfree(root); 180 184 } 181 185