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> |
4ac845a2 | 6 | |
fd0928df | 7 | struct cfq_queue; |
383cd721 SL |
8 | struct cfq_ttime { |
9 | unsigned long last_end_request; | |
10 | ||
11 | unsigned long ttime_total; | |
12 | unsigned long ttime_samples; | |
13 | unsigned long ttime_mean; | |
14 | }; | |
15 | ||
dc86900e TH |
16 | enum { |
17 | CIC_IOPRIO_CHANGED, | |
18 | CIC_CGROUP_CHANGED, | |
19 | }; | |
20 | ||
fd0928df | 21 | struct cfq_io_context { |
fd0928df | 22 | void *key; |
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 | ||
fd0928df JA |
36 | void (*dtor)(struct io_context *); /* destructor */ |
37 | void (*exit)(struct io_context *); /* called on task exit */ | |
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; |
fd0928df JA |
64 | }; |
65 | ||
d38ecf93 JA |
66 | static inline struct io_context *ioc_task_link(struct io_context *ioc) |
67 | { | |
68 | /* | |
69 | * if ref count is zero, don't allow sharing (ioc is going away, it's | |
70 | * a race). | |
71 | */ | |
d9c7d394 | 72 | if (ioc && atomic_long_inc_not_zero(&ioc->refcount)) { |
cbb4f264 | 73 | atomic_inc(&ioc->nr_tasks); |
d38ecf93 | 74 | return ioc; |
d237e5c7 | 75 | } |
d38ecf93 JA |
76 | |
77 | return NULL; | |
78 | } | |
79 | ||
b69f2292 | 80 | struct task_struct; |
da9cbc87 | 81 | #ifdef CONFIG_BLOCK |
42ec57a8 | 82 | void put_io_context(struct io_context *ioc); |
b69f2292 | 83 | void exit_io_context(struct task_struct *task); |
6e736be7 TH |
84 | struct io_context *get_task_io_context(struct task_struct *task, |
85 | gfp_t gfp_flags, int node); | |
dc86900e TH |
86 | void ioc_ioprio_changed(struct io_context *ioc, int ioprio); |
87 | void ioc_cgroup_changed(struct io_context *ioc); | |
da9cbc87 | 88 | #else |
da9cbc87 | 89 | struct io_context; |
42ec57a8 TH |
90 | static inline void put_io_context(struct io_context *ioc) { } |
91 | static inline void exit_io_context(struct task_struct *task) { } | |
da9cbc87 JA |
92 | #endif |
93 | ||
fd0928df | 94 | #endif |