Skip to content

Commit abed4aa

Browse files
josefbacikkdave
authored andcommitted
btrfs: track the csum, extent, and free space trees in a rb tree
In the future we are going to have multiple copies of these trees. To facilitate this we need a way to lookup the different roots we are looking for. Handle this by adding a global root rb tree that is indexed on the root->root_key. Then instead of loading the roots at mount time with individually targeted keys, simply search the tree_root for anything with the specific objectid we want. This will make it straightforward to support both old style and new style file systems. Signed-off-by: Josef Bacik <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 7fcf8a0 commit abed4aa

File tree

9 files changed

+263
-80
lines changed

9 files changed

+263
-80
lines changed

fs/btrfs/ctree.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -623,20 +623,21 @@ enum btrfs_exclusive_operation {
623623
struct btrfs_fs_info {
624624
u8 chunk_tree_uuid[BTRFS_UUID_SIZE];
625625
unsigned long flags;
626-
struct btrfs_root *_extent_root;
627626
struct btrfs_root *tree_root;
628627
struct btrfs_root *chunk_root;
629628
struct btrfs_root *dev_root;
630629
struct btrfs_root *fs_root;
631-
struct btrfs_root *_csum_root;
632630
struct btrfs_root *quota_root;
633631
struct btrfs_root *uuid_root;
634-
struct btrfs_root *_free_space_root;
635632
struct btrfs_root *data_reloc_root;
636633

637634
/* the log root tree is a directory of all the other log roots */
638635
struct btrfs_root *log_root_tree;
639636

637+
/* The tree that holds the global roots (csum, extent, etc) */
638+
rwlock_t global_root_lock;
639+
struct rb_root global_root_tree;
640+
640641
spinlock_t fs_roots_radix_lock;
641642
struct radix_tree_root fs_roots_radix;
642643

@@ -1129,6 +1130,8 @@ struct btrfs_qgroup_swapped_blocks {
11291130
* and for the extent tree extent_root root.
11301131
*/
11311132
struct btrfs_root {
1133+
struct rb_node rb_node;
1134+
11321135
struct extent_buffer *node;
11331136

11341137
struct extent_buffer *commit_root;

0 commit comments

Comments
 (0)