Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 283287a5 authored by Tejun Heo's avatar Tejun Heo Committed by Jens Axboe
Browse files

block, cfq: misc updates to cfq_io_context



Make the following changes to prepare for ioc/cic management cleanup.

* Add cic->q so that ioc can determine the associated queue without
  querying cfq.  This will eventually replace ->key.

* Factor out cfq_release_cic() from cic_free_func().  This function
  assumes that the caller handled locking.

* Rename __cfq_exit_single_io_context() to cfq_exit_cic() and make it
  take only @cic.

* Restructure cfq_cic_link() for future updates.

This patch doesn't introduce any functional changes.

Signed-off-by: default avatarTejun Heo <tj@kernel.org>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 09ac46c4
Loading
Loading
Loading
Loading
+32 −26
Original line number Original line Diff line number Diff line
@@ -2709,21 +2709,26 @@ static void cfq_cic_free(struct cfq_io_context *cic)
	call_rcu(&cic->rcu_head, cfq_cic_free_rcu);
	call_rcu(&cic->rcu_head, cfq_cic_free_rcu);
}
}


static void cic_free_func(struct io_context *ioc, struct cfq_io_context *cic)
static void cfq_release_cic(struct cfq_io_context *cic)
{
{
	unsigned long flags;
	struct io_context *ioc = cic->ioc;
	unsigned long dead_key = (unsigned long) cic->key;
	unsigned long dead_key = (unsigned long) cic->key;


	BUG_ON(!(dead_key & CIC_DEAD_KEY));
	BUG_ON(!(dead_key & CIC_DEAD_KEY));

	spin_lock_irqsave(&ioc->lock, flags);
	radix_tree_delete(&ioc->radix_root, dead_key >> CIC_DEAD_INDEX_SHIFT);
	radix_tree_delete(&ioc->radix_root, dead_key >> CIC_DEAD_INDEX_SHIFT);
	hlist_del_rcu(&cic->cic_list);
	hlist_del_rcu(&cic->cic_list);
	spin_unlock_irqrestore(&ioc->lock, flags);

	cfq_cic_free(cic);
	cfq_cic_free(cic);
}
}


static void cic_free_func(struct io_context *ioc, struct cfq_io_context *cic)
{
	unsigned long flags;

	spin_lock_irqsave(&ioc->lock, flags);
	cfq_release_cic(cic);
	spin_unlock_irqrestore(&ioc->lock, flags);
}

/*
/*
 * Must be called with rcu_read_lock() held or preemption otherwise disabled.
 * Must be called with rcu_read_lock() held or preemption otherwise disabled.
 * Only two callers of this - ->dtor() which is called with the rcu_read_lock(),
 * Only two callers of this - ->dtor() which is called with the rcu_read_lock(),
@@ -2773,9 +2778,9 @@ static void cfq_exit_cfqq(struct cfq_data *cfqd, struct cfq_queue *cfqq)
	cfq_put_queue(cfqq);
	cfq_put_queue(cfqq);
}
}


static void __cfq_exit_single_io_context(struct cfq_data *cfqd,
static void cfq_exit_cic(struct cfq_io_context *cic)
					 struct cfq_io_context *cic)
{
{
	struct cfq_data *cfqd = cic_to_cfqd(cic);
	struct io_context *ioc = cic->ioc;
	struct io_context *ioc = cic->ioc;


	list_del_init(&cic->queue_list);
	list_del_init(&cic->queue_list);
@@ -2823,7 +2828,7 @@ static void cfq_exit_single_io_context(struct io_context *ioc,
		 */
		 */
		smp_read_barrier_depends();
		smp_read_barrier_depends();
		if (cic->key == cfqd)
		if (cic->key == cfqd)
			__cfq_exit_single_io_context(cfqd, cic);
			cfq_exit_cic(cic);


		spin_unlock_irqrestore(q->queue_lock, flags);
		spin_unlock_irqrestore(q->queue_lock, flags);
	}
	}
@@ -3161,9 +3166,12 @@ static int cfq_cic_link(struct cfq_data *cfqd, struct io_context *ioc,
	int ret;
	int ret;


	ret = radix_tree_preload(gfp_mask);
	ret = radix_tree_preload(gfp_mask);
	if (!ret) {
	if (ret)
		goto out;

	cic->ioc = ioc;
	cic->ioc = ioc;
	cic->key = cfqd;
	cic->key = cfqd;
	cic->q = cfqd->queue;


	spin_lock_irqsave(&ioc->lock, flags);
	spin_lock_irqsave(&ioc->lock, flags);
	ret = radix_tree_insert(&ioc->radix_root, cfqd->queue->id, cic);
	ret = radix_tree_insert(&ioc->radix_root, cfqd->queue->id, cic);
@@ -3178,11 +3186,9 @@ static int cfq_cic_link(struct cfq_data *cfqd, struct io_context *ioc,
		list_add(&cic->queue_list, &cfqd->cic_list);
		list_add(&cic->queue_list, &cfqd->cic_list);
		spin_unlock_irqrestore(cfqd->queue->queue_lock, flags);
		spin_unlock_irqrestore(cfqd->queue->queue_lock, flags);
	}
	}
	}
out:

	if (ret)
	if (ret)
		printk(KERN_ERR "cfq: cic link failed!\n");
		printk(KERN_ERR "cfq: cic link failed!\n");

	return ret;
	return ret;
}
}


@@ -3922,7 +3928,7 @@ static void cfq_exit_queue(struct elevator_queue *e)
							struct cfq_io_context,
							struct cfq_io_context,
							queue_list);
							queue_list);


		__cfq_exit_single_io_context(cfqd, cic);
		cfq_exit_cic(cic);
	}
	}


	cfq_put_async_queues(cfqd);
	cfq_put_async_queues(cfqd);
+1 −0
Original line number Original line Diff line number Diff line
@@ -15,6 +15,7 @@ struct cfq_ttime {


struct cfq_io_context {
struct cfq_io_context {
	void *key;
	void *key;
	struct request_queue *q;


	struct cfq_queue *cfqq[2];
	struct cfq_queue *cfqq[2];