btrfs: make buffer_radix take sector size units
authorQu Wenruo <wqu@suse.com>
Wed, 21 Oct 2020 06:25:05 +0000 (14:25 +0800)
committerDavid Sterba <dsterba@suse.com>
Tue, 8 Dec 2020 14:54:03 +0000 (15:54 +0100)
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: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/ctree.h
fs/btrfs/extent_io.c

index 2aa3d88..5911512 100644 (file)
@@ -912,6 +912,7 @@ struct btrfs_fs_info {
 
        /* Extent buffer radix tree */
        spinlock_t buffer_lock;
+       /* Entries are eb->start / sectorsize */
        struct radix_tree_root buffer_radix;
 
        /* next backup root to be overwritten */
index 092ccb8..1dfbe85 100644 (file)
@@ -5107,7 +5107,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_bits);
        if (eb && atomic_inc_not_zero(&eb->refs)) {
                rcu_read_unlock();
                /*
@@ -5159,7 +5159,7 @@ again:
        }
        spin_lock(&fs_info->buffer_lock);
        ret = radix_tree_insert(&fs_info->buffer_radix,
-                               start >> PAGE_SHIFT, eb);
+                               start >> fs_info->sectorsize_bits, eb);
        spin_unlock(&fs_info->buffer_lock);
        radix_tree_preload_end();
        if (ret == -EEXIST) {
@@ -5267,7 +5267,7 @@ again:
 
        spin_lock(&fs_info->buffer_lock);
        ret = radix_tree_insert(&fs_info->buffer_radix,
-                               start >> PAGE_SHIFT, eb);
+                               start >> fs_info->sectorsize_bits, eb);
        spin_unlock(&fs_info->buffer_lock);
        radix_tree_preload_end();
        if (ret == -EEXIST) {
@@ -5323,7 +5323,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_bits);
                        spin_unlock(&fs_info->buffer_lock);
                } else {
                        spin_unlock(&eb->refs_lock);