u64 root_objectid)
{
struct btrfs_key key;
+ struct btrfs_root *root;
key.objectid = root_objectid;
key.type = BTRFS_ROOT_ITEM_KEY;
else
key.offset = (u64)-1;
- return btrfs_get_fs_root(fs_info, &key, false);
+ root = btrfs_get_fs_root(fs_info, &key, false);
+ if (IS_ERR(root))
+ return root;
+ if (!btrfs_grab_fs_root(root))
+ return ERR_PTR(-ENOENT);
+ return root;
}
static noinline_for_stack
err = PTR_ERR(root);
goto out;
}
- if (!btrfs_grab_fs_root(root)) {
- err = -ENOENT;
- goto out;
- }
if (!test_bit(BTRFS_ROOT_REF_COWS, &root->state))
cur->cowonly = 1;
root = read_fs_root(fs_info, reloc_root->root_key.offset);
BUG_ON(IS_ERR(root));
- BUG_ON(!btrfs_grab_fs_root(root));
BUG_ON(root->reloc_root != reloc_root);
/*
root = read_fs_root(fs_info,
reloc_root->root_key.offset);
BUG_ON(IS_ERR(root));
- BUG_ON(!btrfs_grab_fs_root(root));
BUG_ON(root->reloc_root != reloc_root);
ret = merge_reloc_root(rc, root);
root = read_fs_root(fs_info, reloc_root->root_key.offset);
BUG_ON(IS_ERR(root));
- BUG_ON(!btrfs_grab_fs_root(root));
BUG_ON(root->reloc_root != reloc_root);
ret = btrfs_record_root_in_trans(trans, root);
btrfs_put_fs_root(root);
err = PTR_ERR(root);
goto out_free;
}
- if (!btrfs_grab_fs_root(root)) {
- err = -ENOENT;
- goto out_free;
- }
key.objectid = ref_objectid;
key.type = BTRFS_EXTENT_DATA_KEY;
root = read_fs_root(fs_info, BTRFS_DATA_RELOC_TREE_OBJECTID);
if (IS_ERR(root))
return ERR_CAST(root);
- if (!btrfs_grab_fs_root(root))
- return ERR_PTR(-ENOENT);
trans = btrfs_start_transaction(root, 6);
if (IS_ERR(trans)) {
goto out;
}
} else {
- if (!btrfs_grab_fs_root(fs_root)) {
- err = -ENOENT;
- goto out;
- }
btrfs_put_fs_root(fs_root);
}
}
list_add_tail(&reloc_root->root_list, &reloc_roots);
goto out_free;
}
- if (!btrfs_grab_fs_root(fs_root)) {
- err = -ENOENT;
- goto out_free;
- }
err = __add_reloc_root(reloc_root);
BUG_ON(err < 0); /* -ENOMEM or logic error */
if (IS_ERR(fs_root)) {
err = PTR_ERR(fs_root);
} else {
- if (btrfs_grab_fs_root(fs_root)) {
- err = btrfs_orphan_cleanup(fs_root);
- btrfs_put_fs_root(fs_root);
- }
+ err = btrfs_orphan_cleanup(fs_root);
+ btrfs_put_fs_root(fs_root);
}
}
return err;