diff options
author | Tejun Heo <tj@kernel.org> | 2011-12-14 00:33:42 +0100 |
---|---|---|
committer | Ziyan <jaraidaniel@gmail.com> | 2016-01-08 10:37:00 +0100 |
commit | 5fdfa8335c530e8a903edfb90aafcd9219d5cd91 (patch) | |
tree | e648affdab4fd50075debcba3099b38de6571420 /block/blk-ioc.c | |
parent | a6d1b8ef7ede27d73b6182b5913799ec709de249 (diff) | |
download | kernel_samsung_tuna-5fdfa8335c530e8a903edfb90aafcd9219d5cd91.tar.gz kernel_samsung_tuna-5fdfa8335c530e8a903edfb90aafcd9219d5cd91.tar.bz2 kernel_samsung_tuna-5fdfa8335c530e8a903edfb90aafcd9219d5cd91.zip |
block, cfq: move io_cq lookup to blk-ioc.c
Now that all io_cq related data structures are in block core layer,
io_cq lookup can be moved from cfq-iosched.c to blk-ioc.c.
Lookup logic from cfq_cic_lookup() is moved to ioc_lookup_icq() with
parameter return type changes (cfqd -> request_queue, cfq_io_cq ->
io_cq) and cfq_cic_lookup() becomes thin wrapper around
cfq_cic_lookup().
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/blk-ioc.c')
-rw-r--r-- | block/blk-ioc.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/block/blk-ioc.c b/block/blk-ioc.c index 4802a66bb8b..17f1baf2c4f 100644 --- a/block/blk-ioc.c +++ b/block/blk-ioc.c @@ -269,6 +269,42 @@ struct io_context *get_task_io_context(struct task_struct *task, } EXPORT_SYMBOL(get_task_io_context); +/** + * ioc_lookup_icq - lookup io_cq from ioc + * @ioc: the associated io_context + * @q: the associated request_queue + * + * Look up io_cq associated with @ioc - @q pair from @ioc. Must be called + * with @q->queue_lock held. + */ +struct io_cq *ioc_lookup_icq(struct io_context *ioc, struct request_queue *q) +{ + struct io_cq *icq; + + lockdep_assert_held(q->queue_lock); + + /* + * icq's are indexed from @ioc using radix tree and hint pointer, + * both of which are protected with RCU. All removals are done + * holding both q and ioc locks, and we're holding q lock - if we + * find a icq which points to us, it's guaranteed to be valid. + */ + rcu_read_lock(); + icq = rcu_dereference(ioc->icq_hint); + if (icq && icq->q == q) + goto out; + + icq = radix_tree_lookup(&ioc->icq_tree, q->id); + if (icq && icq->q == q) + rcu_assign_pointer(ioc->icq_hint, icq); /* allowed to race */ + else + icq = NULL; +out: + rcu_read_unlock(); + return icq; +} +EXPORT_SYMBOL(ioc_lookup_icq); + void ioc_set_changed(struct io_context *ioc, int which) { struct io_cq *icq; |