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