Lines Matching refs:icq
34 struct io_cq *icq = container_of(head, struct io_cq, __rcu_head);
36 kmem_cache_free(icq->__rcu_icq_cache, icq);
40 * Exit an icq. Called with ioc locked for blk-mq, and with both ioc
43 static void ioc_exit_icq(struct io_cq *icq)
45 struct elevator_type *et = icq->q->elevator->type;
47 if (icq->flags & ICQ_EXITED)
51 et->ops.exit_icq(icq);
53 icq->flags |= ICQ_EXITED;
57 * Release an icq. Called with ioc locked for blk-mq, and with both ioc
60 static void ioc_destroy_icq(struct io_cq *icq)
62 struct io_context *ioc = icq->ioc;
63 struct request_queue *q = icq->q;
68 radix_tree_delete(&ioc->icq_tree, icq->q->id);
69 hlist_del_init(&icq->ioc_node);
70 list_del_init(&icq->q_node);
73 * Both setting lookup hint to and clearing it from @icq are done
74 * under queue_lock. If it's not pointing to @icq now, it never
77 if (rcu_access_pointer(ioc->icq_hint) == icq)
80 ioc_exit_icq(icq);
83 * @icq->q might have gone away by the time RCU callback runs
84 * making it impossible to determine icq_cache. Record it in @icq.
86 icq->__rcu_icq_cache = et->icq_cache;
87 icq->flags |= ICQ_DESTROYED;
88 call_rcu(&icq->__rcu_head, icq_free_icq_rcu);
93 * dancing to unlink all icq's and then frees ioc.
102 struct io_cq *icq = hlist_entry(ioc->icq_list.first,
104 struct request_queue *q = icq->q;
107 ioc_destroy_icq(icq);
110 /* Make sure q and icq cannot be freed. */
119 * The icq may have been destroyed when the ioc lock
122 if (!(icq->flags & ICQ_DESTROYED))
123 ioc_destroy_icq(icq);
179 struct io_cq *icq;
187 hlist_for_each_entry(icq, &ioc->icq_list, ioc_node) {
188 if (icq->flags & ICQ_EXITED)
191 ioc_exit_icq(icq);
218 struct io_cq *icq = list_entry(icq_list->next,
220 struct io_context *ioc = icq->ioc;
223 if (icq->flags & ICQ_DESTROYED) {
227 ioc_destroy_icq(icq);
334 struct io_cq *icq;
339 * icq's are indexed from @ioc using radix tree and hint pointer,
342 * find a icq which points to us, it's guaranteed to be valid.
345 icq = rcu_dereference(ioc->icq_hint);
346 if (icq && icq->q == q)
349 icq = radix_tree_lookup(&ioc->icq_tree, q->id);
350 if (icq && icq->q == q)
351 rcu_assign_pointer(ioc->icq_hint, icq); /* allowed to race */
353 icq = NULL;
356 return icq;
366 * Make sure io_cq linking @ioc and @q exists. If icq doesn't exist, they
376 struct io_cq *icq;
379 icq = kmem_cache_alloc_node(et->icq_cache, gfp_mask | __GFP_ZERO,
381 if (!icq)
385 kmem_cache_free(et->icq_cache, icq);
389 icq->ioc = ioc;
390 icq->q = q;
391 INIT_LIST_HEAD(&icq->q_node);
392 INIT_HLIST_NODE(&icq->ioc_node);
394 /* lock both q and ioc and try to link @icq */
398 if (likely(!radix_tree_insert(&ioc->icq_tree, q->id, icq))) {
399 hlist_add_head(&icq->ioc_node, &ioc->icq_list);
400 list_add(&icq->q_node, &q->icq_list);
402 et->ops.init_icq(icq);
404 kmem_cache_free(et->icq_cache, icq);
405 icq = ioc_lookup_icq(ioc, q);
406 if (!icq)
407 printk(KERN_ERR "cfq: icq link failed!\n");
413 return icq;