/* Add cic into ioc, using cfqd as the search key. This enables us to lookup the process specific cfq io context when entered from the block layer. Also adds the cic to a per-cfqd list, used when this queue is removed.  */
static int cfq_cic_link(struct cfq_data *cfqd, struct io_context *ioc, struct cfq_io_context *cic, gfp_t gfp_mask)
/* Add cic into ioc, using cfqd as the search key. This enables us to lookup the process specific cfq io context when entered from the block layer. Also adds the cic to a per-cfqd list, used when this queue is removed.  */
static int cfq_cic_link(struct cfq_data *cfqd, struct io_context *ioc, struct cfq_io_context *cic, gfp_t gfp_mask)
{
	unsigned long flags;
	int ret;
	ret = radix_tree_preload(gfp_mask);
	if (!ret) {
		cic->ioc = ioc;
		cic->key = cfqd;
		spin_lock_irqsave(&ioc->lock, flags);
		ret = radix_tree_insert(&ioc->radix_root,
						(unsigned long) cfqd, cic);
		if (!ret)
			hlist_add_head_rcu(&cic->cic_list, &ioc->cic_list);
		spin_unlock_irqrestore(&ioc->lock, flags);
		radix_tree_preload_end();
		if (!ret) {
			spin_lock_irqsave(cfqd->queue->queue_lock, flags);
			list_add(&cic->queue_list, &cfqd->cic_list);
			spin_unlock_irqrestore(cfqd->queue->queue_lock, flags);
		}
	}
	if (ret)
		printk(KERN_ERR "cfq: cic link failed!\n");
	return ret;
}