block, cfq: move icq cache management to block core
[deliverable/linux.git] / include / linux / iocontext.h
CommitLineData
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 8enum {
c5869807
TH
9 ICQ_IOPRIO_CHANGED,
10 ICQ_CGROUP_CHANGED,
dc86900e
TH
11};
12
c5869807
TH
13struct 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 */
31struct 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
53static 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 67struct task_struct;
da9cbc87 68#ifdef CONFIG_BLOCK
b2efa052 69void put_io_context(struct io_context *ioc, struct request_queue *locked_q);
b69f2292 70void exit_io_context(struct task_struct *task);
6e736be7
TH
71struct io_context *get_task_io_context(struct task_struct *task,
72 gfp_t gfp_flags, int node);
dc86900e
TH
73void ioc_ioprio_changed(struct io_context *ioc, int ioprio);
74void ioc_cgroup_changed(struct io_context *ioc);
da9cbc87 75#else
da9cbc87 76struct io_context;
b2efa052
TH
77static inline void put_io_context(struct io_context *ioc,
78 struct request_queue *locked_q) { }
42ec57a8 79static inline void exit_io_context(struct task_struct *task) { }
da9cbc87
JA
80#endif
81
fd0928df 82#endif
This page took 0.42459 seconds and 5 git commands to generate.