btrfs-progs: add alloc_reserved_tree_block2 function

This is a simple adapter function to convert the delayed-refs structures
to the current arguments of alloc_reserved_tree_block.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
master
Nikolay Borisov 2018-06-08 15:47:56 +03:00 committed by David Sterba
parent 98197fbcc5
commit 3c8faad5cf
1 changed files with 24 additions and 0 deletions

View File

@ -2687,6 +2687,30 @@ int btrfs_reserve_extent(struct btrfs_trans_handle *trans,
return ret;
}
static int alloc_reserved_tree_block2(struct btrfs_trans_handle *trans,
struct btrfs_delayed_ref_node *node,
struct btrfs_delayed_extent_op *extent_op)
{
struct btrfs_delayed_tree_ref *ref = btrfs_delayed_node_to_tree_ref(node);
struct btrfs_key ins;
bool skinny_metadata = btrfs_fs_incompat(trans->fs_info, SKINNY_METADATA);
ins.objectid = node->bytenr;
if (skinny_metadata) {
ins.offset = ref->level;
ins.type = BTRFS_METADATA_ITEM_KEY;
} else {
ins.offset = node->num_bytes;
ins.type = BTRFS_EXTENT_ITEM_KEY;
}
return alloc_reserved_tree_block(trans, ref->root, trans->transid,
extent_op->flags_to_set,
&extent_op->key, ref->level, &ins);
}
static int alloc_reserved_tree_block(struct btrfs_trans_handle *trans,
u64 root_objectid, u64 generation,
u64 flags, struct btrfs_disk_key *key,