blkio: Introduce the root service tree for cfq groups
[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>
4ac845a2 6
fd0928df
JA
7/*
8 * This is the per-process anticipatory I/O scheduler state.
9 */
10struct as_io_context {
11 spinlock_t lock;
12
13 void (*dtor)(struct as_io_context *aic); /* destructor */
14 void (*exit)(struct as_io_context *aic); /* called on task exit */
15
16 unsigned long state;
17 atomic_t nr_queued; /* queued reads & sync writes */
18 atomic_t nr_dispatched; /* number of requests gone to the drivers */
19
20 /* IO History tracking */
21 /* Thinktime */
22 unsigned long last_end_request;
23 unsigned long ttime_total;
24 unsigned long ttime_samples;
25 unsigned long ttime_mean;
26 /* Layout pattern */
27 unsigned int seek_samples;
28 sector_t last_request_pos;
29 u64 seek_total;
30 sector_t seek_mean;
31};
32
33struct cfq_queue;
34struct cfq_io_context {
fd0928df 35 void *key;
4ac845a2 36 unsigned long dead_key;
fd0928df
JA
37
38 struct cfq_queue *cfqq[2];
39
40 struct io_context *ioc;
41
42 unsigned long last_end_request;
fd0928df
JA
43
44 unsigned long ttime_total;
45 unsigned long ttime_samples;
46 unsigned long ttime_mean;
47
fd0928df 48 struct list_head queue_list;
ffc4e759 49 struct hlist_node cic_list;
fd0928df
JA
50
51 void (*dtor)(struct io_context *); /* destructor */
52 void (*exit)(struct io_context *); /* called on task exit */
34e6bbf2
FC
53
54 struct rcu_head rcu_head;
fd0928df
JA
55};
56
57/*
d38ecf93
JA
58 * I/O subsystem state of the associated processes. It is refcounted
59 * and kmalloc'ed. These could be shared between processes.
fd0928df
JA
60 */
61struct io_context {
d9c7d394 62 atomic_long_t refcount;
d38ecf93
JA
63 atomic_t nr_tasks;
64
65 /* all the fields below are protected by this lock */
66 spinlock_t lock;
fd0928df
JA
67
68 unsigned short ioprio;
69 unsigned short ioprio_changed;
70
71 /*
72 * For request batching
73 */
74 unsigned long last_waited; /* Time last woken after wait for request */
75 int nr_batch_requests; /* Number of requests left in the batch */
76
77 struct as_io_context *aic;
4ac845a2 78 struct radix_tree_root radix_root;
ffc4e759 79 struct hlist_head cic_list;
fd0928df
JA
80 void *ioc_data;
81};
82
d38ecf93
JA
83static inline struct io_context *ioc_task_link(struct io_context *ioc)
84{
85 /*
86 * if ref count is zero, don't allow sharing (ioc is going away, it's
87 * a race).
88 */
d9c7d394 89 if (ioc && atomic_long_inc_not_zero(&ioc->refcount)) {
cbb4f264 90 atomic_inc(&ioc->nr_tasks);
d38ecf93 91 return ioc;
d237e5c7 92 }
d38ecf93
JA
93
94 return NULL;
95}
96
da9cbc87
JA
97#ifdef CONFIG_BLOCK
98int put_io_context(struct io_context *ioc);
99void exit_io_context(void);
100struct io_context *get_io_context(gfp_t gfp_flags, int node);
101struct io_context *alloc_io_context(gfp_t gfp_flags, int node);
102void copy_io_context(struct io_context **pdst, struct io_context **psrc);
103#else
104static inline void exit_io_context(void)
105{
106}
107
108struct io_context;
109static inline int put_io_context(struct io_context *ioc)
110{
111 return 1;
112}
113#endif
114
fd0928df 115#endif
This page took 0.269125 seconds and 5 git commands to generate.