block, cfq: move ioc ioprio/cgroup changed handling to cic
[deliverable/linux.git] / include / linux / iocontext.h
1 #ifndef IOCONTEXT_H
2 #define IOCONTEXT_H
3
4 #include <linux/radix-tree.h>
5 #include <linux/rcupdate.h>
6
7 struct cfq_queue;
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
16 enum {
17 CIC_IOPRIO_CHANGED,
18 CIC_CGROUP_CHANGED,
19 };
20
21 struct cfq_io_context {
22 void *key;
23 struct request_queue *q;
24
25 struct cfq_queue *cfqq[2];
26
27 struct io_context *ioc;
28
29 struct cfq_ttime ttime;
30
31 struct list_head queue_list;
32 struct hlist_node cic_list;
33
34 unsigned long changed;
35
36 void (*dtor)(struct io_context *); /* destructor */
37 void (*exit)(struct io_context *); /* called on task exit */
38
39 struct rcu_head rcu_head;
40 };
41
42 /*
43 * I/O subsystem state of the associated processes. It is refcounted
44 * and kmalloc'ed. These could be shared between processes.
45 */
46 struct io_context {
47 atomic_long_t refcount;
48 atomic_t nr_tasks;
49
50 /* all the fields below are protected by this lock */
51 spinlock_t lock;
52
53 unsigned short ioprio;
54
55 /*
56 * For request batching
57 */
58 int nr_batch_requests; /* Number of requests left in the batch */
59 unsigned long last_waited; /* Time last woken after wait for request */
60
61 struct radix_tree_root radix_root;
62 struct hlist_head cic_list;
63 void __rcu *ioc_data;
64 };
65
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 */
72 if (ioc && atomic_long_inc_not_zero(&ioc->refcount)) {
73 atomic_inc(&ioc->nr_tasks);
74 return ioc;
75 }
76
77 return NULL;
78 }
79
80 struct task_struct;
81 #ifdef CONFIG_BLOCK
82 void put_io_context(struct io_context *ioc);
83 void exit_io_context(struct task_struct *task);
84 struct io_context *get_task_io_context(struct task_struct *task,
85 gfp_t gfp_flags, int node);
86 void ioc_ioprio_changed(struct io_context *ioc, int ioprio);
87 void ioc_cgroup_changed(struct io_context *ioc);
88 #else
89 struct io_context;
90 static inline void put_io_context(struct io_context *ioc) { }
91 static inline void exit_io_context(struct task_struct *task) { }
92 #endif
93
94 #endif
This page took 0.033043 seconds and 6 git commands to generate.