/* find the leaf ref for a given extent. This returns the ref struct with a usage reference incremented  */
struct btrfs_leaf_ref* btrfs_lookup_leaf_ref(struct btrfs_root *root, u64 bytenr)
/* find the leaf ref for a given extent. This returns the ref struct with a usage reference incremented  */
struct btrfs_leaf_ref* btrfs_lookup_leaf_ref(struct btrfs_root *root, u64 bytenr)
{
	struct rb_node *rb;
	struct btrfs_leaf_ref *ref = NULL;
	struct btrfs_leaf_ref_tree *tree = root->ref_tree;
again:
	if (tree) {
		spin_lock(&tree->lock);
		rb = tree_search(&tree->root, bytenr);
		if (rb)
			ref = rb_entry(rb, struct btrfs_leaf_ref, rb_node);
		if (ref)
			atomic_inc(&ref->usage);
		spin_unlock(&tree->lock);
		if (ref)
			return ref;
	}
	if (tree != &root->fs_info->shared_ref_tree) {
		tree = &root->fs_info->shared_ref_tree;
		goto again;
	}
	return NULL;
}