iocontext.h 2.1 KB

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