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