/* RB-tree support functions for inserting/lookup/removal of requests in a sorted RB tree.  */
struct request* elv_rb_add(struct rb_root *root, struct request *rq)
/* RB-tree support functions for inserting/lookup/removal of requests in a sorted RB tree.  */
struct request* elv_rb_add(struct rb_root *root, struct request *rq)
{
	struct rb_node **p = &root->rb_node;
	struct rb_node *parent = NULL;
	struct request *__rq;
	while (*p) {
		parent = *p;
		__rq = rb_entry(parent, struct request, rb_node);
		if (blk_rq_pos(rq) < blk_rq_pos(__rq))
			p = &(*p)->rb_left;
		else if (blk_rq_pos(rq) > blk_rq_pos(__rq))
			p = &(*p)->rb_right;
		else
			return __rq;
	}
	rb_link_node(&rq->rb_node, parent, p);
	rb_insert_color(&rq->rb_node, root);
	return NULL;
}