ret = add_all_parents(root, path, parents, ref, level, time_seq,
extent_item_pos, total_refs, ignore_offset);
out:
- btrfs_put_fs_root(root);
+ btrfs_put_root(root);
out_free:
path->lowest_level = 0;
btrfs_release_path(path);
free_extent_buffer(root->commit_root);
free_extent_buffer(leaf);
}
- btrfs_put_fs_root(root);
+ btrfs_put_root(root);
return ERR_PTR(ret);
}
leaf = btrfs_alloc_tree_block(trans, root, 0, BTRFS_TREE_LOG_OBJECTID,
NULL, 0, 0, 0);
if (IS_ERR(leaf)) {
- btrfs_put_fs_root(root);
+ btrfs_put_root(root);
return ERR_CAST(leaf);
}
return root;
find_fail:
- btrfs_put_fs_root(root);
+ btrfs_put_root(root);
alloc_fail:
root = ERR_PTR(ret);
goto out;
root = radix_tree_lookup(&fs_info->fs_roots_radix,
(unsigned long)root_id);
if (root)
- root = btrfs_grab_fs_root(root);
+ root = btrfs_grab_root(root);
spin_unlock(&fs_info->fs_roots_radix_lock);
return root;
}
(unsigned long)root->root_key.objectid,
root);
if (ret == 0) {
- btrfs_grab_fs_root(root);
+ btrfs_grab_root(root);
set_bit(BTRFS_ROOT_IN_RADIX, &root->state);
}
spin_unlock(&fs_info->fs_roots_radix_lock);
root->root_key.objectid, root->root_key.offset,
refcount_read(&root->refs));
while (refcount_read(&root->refs) > 1)
- btrfs_put_fs_root(root);
- btrfs_put_fs_root(root);
+ btrfs_put_root(root);
+ btrfs_put_root(root);
}
#endif
}
btrfs_free_ref_cache(fs_info);
kfree(fs_info->balance_ctl);
kfree(fs_info->delayed_root);
- btrfs_put_fs_root(fs_info->extent_root);
- btrfs_put_fs_root(fs_info->tree_root);
- btrfs_put_fs_root(fs_info->chunk_root);
- btrfs_put_fs_root(fs_info->dev_root);
- btrfs_put_fs_root(fs_info->csum_root);
- btrfs_put_fs_root(fs_info->quota_root);
- btrfs_put_fs_root(fs_info->uuid_root);
- btrfs_put_fs_root(fs_info->free_space_root);
- btrfs_put_fs_root(fs_info->fs_root);
+ btrfs_put_root(fs_info->extent_root);
+ btrfs_put_root(fs_info->tree_root);
+ btrfs_put_root(fs_info->chunk_root);
+ btrfs_put_root(fs_info->dev_root);
+ btrfs_put_root(fs_info->csum_root);
+ btrfs_put_root(fs_info->quota_root);
+ btrfs_put_root(fs_info->uuid_root);
+ btrfs_put_root(fs_info->free_space_root);
+ btrfs_put_root(fs_info->fs_root);
btrfs_check_leaked_roots(fs_info);
kfree(fs_info->super_copy);
kfree(fs_info->super_for_commit);
int ret;
if (location->objectid == BTRFS_ROOT_TREE_OBJECTID)
- return btrfs_grab_fs_root(fs_info->tree_root);
+ return btrfs_grab_root(fs_info->tree_root);
if (location->objectid == BTRFS_EXTENT_TREE_OBJECTID)
- return btrfs_grab_fs_root(fs_info->extent_root);
+ return btrfs_grab_root(fs_info->extent_root);
if (location->objectid == BTRFS_CHUNK_TREE_OBJECTID)
- return btrfs_grab_fs_root(fs_info->chunk_root);
+ return btrfs_grab_root(fs_info->chunk_root);
if (location->objectid == BTRFS_DEV_TREE_OBJECTID)
- return btrfs_grab_fs_root(fs_info->dev_root);
+ return btrfs_grab_root(fs_info->dev_root);
if (location->objectid == BTRFS_CSUM_TREE_OBJECTID)
- return btrfs_grab_fs_root(fs_info->csum_root);
+ return btrfs_grab_root(fs_info->csum_root);
if (location->objectid == BTRFS_QUOTA_TREE_OBJECTID)
- return btrfs_grab_fs_root(fs_info->quota_root) ?
+ return btrfs_grab_root(fs_info->quota_root) ?
fs_info->quota_root : ERR_PTR(-ENOENT);
if (location->objectid == BTRFS_UUID_TREE_OBJECTID)
- return btrfs_grab_fs_root(fs_info->uuid_root) ?
+ return btrfs_grab_root(fs_info->uuid_root) ?
fs_info->uuid_root : ERR_PTR(-ENOENT);
if (location->objectid == BTRFS_FREE_SPACE_TREE_OBJECTID)
- return btrfs_grab_fs_root(fs_info->free_space_root) ?
+ return btrfs_grab_root(fs_info->free_space_root) ?
fs_info->free_space_root : ERR_PTR(-ENOENT);
again:
root = btrfs_lookup_fs_root(fs_info, location->objectid);
if (root) {
if (check_ref && btrfs_root_refs(&root->root_item) == 0) {
- btrfs_put_fs_root(root);
+ btrfs_put_root(root);
return ERR_PTR(-ENOENT);
}
return root;
* we have the third for returning it, and the caller will put it when
* it's done with the root.
*/
- btrfs_grab_fs_root(root);
+ btrfs_grab_root(root);
ret = btrfs_insert_fs_root(fs_info, root);
if (ret) {
- btrfs_put_fs_root(root);
+ btrfs_put_root(root);
if (ret == -EEXIST) {
btrfs_free_fs_root(root);
goto again;
} else {
free_extent_buffer(gang[0]->node);
free_extent_buffer(gang[0]->commit_root);
- btrfs_put_fs_root(gang[0]);
+ btrfs_put_root(gang[0]);
}
}
if (IS_ERR(log_tree_root->node)) {
btrfs_warn(fs_info, "failed to read log tree");
ret = PTR_ERR(log_tree_root->node);
- btrfs_put_fs_root(log_tree_root);
+ btrfs_put_root(log_tree_root);
return ret;
} else if (!extent_buffer_uptodate(log_tree_root->node)) {
btrfs_err(fs_info, "failed to read log tree");
free_extent_buffer(log_tree_root->node);
- btrfs_put_fs_root(log_tree_root);
+ btrfs_put_root(log_tree_root);
return -EIO;
}
/* returns with log_tree_root freed on success */
btrfs_handle_fs_error(fs_info, ret,
"Failed to recover log tree");
free_extent_buffer(log_tree_root->node);
- btrfs_put_fs_root(log_tree_root);
+ btrfs_put_root(log_tree_root);
return ret;
}
radix_tree_delete(&fs_info->fs_roots_radix,
(unsigned long)root->root_key.objectid);
if (test_and_clear_bit(BTRFS_ROOT_IN_RADIX, &root->state))
- btrfs_put_fs_root(root);
+ btrfs_put_root(root);
spin_unlock(&fs_info->fs_roots_radix_lock);
if (btrfs_root_refs(&root->root_item) == 0)
if (root->reloc_root) {
free_extent_buffer(root->reloc_root->node);
free_extent_buffer(root->reloc_root->commit_root);
- btrfs_put_fs_root(root->reloc_root);
+ btrfs_put_root(root->reloc_root);
root->reloc_root = NULL;
}
}
free_extent_buffer(root->commit_root);
kfree(root->free_ino_ctl);
kfree(root->free_ino_pinned);
- btrfs_put_fs_root(root);
+ btrfs_put_root(root);
}
int btrfs_cleanup_fs_roots(struct btrfs_fs_info *fs_info)
continue;
}
/* grab all the search result for later use */
- gang[i] = btrfs_grab_fs_root(gang[i]);
+ gang[i] = btrfs_grab_root(gang[i]);
}
srcu_read_unlock(&fs_info->subvol_srcu, index);
err = btrfs_orphan_cleanup(gang[i]);
if (err)
break;
- btrfs_put_fs_root(gang[i]);
+ btrfs_put_root(gang[i]);
}
root_objectid++;
}
/* release the uncleaned roots due to error */
for (; i < ret; i++) {
if (gang[i])
- btrfs_put_fs_root(gang[i]);
+ btrfs_put_root(gang[i]);
}
return err;
}
while (!list_empty(&splice)) {
root = list_first_entry(&splice, struct btrfs_root,
delalloc_root);
- root = btrfs_grab_fs_root(root);
+ root = btrfs_grab_root(root);
BUG_ON(!root);
spin_unlock(&fs_info->delalloc_root_lock);
btrfs_destroy_delalloc_inodes(root);
- btrfs_put_fs_root(root);
+ btrfs_put_root(root);
spin_lock(&fs_info->delalloc_root_lock);
}
* If you want to ensure the whole tree is safe, you should use
* fs_info->subvol_srcu
*/
-static inline struct btrfs_root *btrfs_grab_fs_root(struct btrfs_root *root)
+static inline struct btrfs_root *btrfs_grab_root(struct btrfs_root *root)
{
if (!root)
return NULL;
return NULL;
}
-static inline void btrfs_put_fs_root(struct btrfs_root *root)
+static inline void btrfs_put_root(struct btrfs_root *root)
{
if (!root)
return;
key.offset = 0;
inode = btrfs_iget(sb, &key, root);
- btrfs_put_fs_root(root);
+ btrfs_put_root(root);
if (IS_ERR(inode)) {
err = PTR_ERR(inode);
goto fail;
} else {
free_extent_buffer(root->node);
free_extent_buffer(root->commit_root);
- btrfs_put_fs_root(root);
+ btrfs_put_root(root);
}
root_dropped = true;
out_end_trans:
key.type = BTRFS_INODE_ITEM_KEY;
key.offset = 0;
inode = btrfs_iget(fs_info->sb, &key, inode_root);
- btrfs_put_fs_root(inode_root);
+ btrfs_put_root(inode_root);
if (IS_ERR(inode)) {
ret = PTR_ERR(inode);
goto cleanup;
free_extent_buffer(free_space_root->node);
free_extent_buffer(free_space_root->commit_root);
- btrfs_put_fs_root(free_space_root);
+ btrfs_put_root(free_space_root);
return btrfs_commit_transaction(trans);
inode = btrfs_iget(dir->i_sb, &location, sub_root);
}
if (root != sub_root)
- btrfs_put_fs_root(sub_root);
+ btrfs_put_root(sub_root);
srcu_read_unlock(&fs_info->subvol_srcu, index);
if (!IS_ERR(inode) && root != sub_root) {
while (!list_empty(&splice) && nr) {
root = list_first_entry(&splice, struct btrfs_root,
delalloc_root);
- root = btrfs_grab_fs_root(root);
+ root = btrfs_grab_root(root);
BUG_ON(!root);
list_move_tail(&root->delalloc_root,
&fs_info->delalloc_roots);
spin_unlock(&fs_info->delalloc_root_lock);
ret = start_delalloc_inodes(root, nr, false);
- btrfs_put_fs_root(root);
+ btrfs_put_root(root);
if (ret < 0)
goto out;
btrfs_record_root_in_trans(trans, new_root);
ret = btrfs_create_subvol_root(trans, new_root, root, new_dirid);
- btrfs_put_fs_root(new_root);
+ btrfs_put_root(new_root);
if (ret) {
/* We potentially lose an unused inode item here */
btrfs_abort_transaction(trans, ret);
d_instantiate(dentry, inode);
ret = 0;
fail:
- btrfs_put_fs_root(pending_snapshot->snap);
+ btrfs_put_root(pending_snapshot->snap);
btrfs_subvolume_release_metadata(fs_info, &pending_snapshot->block_rsv);
dec_and_free:
if (snapshot_force_cow)
if (sk->tree_id == 0) {
/* search the root of the inode that was passed */
- root = btrfs_grab_fs_root(BTRFS_I(inode)->root);
+ root = btrfs_grab_root(BTRFS_I(inode)->root);
} else {
key.objectid = sk->tree_id;
key.type = BTRFS_ROOT_ITEM_KEY;
ret = 0;
err:
sk->nr_items = num_found;
- btrfs_put_fs_root(root);
+ btrfs_put_root(root);
btrfs_free_path(path);
return ret;
}
name[total_len] = '\0';
ret = 0;
out:
- btrfs_put_fs_root(root);
+ btrfs_put_root(root);
btrfs_free_path(path);
return ret;
}
memmove(args->path, ptr, total_len);
args->path[total_len] = '\0';
- btrfs_put_fs_root(root);
+ btrfs_put_root(root);
root = NULL;
btrfs_release_path(path);
}
args->name[item_len] = 0;
out_put:
- btrfs_put_fs_root(root);
+ btrfs_put_root(root);
out:
btrfs_free_path(path);
return ret;
ret = -EFAULT;
out:
- btrfs_put_fs_root(root);
+ btrfs_put_root(root);
out_free:
btrfs_free_path(path);
kzfree(subvol_info);
btrfs_set_fs_incompat(fs_info, DEFAULT_SUBVOL);
btrfs_end_transaction(trans);
out_free:
- btrfs_put_fs_root(new_root);
+ btrfs_put_root(new_root);
btrfs_free_path(path);
out:
mnt_drop_write_file(file);
while (!list_empty(&splice) && nr) {
root = list_first_entry(&splice, struct btrfs_root,
ordered_root);
- root = btrfs_grab_fs_root(root);
+ root = btrfs_grab_root(root);
BUG_ON(!root);
list_move_tail(&root->ordered_root,
&fs_info->ordered_roots);
done = btrfs_wait_ordered_extents(root, nr,
range_start, range_len);
- btrfs_put_fs_root(root);
+ btrfs_put_root(root);
spin_lock(&fs_info->ordered_root_lock);
if (nr != U64_MAX) {
if (ret) {
free_extent_buffer(quota_root->node);
free_extent_buffer(quota_root->commit_root);
- btrfs_put_fs_root(quota_root);
+ btrfs_put_root(quota_root);
}
out:
if (ret) {
free_extent_buffer(quota_root->node);
free_extent_buffer(quota_root->commit_root);
- btrfs_put_fs_root(quota_root);
+ btrfs_put_root(quota_root);
end_trans:
ret = btrfs_end_transaction(trans);
{
if (node) {
cache->nr_nodes--;
- btrfs_put_fs_root(node->root);
+ btrfs_put_root(node->root);
kfree(node);
}
}
root = (struct btrfs_root *)node->data;
}
spin_unlock(&rc->reloc_root_tree.lock);
- return btrfs_grab_fs_root(root);
+ return btrfs_grab_root(root);
}
static int is_cowonly_root(u64 root_objectid)
ASSERT(btrfs_root_bytenr(&root->root_item) ==
cur->bytenr);
if (should_ignore_root(root)) {
- btrfs_put_fs_root(root);
+ btrfs_put_root(root);
list_add(&cur->list, &useless);
} else {
cur->root = root;
ret = btrfs_search_slot(NULL, root, node_key, path2, 0, 0);
path2->lowest_level = 0;
if (ret < 0) {
- btrfs_put_fs_root(root);
+ btrfs_put_root(root);
err = ret;
goto out;
}
root->root_key.objectid,
node_key->objectid, node_key->type,
node_key->offset);
- btrfs_put_fs_root(root);
+ btrfs_put_root(root);
err = -ENOENT;
goto out;
}
ASSERT(btrfs_root_bytenr(&root->root_item) ==
lower->bytenr);
if (should_ignore_root(root)) {
- btrfs_put_fs_root(root);
+ btrfs_put_root(root);
list_add(&lower->list, &useless);
} else {
lower->root = root;
edge = alloc_backref_edge(cache);
if (!edge) {
- btrfs_put_fs_root(root);
+ btrfs_put_root(root);
err = -ENOMEM;
goto out;
}
if (!rb_node) {
upper = alloc_backref_node(cache);
if (!upper) {
- btrfs_put_fs_root(root);
+ btrfs_put_root(root);
free_backref_edge(cache, edge);
err = -ENOMEM;
goto out;
edge->node[UPPER] = upper;
if (rb_node) {
- btrfs_put_fs_root(root);
+ btrfs_put_root(root);
break;
}
lower = upper;
new_node->level = node->level;
new_node->lowest = node->lowest;
new_node->checked = 1;
- new_node->root = btrfs_grab_fs_root(dest);
+ new_node->root = btrfs_grab_root(dest);
ASSERT(new_node->root);
if (!node->lowest) {
btrfs_update_reloc_root(trans, root);
if (list_empty(&root->reloc_dirty_list)) {
- btrfs_grab_fs_root(root);
+ btrfs_grab_root(root);
list_add_tail(&root->reloc_dirty_list, &rc->dirty_subvol_roots);
}
}
*/
smp_wmb();
clear_bit(BTRFS_ROOT_DEAD_RELOC_TREE, &root->state);
- btrfs_put_fs_root(root);
+ btrfs_put_root(root);
} else {
/* Orphan reloc tree, just clean it up */
ret2 = btrfs_drop_snapshot(root, NULL, 0, 1);
btrfs_update_reloc_root(trans, root);
list_add(&reloc_root->root_list, &reloc_roots);
- btrfs_put_fs_root(root);
+ btrfs_put_root(root);
}
list_splice(&reloc_roots, &rc->reloc_roots);
BUG_ON(root->reloc_root != reloc_root);
ret = merge_reloc_root(rc, root);
- btrfs_put_fs_root(root);
+ btrfs_put_root(root);
if (ret) {
if (list_empty(&reloc_root->root_list))
list_add_tail(&reloc_root->root_list,
BUG_ON(IS_ERR(root));
BUG_ON(root->reloc_root != reloc_root);
ret = btrfs_record_root_in_trans(trans, root);
- btrfs_put_fs_root(root);
+ btrfs_put_root(root);
return ret;
}
BUG_ON(next->new_bytenr);
BUG_ON(!list_empty(&next->list));
next->new_bytenr = root->node->start;
- btrfs_put_fs_root(next->root);
- next->root = btrfs_grab_fs_root(root);
+ btrfs_put_root(next->root);
+ next->root = btrfs_grab_root(root);
ASSERT(next->root);
list_add_tail(&next->list,
&rc->backref_cache.changed);
btrfs_record_root_in_trans(trans, root);
root = root->reloc_root;
node->new_bytenr = root->node->start;
- btrfs_put_fs_root(node->root);
- node->root = btrfs_grab_fs_root(root);
+ btrfs_put_root(node->root);
+ node->root = btrfs_grab_root(root);
ASSERT(node->root);
list_add_tail(&node->list, &rc->backref_cache.changed);
} else {
}
out:
- btrfs_put_fs_root(root);
+ btrfs_put_root(root);
out_free:
btrfs_free_path(path);
return err;
trans = btrfs_start_transaction(root, 6);
if (IS_ERR(trans)) {
- btrfs_put_fs_root(root);
+ btrfs_put_root(root);
return ERR_CAST(trans);
}
err = btrfs_orphan_add(trans, BTRFS_I(inode));
out:
- btrfs_put_fs_root(root);
+ btrfs_put_root(root);
btrfs_end_transaction(trans);
btrfs_btree_balance_dirty(fs_info);
if (err) {
goto out;
}
} else {
- btrfs_put_fs_root(fs_root);
+ btrfs_put_root(fs_root);
}
}
err = __add_reloc_root(reloc_root);
BUG_ON(err < 0); /* -ENOMEM or logic error */
fs_root->reloc_root = reloc_root;
- btrfs_put_fs_root(fs_root);
+ btrfs_put_root(fs_root);
}
err = btrfs_commit_transaction(trans);
err = PTR_ERR(fs_root);
} else {
err = btrfs_orphan_cleanup(fs_root);
- btrfs_put_fs_root(fs_root);
+ btrfs_put_root(fs_root);
}
}
return err;
set_bit(BTRFS_ROOT_DEAD_TREE, &root->state);
btrfs_add_dead_root(root);
}
- btrfs_put_fs_root(root);
+ btrfs_put_root(root);
}
btrfs_free_path(path);
ret = btrfs_search_slot(NULL, local_root, &key, swarn->path, 0, 0);
if (ret) {
- btrfs_put_fs_root(local_root);
+ btrfs_put_root(local_root);
btrfs_release_path(swarn->path);
goto err;
}
ipath = init_ipath(4096, local_root, swarn->path);
memalloc_nofs_restore(nofs_flag);
if (IS_ERR(ipath)) {
- btrfs_put_fs_root(local_root);
+ btrfs_put_root(local_root);
ret = PTR_ERR(ipath);
ipath = NULL;
goto err;
min(isize - offset, (u64)PAGE_SIZE), nlink,
(char *)(unsigned long)ipath->fspath->val[i]);
- btrfs_put_fs_root(local_root);
+ btrfs_put_root(local_root);
free_ipath(ipath);
return 0;
if (!btrfs_root_readonly(clone_root) ||
btrfs_root_dead(clone_root)) {
spin_unlock(&clone_root->root_item_lock);
- btrfs_put_fs_root(clone_root);
+ btrfs_put_root(clone_root);
srcu_read_unlock(&fs_info->subvol_srcu, index);
ret = -EPERM;
goto out;
if (clone_root->dedupe_in_progress) {
dedupe_in_progress_warn(clone_root);
spin_unlock(&clone_root->root_item_lock);
- btrfs_put_fs_root(clone_root);
+ btrfs_put_root(clone_root);
srcu_read_unlock(&fs_info->subvol_srcu, index);
ret = -EAGAIN;
goto out;
* for possible clone sources.
*/
sctx->clone_roots[sctx->clone_roots_cnt++].root =
- btrfs_grab_fs_root(sctx->send_root);
+ btrfs_grab_root(sctx->send_root);
/* We do a bsearch later */
sort(sctx->clone_roots, sctx->clone_roots_cnt,
for (i = 0; i < sctx->clone_roots_cnt; i++) {
btrfs_root_dec_send_in_progress(
sctx->clone_roots[i].root);
- btrfs_put_fs_root(sctx->clone_roots[i].root);
+ btrfs_put_root(sctx->clone_roots[i].root);
}
} else {
for (i = 0; sctx && i < clone_sources_to_rollback; i++) {
btrfs_root_dec_send_in_progress(
sctx->clone_roots[i].root);
- btrfs_put_fs_root(sctx->clone_roots[i].root);
+ btrfs_put_root(sctx->clone_roots[i].root);
}
btrfs_root_dec_send_in_progress(send_root);
}
if (sctx && !IS_ERR_OR_NULL(sctx->parent_root)) {
btrfs_root_dec_send_in_progress(sctx->parent_root);
- btrfs_put_fs_root(sctx->parent_root);
+ btrfs_put_root(sctx->parent_root);
}
kvfree(clone_sources_tmp);
ptr[0] = '/';
btrfs_release_path(path);
}
- btrfs_put_fs_root(fs_root);
+ btrfs_put_root(fs_root);
fs_root = NULL;
}
return name;
err:
- btrfs_put_fs_root(fs_root);
+ btrfs_put_root(fs_root);
btrfs_free_path(path);
kfree(name);
return ERR_PTR(ret);
/* One for allocate_extent_buffer */
free_extent_buffer(root->node);
}
- btrfs_put_fs_root(root);
+ btrfs_put_root(root);
}
struct btrfs_block_group *
clear_extent_bits(&log->dirty_log_pages, 0, (u64)-1,
EXTENT_DIRTY | EXTENT_NEW | EXTENT_NEED_WAIT);
free_extent_buffer(log->node);
- btrfs_put_fs_root(log);
+ btrfs_put_root(log);
}
/*
log->node->len);
free_extent_buffer(log->node);
free_extent_buffer(log->commit_root);
- btrfs_put_fs_root(log);
+ btrfs_put_root(log);
if (!ret)
goto next;
}
wc.replay_dest->log_root = NULL;
- btrfs_put_fs_root(wc.replay_dest);
+ btrfs_put_root(wc.replay_dest);
free_extent_buffer(log->node);
free_extent_buffer(log->commit_root);
- btrfs_put_fs_root(log);
+ btrfs_put_root(log);
if (ret)
goto error;
free_extent_buffer(log_root_tree->node);
log_root_tree->log_root = NULL;
clear_bit(BTRFS_FS_LOG_RECOVERING, &fs_info->flags);
- btrfs_put_fs_root(log_root_tree);
+ btrfs_put_root(log_root_tree);
return 0;
error:
ret = 1;
break;
}
- btrfs_put_fs_root(subvol_root);
+ btrfs_put_root(subvol_root);
out:
return ret;
}