Skip to content
Permalink
Browse files
btrfs: make btrfs_fs_info::buffer_radix to take sector size devided v…
…alues

For subpage size sector size support, one page can contain mutliple tree
blocks, thus we can no longer use (eb->start >> PAGE_SHIFT) any more, or
we can easily get extent buffer doesn't belongs to us.

This patch will use (extent_buffer::start / sectorsize) as index for radix
tree so that we can get correct extent buffer for subpage size support.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
  • Loading branch information
adam900710 authored and intel-lab-lkp committed Sep 15, 2020
1 parent 8070c4b commit d68d61d0719a047c653dcee58952ec46f5db5d00
Showing 1 changed file with 4 additions and 4 deletions.
@@ -5142,7 +5142,7 @@ struct extent_buffer *find_extent_buffer(struct btrfs_fs_info *fs_info,

rcu_read_lock();
eb = radix_tree_lookup(&fs_info->buffer_radix,
start >> PAGE_SHIFT);
start / fs_info->sectorsize);
if (eb && atomic_inc_not_zero(&eb->refs)) {
rcu_read_unlock();
/*
@@ -5194,7 +5194,7 @@ struct extent_buffer *alloc_test_extent_buffer(struct btrfs_fs_info *fs_info,
}
spin_lock(&fs_info->buffer_lock);
ret = radix_tree_insert(&fs_info->buffer_radix,
start >> PAGE_SHIFT, eb);
start / fs_info->sectorsize, eb);
spin_unlock(&fs_info->buffer_lock);
radix_tree_preload_end();
if (ret == -EEXIST) {
@@ -5302,7 +5302,7 @@ struct extent_buffer *alloc_extent_buffer(struct btrfs_fs_info *fs_info,

spin_lock(&fs_info->buffer_lock);
ret = radix_tree_insert(&fs_info->buffer_radix,
start >> PAGE_SHIFT, eb);
start / fs_info->sectorsize, eb);
spin_unlock(&fs_info->buffer_lock);
radix_tree_preload_end();
if (ret == -EEXIST) {
@@ -5358,7 +5358,7 @@ static int release_extent_buffer(struct extent_buffer *eb)

spin_lock(&fs_info->buffer_lock);
radix_tree_delete(&fs_info->buffer_radix,
eb->start >> PAGE_SHIFT);
eb->start / fs_info->sectorsize);
spin_unlock(&fs_info->buffer_lock);
} else {
spin_unlock(&eb->refs_lock);

0 comments on commit d68d61d

Please sign in to comment.