blob: 7f6b0004ca7017ade078aad6c901f87e26b480de [file] [log] [blame]
Paolo Valente70f28712013-05-09 19:10:02 +02001/*
2 * BFQ: I/O context handling.
3 *
4 * Based on ideas and code from CFQ:
5 * Copyright (C) 2003 Jens Axboe <axboe@kernel.dk>
6 *
7 * Copyright (C) 2008 Fabio Checconi <fabio@gandalf.sssup.it>
8 * Paolo Valente <paolo.valente@unimore.it>
9 *
10 * Copyright (C) 2010 Paolo Valente <paolo.valente@unimore.it>
11 */
12
13/**
14 * icq_to_bic - convert iocontext queue structure to bfq_io_cq.
15 * @icq: the iocontext queue.
16 */
17static inline struct bfq_io_cq *icq_to_bic(struct io_cq *icq)
18{
19 /* bic->icq is the first member, %NULL will convert to %NULL */
20 return container_of(icq, struct bfq_io_cq, icq);
21}
22
23/**
24 * bfq_bic_lookup - search into @ioc a bic associated to @bfqd.
25 * @bfqd: the lookup key.
26 * @ioc: the io_context of the process doing I/O.
27 *
28 * Queue lock must be held.
29 */
30static inline struct bfq_io_cq *bfq_bic_lookup(struct bfq_data *bfqd,
31 struct io_context *ioc)
32{
33 if (ioc)
34 return icq_to_bic(ioc_lookup_icq(ioc, bfqd->queue));
35 return NULL;
36}