/* The path must have already been setup for deleting the leaf, including all the proper balancing. path->nodes must be locked.  */
static noinline int btrfs_del_leaf(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct btrfs_path *path, struct extent_buffer *leaf)
/* The path must have already been setup for deleting the leaf, including all the proper balancing. path->nodes must be locked.  */
static noinline int btrfs_del_leaf(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct btrfs_path *path, struct extent_buffer *leaf)
{
	int ret;
	WARN_ON(btrfs_header_generation(leaf) != trans->transid);
	ret = del_ptr(trans, root, path, 1, path->slots[1]);
	if (ret)
		return ret;
	btrfs_unlock_up_safe(path, 0);
	ret = btrfs_free_tree_block(trans, root, leaf->start, leaf->len,
				    0, root->root_key.objectid, 0);
	return ret;
}