/* remove a single leaf ref from the tree. This drops the ref held by the tree only  */
int btrfs_remove_leaf_ref(struct btrfs_root *root, struct btrfs_leaf_ref *ref)
/* remove a single leaf ref from the tree. This drops the ref held by the tree only  */
int btrfs_remove_leaf_ref(struct btrfs_root *root, struct btrfs_leaf_ref *ref)
{
	struct btrfs_leaf_ref_tree *tree;
	if (!xchg(&ref->in_tree, 0))
		return 0;
	tree = ref->tree;
	spin_lock(&tree->lock);
	rb_erase(&ref->rb_node, &tree->root);
	list_del_init(&ref->list);
	spin_unlock(&tree->lock);
	btrfs_free_leaf_ref(root, ref);
	return 0;
}