CFQ: move think time check variables to a separate struct
[linux-2.6-block.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>
4ac845a2 6
fd0928df 7struct cfq_queue;
383cd721
SL
8struct 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
fd0928df 16struct cfq_io_context {
fd0928df
JA
17 void *key;
18
19 struct cfq_queue *cfqq[2];
20
21 struct io_context *ioc;
22
383cd721 23 struct cfq_ttime ttime;
fd0928df 24
fd0928df 25 struct list_head queue_list;
ffc4e759 26 struct hlist_node cic_list;
fd0928df
JA
27
28 void (*dtor)(struct io_context *); /* destructor */
29 void (*exit)(struct io_context *); /* called on task exit */
34e6bbf2
FC
30
31 struct rcu_head rcu_head;
fd0928df
JA
32};
33
34/*
d38ecf93
JA
35 * I/O subsystem state of the associated processes. It is refcounted
36 * and kmalloc'ed. These could be shared between processes.
fd0928df
JA
37 */
38struct io_context {
d9c7d394 39 atomic_long_t refcount;
d38ecf93
JA
40 atomic_t nr_tasks;
41
42 /* all the fields below are protected by this lock */
43 spinlock_t lock;
fd0928df
JA
44
45 unsigned short ioprio;
46 unsigned short ioprio_changed;
47
67523c48 48#if defined(CONFIG_BLK_CGROUP) || defined(CONFIG_BLK_CGROUP_MODULE)
31e4c28d
VG
49 unsigned short cgroup_changed;
50#endif
51
fd0928df
JA
52 /*
53 * For request batching
54 */
fd0928df 55 int nr_batch_requests; /* Number of requests left in the batch */
58c24a61 56 unsigned long last_waited; /* Time last woken after wait for request */
fd0928df 57
4ac845a2 58 struct radix_tree_root radix_root;
ffc4e759 59 struct hlist_head cic_list;
4d2deb40 60 void __rcu *ioc_data;
fd0928df
JA
61};
62
d38ecf93
JA
63static inline struct io_context *ioc_task_link(struct io_context *ioc)
64{
65 /*
66 * if ref count is zero, don't allow sharing (ioc is going away, it's
67 * a race).
68 */
d9c7d394 69 if (ioc && atomic_long_inc_not_zero(&ioc->refcount)) {
cbb4f264 70 atomic_inc(&ioc->nr_tasks);
d38ecf93 71 return ioc;
d237e5c7 72 }
d38ecf93
JA
73
74 return NULL;
75}
76
b69f2292 77struct task_struct;
da9cbc87
JA
78#ifdef CONFIG_BLOCK
79int put_io_context(struct io_context *ioc);
b69f2292 80void exit_io_context(struct task_struct *task);
da9cbc87
JA
81struct io_context *get_io_context(gfp_t gfp_flags, int node);
82struct io_context *alloc_io_context(gfp_t gfp_flags, int node);
da9cbc87 83#else
b69f2292 84static inline void exit_io_context(struct task_struct *task)
da9cbc87
JA
85{
86}
87
88struct io_context;
89static inline int put_io_context(struct io_context *ioc)
90{
91 return 1;
92}
93#endif
94
fd0928df 95#endif