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