CFQ: move think time check variables to a separate struct
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / include / linux / iocontext.h
blob5037a0ad231245b3b2779c81bf76f912df467879
1 #ifndef IOCONTEXT_H
2 #define IOCONTEXT_H
4 #include <linux/radix-tree.h>
5 #include <linux/rcupdate.h>
7 struct cfq_queue;
8 struct cfq_ttime {
9 unsigned long last_end_request;
11 unsigned long ttime_total;
12 unsigned long ttime_samples;
13 unsigned long ttime_mean;
16 struct cfq_io_context {
17 void *key;
19 struct cfq_queue *cfqq[2];
21 struct io_context *ioc;
23 struct cfq_ttime ttime;
25 struct list_head queue_list;
26 struct hlist_node cic_list;
28 void (*dtor)(struct io_context *); /* destructor */
29 void (*exit)(struct io_context *); /* called on task exit */
31 struct rcu_head rcu_head;
35 * I/O subsystem state of the associated processes. It is refcounted
36 * and kmalloc'ed. These could be shared between processes.
38 struct io_context {
39 atomic_long_t refcount;
40 atomic_t nr_tasks;
42 /* all the fields below are protected by this lock */
43 spinlock_t lock;
45 unsigned short ioprio;
46 unsigned short ioprio_changed;
48 #if defined(CONFIG_BLK_CGROUP) || defined(CONFIG_BLK_CGROUP_MODULE)
49 unsigned short cgroup_changed;
50 #endif
53 * For request batching
55 int nr_batch_requests; /* Number of requests left in the batch */
56 unsigned long last_waited; /* Time last woken after wait for request */
58 struct radix_tree_root radix_root;
59 struct hlist_head cic_list;
60 void __rcu *ioc_data;
63 static inline struct io_context *ioc_task_link(struct io_context *ioc)
66 * if ref count is zero, don't allow sharing (ioc is going away, it's
67 * a race).
69 if (ioc && atomic_long_inc_not_zero(&ioc->refcount)) {
70 atomic_inc(&ioc->nr_tasks);
71 return ioc;
74 return NULL;
77 struct task_struct;
78 #ifdef CONFIG_BLOCK
79 int put_io_context(struct io_context *ioc);
80 void exit_io_context(struct task_struct *task);
81 struct io_context *get_io_context(gfp_t gfp_flags, int node);
82 struct io_context *alloc_io_context(gfp_t gfp_flags, int node);
83 #else
84 static inline void exit_io_context(struct task_struct *task)
88 struct io_context;
89 static inline int put_io_context(struct io_context *ioc)
91 return 1;
93 #endif
95 #endif