bfq-ioc.c 963 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  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. * icq_to_bic - convert iocontext queue structure to bfq_io_cq.
  14. * @icq: the iocontext queue.
  15. */
  16. static inline struct bfq_io_cq *icq_to_bic(struct io_cq *icq)
  17. {
  18. /* bic->icq is the first member, %NULL will convert to %NULL */
  19. return container_of(icq, struct bfq_io_cq, icq);
  20. }
  21. /**
  22. * bfq_bic_lookup - search into @ioc a bic associated to @bfqd.
  23. * @bfqd: the lookup key.
  24. * @ioc: the io_context of the process doing I/O.
  25. *
  26. * Queue lock must be held.
  27. */
  28. static inline struct bfq_io_cq *bfq_bic_lookup(struct bfq_data *bfqd,
  29. struct io_context *ioc)
  30. {
  31. if (ioc)
  32. return icq_to_bic(ioc_lookup_icq(ioc, bfqd->queue));
  33. return NULL;
  34. }