4 #include <linux/kernel.h>
5 #include <linux/module.h>
10 #include <linux/slab.h>
40 static void ioc_exit_icq(
struct io_cq *icq)
42 struct elevator_type *
et = icq->
q->elevator->type;
47 if (et->ops.elevator_exit_icq_fn)
48 et->ops.elevator_exit_icq_fn(icq);
54 static void ioc_destroy_icq(
struct io_cq *icq)
58 struct elevator_type *et = q->elevator->type;
65 list_del_init(&icq->
q_node);
103 while (!hlist_empty(&ioc->
icq_list)) {
108 if (spin_trylock(q->queue_lock)) {
109 ioc_destroy_icq(icq);
110 spin_unlock(q->queue_lock);
112 spin_unlock_irqrestore(&ioc->
lock, flags);
118 spin_unlock_irqrestore(&ioc->
lock, flags);
133 bool free_ioc =
false;
144 if (atomic_long_dec_and_test(&ioc->
refcount)) {
150 spin_unlock_irqrestore(&ioc->
lock, flags);
186 if (spin_trylock(icq->
q->queue_lock)) {
188 spin_unlock(icq->
q->queue_lock);
190 spin_unlock_irqrestore(&ioc->
lock, flags);
195 spin_unlock_irqrestore(&ioc->
lock, flags);
224 while (!list_empty(&q->icq_list)) {
229 spin_lock(&ioc->
lock);
230 ioc_destroy_icq(icq);
231 spin_unlock(&ioc->
lock);
332 if (icq && icq->
q == q)
336 if (icq && icq->
q == q)
361 struct elevator_type *et = q->elevator->type;
377 INIT_LIST_HEAD(&icq->
q_node);
381 spin_lock_irq(q->queue_lock);
382 spin_lock(&ioc->
lock);
386 list_add(&icq->
q_node, &q->icq_list);
387 if (et->ops.elevator_init_icq_fn)
388 et->ops.elevator_init_icq_fn(icq);
396 spin_unlock(&ioc->
lock);
397 spin_unlock_irq(q->queue_lock);
398 radix_tree_preload_end();
402 static int __init blk_ioc_init(
void)