Messages in this thread Patch in this message | | | From | Mark Harmstone <> | Subject | [RFC PATCH 03/19] btrfs: load key tree | Date | Wed, 9 Jan 2019 01:26:45 +0000 |
| |
Signed-off-by: Mark Harmstone <mark@harmstone.com> --- fs/btrfs/ctree.h | 2 ++ fs/btrfs/disk-io.c | 11 +++++++++++ 2 files changed, 13 insertions(+)
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 68f322f600a0..bd2e59dd0eba 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -758,6 +758,7 @@ struct btrfs_fs_info { struct btrfs_root *quota_root; struct btrfs_root *uuid_root; struct btrfs_root *free_space_root; + struct btrfs_root *key_root; /* the log root tree is a directory of all the other log roots */ struct btrfs_root *log_root_tree; @@ -2957,6 +2958,7 @@ static inline void free_fs_info(struct btrfs_fs_info *fs_info) kfree(fs_info->quota_root); kfree(fs_info->uuid_root); kfree(fs_info->free_space_root); + kfree(fs_info->key_root); kfree(fs_info->super_copy); kfree(fs_info->super_for_commit); security_free_mnt_opts(&fs_info->security_opts); diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 6d776717d8b3..a533c00855be 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -1559,6 +1559,9 @@ struct btrfs_root *btrfs_get_fs_root(struct btrfs_fs_info *fs_info, if (location->objectid == BTRFS_FREE_SPACE_TREE_OBJECTID) return fs_info->free_space_root ? fs_info->free_space_root : ERR_PTR(-ENOENT); + if (location->objectid == BTRFS_KEY_TREE_OBJECTID) + return fs_info->key_root ? fs_info->key_root : + ERR_PTR(-ENOENT); again: root = btrfs_lookup_fs_root(fs_info, location->objectid); if (root) { @@ -2029,6 +2032,7 @@ static void free_root_pointers(struct btrfs_fs_info *info, int chunk_root) if (chunk_root) free_root_extent_buffers(info->chunk_root); free_root_extent_buffers(info->free_space_root); + free_root_extent_buffers(info->key_root); } void btrfs_free_fs_roots(struct btrfs_fs_info *fs_info) @@ -2349,6 +2353,13 @@ static int btrfs_read_roots(struct btrfs_fs_info *fs_info) fs_info->free_space_root = root; } + location.objectid = BTRFS_KEY_TREE_OBJECTID; + root = btrfs_read_tree_root(tree_root, &location); + if (!IS_ERR(root)) { + set_bit(BTRFS_ROOT_TRACK_DIRTY, &root->state); + fs_info->key_root = root; + } + return 0; out: btrfs_warn(fs_info, "failed to read root (objectid=%llu): %d", -- 2.19.2
| |