btrfs: move fs root init stuff into btrfs_init_fs_root
authorJosef Bacik <josef@toxicpanda.com>
Fri, 24 Jan 2020 14:32:19 +0000 (09:32 -0500)
committerDavid Sterba <dsterba@suse.com>
Mon, 23 Mar 2020 16:01:25 +0000 (17:01 +0100)
We have a helper for reading fs roots that just reads the fs root off
the disk and then sets REF_COWS and init's the inheritable flags.  Move
this into btrfs_init_fs_root so we can later get rid of this helper and
consolidate all of the fs root reading into one helper.

Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/disk-io.c

index f1121d814e8700dbd5472d3338d1aa4556408436..eff6f0e45c3ed542b7743c7836166356fb35bc21 100644 (file)
@@ -1445,12 +1445,6 @@ struct btrfs_root *btrfs_read_fs_root(struct btrfs_root *tree_root,
        root = btrfs_read_tree_root(tree_root, location);
        if (IS_ERR(root))
                return root;
-
-       if (root->root_key.objectid != BTRFS_TREE_LOG_OBJECTID) {
-               set_bit(BTRFS_ROOT_REF_COWS, &root->state);
-               btrfs_check_and_init_root_item(&root->root_item);
-       }
-
        return root;
 }
 
@@ -1474,6 +1468,11 @@ int btrfs_init_fs_root(struct btrfs_root *root)
        }
        root->subv_writers = writers;
 
+       if (root->root_key.objectid != BTRFS_TREE_LOG_OBJECTID) {
+               set_bit(BTRFS_ROOT_REF_COWS, &root->state);
+               btrfs_check_and_init_root_item(&root->root_item);
+       }
+
        btrfs_init_free_ino_ctl(root);
        spin_lock_init(&root->ino_cache_lock);
        init_waitqueue_head(&root->ino_cache_wait);