/* insert a new ref into the rbtree. This returns any existing refs for the same (bytenr,parent) tuple, or NULL if the new node was properly inserted.  */
static struct btrfs_delayed_ref_node* tree_insert(struct rb_root *root, struct rb_node *node)
/* insert a new ref into the rbtree. This returns any existing refs for the same (bytenr,parent) tuple, or NULL if the new node was properly inserted.  */
static struct btrfs_delayed_ref_node* tree_insert(struct rb_root *root, struct rb_node *node)
{
	struct rb_node **p = &root->rb_node;
	struct rb_node *parent_node = NULL;
	struct btrfs_delayed_ref_node *entry;
	struct btrfs_delayed_ref_node *ins;
	int cmp;
	ins = rb_entry(node, struct btrfs_delayed_ref_node, rb_node);
	while (*p) {
		parent_node = *p;
		entry = rb_entry(parent_node, struct btrfs_delayed_ref_node,
				 rb_node);
		cmp = comp_entry(entry, ins);
		if (cmp < 0)
			p = &(*p)->rb_left;
		else if (cmp > 0)
			p = &(*p)->rb_right;
		else
			return entry;
	}
	rb_link_node(node, parent_node, p);
	rb_insert_color(node, root);
	return NULL;
}