Lines Matching defs:ioc

22  * @ioc: io_context to get
24 * Increment reference count to @ioc.
26 void get_io_context(struct io_context *ioc)
28 BUG_ON(atomic_long_read(&ioc->refcount) <= 0);
29 atomic_long_inc(&ioc->refcount);
40 * Exit an icq. Called with ioc locked for blk-mq, and with both ioc
57 * Release an icq. Called with ioc locked for blk-mq, and with both ioc
62 struct io_context *ioc = icq->ioc;
66 lockdep_assert_held(&ioc->lock);
68 radix_tree_delete(&ioc->icq_tree, icq->q->id);
77 if (rcu_access_pointer(ioc->icq_hint) == icq)
78 rcu_assign_pointer(ioc->icq_hint, NULL);
92 * Slow path for ioc release in put_io_context(). Performs double-lock
93 * dancing to unlink all icq's and then frees ioc.
97 struct io_context *ioc = container_of(work, struct io_context,
99 spin_lock_irq(&ioc->lock);
101 while (!hlist_empty(&ioc->icq_list)) {
102 struct io_cq *icq = hlist_entry(ioc->icq_list.first,
114 spin_unlock(&ioc->lock);
116 spin_lock(&ioc->lock);
119 * The icq may have been destroyed when the ioc lock
130 spin_unlock_irq(&ioc->lock);
132 kmem_cache_free(iocontext_cachep, ioc);
137 * @ioc: io_context to put
139 * Decrement reference count of @ioc and release it if the count reaches
142 void put_io_context(struct io_context *ioc)
147 if (ioc == NULL)
150 BUG_ON(atomic_long_read(&ioc->refcount) <= 0);
153 * Releasing ioc requires reverse order double locking and we may
156 if (atomic_long_dec_and_test(&ioc->refcount)) {
157 spin_lock_irqsave(&ioc->lock, flags);
158 if (!hlist_empty(&ioc->icq_list))
160 &ioc->release_work);
163 spin_unlock_irqrestore(&ioc->lock, flags);
167 kmem_cache_free(iocontext_cachep, ioc);
171 * put_io_context_active - put active reference on ioc
172 * @ioc: ioc of interest
175 * put, @ioc can never issue further IOs and ioscheds are notified.
177 void put_io_context_active(struct io_context *ioc)
181 if (!atomic_dec_and_test(&ioc->active_ref)) {
182 put_io_context(ioc);
186 spin_lock_irq(&ioc->lock);
187 hlist_for_each_entry(icq, &ioc->icq_list, ioc_node) {
193 spin_unlock_irq(&ioc->lock);
195 put_io_context(ioc);
201 struct io_context *ioc;
204 ioc = task->io_context;
208 atomic_dec(&ioc->nr_tasks);
209 put_io_context_active(ioc);
220 struct io_context *ioc = icq->ioc;
222 spin_lock_irqsave(&ioc->lock, flags);
224 spin_unlock_irqrestore(&ioc->lock, flags);
228 spin_unlock_irqrestore(&ioc->lock, flags);
234 * ioc_clear_queue - break any ioc association with the specified queue
252 struct io_context *ioc;
255 ioc = kmem_cache_alloc_node(iocontext_cachep, gfp_flags | __GFP_ZERO,
257 if (unlikely(!ioc))
261 atomic_long_set(&ioc->refcount, 1);
262 atomic_set(&ioc->nr_tasks, 1);
263 atomic_set(&ioc->active_ref, 1);
264 spin_lock_init(&ioc->lock);
265 INIT_RADIX_TREE(&ioc->icq_tree, GFP_ATOMIC);
266 INIT_HLIST_HEAD(&ioc->icq_list);
267 INIT_WORK(&ioc->release_work, ioc_release_fn);
270 * Try to install. ioc shouldn't be installed if someone else
272 * that we need to allow ioc creation on exiting %current as exit
279 task->io_context = ioc;
281 kmem_cache_free(iocontext_cachep, ioc);
306 struct io_context *ioc;
312 ioc = task->io_context;
313 if (likely(ioc)) {
314 get_io_context(ioc);
316 return ioc;
325 * ioc_lookup_icq - lookup io_cq from ioc
326 * @ioc: the associated io_context
329 * Look up io_cq associated with @ioc - @q pair from @ioc. Must be called
332 struct io_cq *ioc_lookup_icq(struct io_context *ioc, struct request_queue *q)
339 * icq's are indexed from @ioc using radix tree and hint pointer,
341 * holding both q and ioc locks, and we're holding q lock - if we
345 icq = rcu_dereference(ioc->icq_hint);
349 icq = radix_tree_lookup(&ioc->icq_tree, q->id);
351 rcu_assign_pointer(ioc->icq_hint, icq); /* allowed to race */
362 * @ioc: io_context of interest
366 * Make sure io_cq linking @ioc and @q exists. If icq doesn't exist, they
369 * The caller is responsible for ensuring @ioc won't go away and @q is
372 struct io_cq *ioc_create_icq(struct io_context *ioc, struct request_queue *q,
389 icq->ioc = ioc;
394 /* lock both q and ioc and try to link @icq */
396 spin_lock(&ioc->lock);
398 if (likely(!radix_tree_insert(&ioc->icq_tree, q->id, icq))) {
399 hlist_add_head(&icq->ioc_node, &ioc->icq_list);
405 icq = ioc_lookup_icq(ioc, q);
410 spin_unlock(&ioc->lock);