iocontext.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #ifndef IOCONTEXT_H
  2. #define IOCONTEXT_H
  3. #include <linux/radix-tree.h>
  4. #include <linux/rcupdate.h>
  5. #include <linux/workqueue.h>
  6. struct cfq_queue;
  7. struct cfq_ttime {
  8. unsigned long last_end_request;
  9. unsigned long ttime_total;
  10. unsigned long ttime_samples;
  11. unsigned long ttime_mean;
  12. };
  13. enum {
  14. CIC_IOPRIO_CHANGED,
  15. CIC_CGROUP_CHANGED,
  16. };
  17. struct cfq_io_context {
  18. struct request_queue *q;
  19. struct cfq_queue *cfqq[2];
  20. struct io_context *ioc;
  21. struct cfq_ttime ttime;
  22. struct list_head queue_list;
  23. struct hlist_node cic_list;
  24. unsigned long changed;
  25. void (*exit)(struct cfq_io_context *);
  26. void (*release)(struct cfq_io_context *);
  27. struct rcu_head rcu_head;
  28. };
  29. /*
  30. * I/O subsystem state of the associated processes. It is refcounted
  31. * and kmalloc'ed. These could be shared between processes.
  32. */
  33. struct io_context {
  34. atomic_long_t refcount;
  35. atomic_t nr_tasks;
  36. /* all the fields below are protected by this lock */
  37. spinlock_t lock;
  38. unsigned short ioprio;
  39. /*
  40. * For request batching
  41. */
  42. int nr_batch_requests; /* Number of requests left in the batch */
  43. unsigned long last_waited; /* Time last woken after wait for request */
  44. struct radix_tree_root radix_root;
  45. struct hlist_head cic_list;
  46. void __rcu *ioc_data;
  47. struct work_struct release_work;
  48. };
  49. static inline struct io_context *ioc_task_link(struct io_context *ioc)
  50. {
  51. /*
  52. * if ref count is zero, don't allow sharing (ioc is going away, it's
  53. * a race).
  54. */
  55. if (ioc && atomic_long_inc_not_zero(&ioc->refcount)) {
  56. atomic_inc(&ioc->nr_tasks);
  57. return ioc;
  58. }
  59. return NULL;
  60. }
  61. struct task_struct;
  62. #ifdef CONFIG_BLOCK
  63. void put_io_context(struct io_context *ioc, struct request_queue *locked_q);
  64. void exit_io_context(struct task_struct *task);
  65. struct io_context *get_task_io_context(struct task_struct *task,
  66. gfp_t gfp_flags, int node);
  67. void ioc_ioprio_changed(struct io_context *ioc, int ioprio);
  68. void ioc_cgroup_changed(struct io_context *ioc);
  69. #else
  70. struct io_context;
  71. static inline void put_io_context(struct io_context *ioc,
  72. struct request_queue *locked_q) { }
  73. static inline void exit_io_context(struct task_struct *task) { }
  74. #endif
  75. #endif