Commit 478ef886 authored by Qu Wenruo's avatar Qu Wenruo Committed by David Sterba

btrfs: make buffer_radix take sector size units

For subpage sector size support, one page can contain multiple tree
blocks. The entries cannot be based on page size and index must be
derived from the sectorsize. No change for page size == sector size.
Reviewed-by: default avatarNikolay Borisov <nborisov@suse.com>
Signed-off-by: default avatarQu Wenruo <wqu@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 0d01e247
...@@ -912,6 +912,7 @@ struct btrfs_fs_info { ...@@ -912,6 +912,7 @@ struct btrfs_fs_info {
/* Extent buffer radix tree */ /* Extent buffer radix tree */
spinlock_t buffer_lock; spinlock_t buffer_lock;
/* Entries are eb->start / sectorsize */
struct radix_tree_root buffer_radix; struct radix_tree_root buffer_radix;
/* next backup root to be overwritten */ /* next backup root to be overwritten */
......
...@@ -5107,7 +5107,7 @@ struct extent_buffer *find_extent_buffer(struct btrfs_fs_info *fs_info, ...@@ -5107,7 +5107,7 @@ struct extent_buffer *find_extent_buffer(struct btrfs_fs_info *fs_info,
rcu_read_lock(); rcu_read_lock();
eb = radix_tree_lookup(&fs_info->buffer_radix, eb = radix_tree_lookup(&fs_info->buffer_radix,
start >> PAGE_SHIFT); start >> fs_info->sectorsize_bits);
if (eb && atomic_inc_not_zero(&eb->refs)) { if (eb && atomic_inc_not_zero(&eb->refs)) {
rcu_read_unlock(); rcu_read_unlock();
/* /*
...@@ -5159,7 +5159,7 @@ struct extent_buffer *alloc_test_extent_buffer(struct btrfs_fs_info *fs_info, ...@@ -5159,7 +5159,7 @@ struct extent_buffer *alloc_test_extent_buffer(struct btrfs_fs_info *fs_info,
} }
spin_lock(&fs_info->buffer_lock); spin_lock(&fs_info->buffer_lock);
ret = radix_tree_insert(&fs_info->buffer_radix, ret = radix_tree_insert(&fs_info->buffer_radix,
start >> PAGE_SHIFT, eb); start >> fs_info->sectorsize_bits, eb);
spin_unlock(&fs_info->buffer_lock); spin_unlock(&fs_info->buffer_lock);
radix_tree_preload_end(); radix_tree_preload_end();
if (ret == -EEXIST) { if (ret == -EEXIST) {
...@@ -5267,7 +5267,7 @@ struct extent_buffer *alloc_extent_buffer(struct btrfs_fs_info *fs_info, ...@@ -5267,7 +5267,7 @@ struct extent_buffer *alloc_extent_buffer(struct btrfs_fs_info *fs_info,
spin_lock(&fs_info->buffer_lock); spin_lock(&fs_info->buffer_lock);
ret = radix_tree_insert(&fs_info->buffer_radix, ret = radix_tree_insert(&fs_info->buffer_radix,
start >> PAGE_SHIFT, eb); start >> fs_info->sectorsize_bits, eb);
spin_unlock(&fs_info->buffer_lock); spin_unlock(&fs_info->buffer_lock);
radix_tree_preload_end(); radix_tree_preload_end();
if (ret == -EEXIST) { if (ret == -EEXIST) {
...@@ -5323,7 +5323,7 @@ static int release_extent_buffer(struct extent_buffer *eb) ...@@ -5323,7 +5323,7 @@ static int release_extent_buffer(struct extent_buffer *eb)
spin_lock(&fs_info->buffer_lock); spin_lock(&fs_info->buffer_lock);
radix_tree_delete(&fs_info->buffer_radix, radix_tree_delete(&fs_info->buffer_radix,
eb->start >> PAGE_SHIFT); eb->start >> fs_info->sectorsize_bits);
spin_unlock(&fs_info->buffer_lock); spin_unlock(&fs_info->buffer_lock);
} else { } else {
spin_unlock(&eb->refs_lock); spin_unlock(&eb->refs_lock);
......
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