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 | |
dc86900e | 8 | enum { |
c5869807 TH |
9 | ICQ_IOPRIO_CHANGED, |
10 | ICQ_CGROUP_CHANGED, | |
dc86900e TH |
11 | }; |
12 | ||
c5869807 TH |
13 | struct io_cq { |
14 | struct request_queue *q; | |
15 | struct io_context *ioc; | |
fd0928df | 16 | |
c5869807 TH |
17 | struct list_head q_node; |
18 | struct hlist_node ioc_node; | |
dc86900e | 19 | |
c5869807 TH |
20 | unsigned long changed; |
21 | struct rcu_head rcu_head; | |
34e6bbf2 | 22 | |
c5869807 TH |
23 | void (*exit)(struct io_cq *); |
24 | void (*release)(struct io_cq *); | |
fd0928df JA |
25 | }; |
26 | ||
27 | /* | |
d38ecf93 JA |
28 | * I/O subsystem state of the associated processes. It is refcounted |
29 | * and kmalloc'ed. These could be shared between processes. | |
fd0928df JA |
30 | */ |
31 | struct io_context { | |
d9c7d394 | 32 | atomic_long_t refcount; |
d38ecf93 JA |
33 | atomic_t nr_tasks; |
34 | ||
35 | /* all the fields below are protected by this lock */ | |
36 | spinlock_t lock; | |
fd0928df JA |
37 | |
38 | unsigned short ioprio; | |
31e4c28d | 39 | |
fd0928df JA |
40 | /* |
41 | * For request batching | |
42 | */ | |
fd0928df | 43 | int nr_batch_requests; /* Number of requests left in the batch */ |
58c24a61 | 44 | unsigned long last_waited; /* Time last woken after wait for request */ |
fd0928df | 45 | |
c5869807 TH |
46 | struct radix_tree_root icq_tree; |
47 | struct io_cq __rcu *icq_hint; | |
48 | struct hlist_head icq_list; | |
b2efa052 TH |
49 | |
50 | struct work_struct release_work; | |
fd0928df JA |
51 | }; |
52 | ||
d38ecf93 JA |
53 | static inline struct io_context *ioc_task_link(struct io_context *ioc) |
54 | { | |
55 | /* | |
56 | * if ref count is zero, don't allow sharing (ioc is going away, it's | |
57 | * a race). | |
58 | */ | |
d9c7d394 | 59 | if (ioc && atomic_long_inc_not_zero(&ioc->refcount)) { |
cbb4f264 | 60 | atomic_inc(&ioc->nr_tasks); |
d38ecf93 | 61 | return ioc; |
d237e5c7 | 62 | } |
d38ecf93 JA |
63 | |
64 | return NULL; | |
65 | } | |
66 | ||
b69f2292 | 67 | struct task_struct; |
da9cbc87 | 68 | #ifdef CONFIG_BLOCK |
b2efa052 | 69 | void put_io_context(struct io_context *ioc, struct request_queue *locked_q); |
b69f2292 | 70 | void exit_io_context(struct task_struct *task); |
6e736be7 TH |
71 | struct io_context *get_task_io_context(struct task_struct *task, |
72 | gfp_t gfp_flags, int node); | |
dc86900e TH |
73 | void ioc_ioprio_changed(struct io_context *ioc, int ioprio); |
74 | void ioc_cgroup_changed(struct io_context *ioc); | |
da9cbc87 | 75 | #else |
da9cbc87 | 76 | struct io_context; |
b2efa052 TH |
77 | static inline void put_io_context(struct io_context *ioc, |
78 | struct request_queue *locked_q) { } | |
42ec57a8 | 79 | static inline void exit_io_context(struct task_struct *task) { } |
da9cbc87 JA |
80 | #endif |
81 | ||
fd0928df | 82 | #endif |