Skip to content

Commit

Permalink
btrfs: track the csum, extent, and free space trees in a rb tree
Browse files Browse the repository at this point in the history
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 <josef@toxicpanda.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
  • Loading branch information
Josef Bacik authored and David Sterba committed Jan 3, 2022
1 parent 7fcf8a0 commit abed4aa
Show file tree
Hide file tree
Showing 9 changed files with 263 additions and 80 deletions.
9 changes: 6 additions & 3 deletions fs/btrfs/ctree.h
Original file line number Diff line number Diff line change
Expand Up @@ -623,20 +623,21 @@ enum btrfs_exclusive_operation {
struct btrfs_fs_info {
u8 chunk_tree_uuid[BTRFS_UUID_SIZE];
unsigned long flags;
struct btrfs_root *_extent_root;
struct btrfs_root *tree_root;
struct btrfs_root *chunk_root;
struct btrfs_root *dev_root;
struct btrfs_root *fs_root;
struct btrfs_root *_csum_root;
struct btrfs_root *quota_root;
struct btrfs_root *uuid_root;
struct btrfs_root *_free_space_root;
struct btrfs_root *data_reloc_root;

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

/* The tree that holds the global roots (csum, extent, etc) */
rwlock_t global_root_lock;
struct rb_root global_root_tree;

spinlock_t fs_roots_radix_lock;
struct radix_tree_root fs_roots_radix;

Expand Down Expand Up @@ -1129,6 +1130,8 @@ struct btrfs_qgroup_swapped_blocks {
* and for the extent tree extent_root root.
*/
struct btrfs_root {
struct rb_node rb_node;

struct extent_buffer *node;

struct extent_buffer *commit_root;
Expand Down
Loading

0 comments on commit abed4aa

Please sign in to comment.