aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/elevator.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/elevator.h')
-rw-r--r--include/linux/elevator.h41
1 files changed, 19 insertions, 22 deletions
diff --git a/include/linux/elevator.h b/include/linux/elevator.h
index 1d0f7a2ff73b..c24f3d7fbf1e 100644
--- a/include/linux/elevator.h
+++ b/include/linux/elevator.h
@@ -5,6 +5,8 @@
5 5
6#ifdef CONFIG_BLOCK 6#ifdef CONFIG_BLOCK
7 7
8struct io_cq;
9
8typedef int (elevator_merge_fn) (struct request_queue *, struct request **, 10typedef int (elevator_merge_fn) (struct request_queue *, struct request **,
9 struct bio *); 11 struct bio *);
10 12
@@ -24,6 +26,8 @@ typedef struct request *(elevator_request_list_fn) (struct request_queue *, stru
24typedef void (elevator_completed_req_fn) (struct request_queue *, struct request *); 26typedef void (elevator_completed_req_fn) (struct request_queue *, struct request *);
25typedef int (elevator_may_queue_fn) (struct request_queue *, int); 27typedef int (elevator_may_queue_fn) (struct request_queue *, int);
26 28
29typedef void (elevator_init_icq_fn) (struct io_cq *);
30typedef void (elevator_exit_icq_fn) (struct io_cq *);
27typedef int (elevator_set_req_fn) (struct request_queue *, struct request *, gfp_t); 31typedef int (elevator_set_req_fn) (struct request_queue *, struct request *, gfp_t);
28typedef void (elevator_put_req_fn) (struct request *); 32typedef void (elevator_put_req_fn) (struct request *);
29typedef void (elevator_activate_req_fn) (struct request_queue *, struct request *); 33typedef void (elevator_activate_req_fn) (struct request_queue *, struct request *);
@@ -56,6 +60,9 @@ struct elevator_ops
56 elevator_request_list_fn *elevator_former_req_fn; 60 elevator_request_list_fn *elevator_former_req_fn;
57 elevator_request_list_fn *elevator_latter_req_fn; 61 elevator_request_list_fn *elevator_latter_req_fn;
58 62
63 elevator_init_icq_fn *elevator_init_icq_fn; /* see iocontext.h */
64 elevator_exit_icq_fn *elevator_exit_icq_fn; /* ditto */
65
59 elevator_set_req_fn *elevator_set_req_fn; 66 elevator_set_req_fn *elevator_set_req_fn;
60 elevator_put_req_fn *elevator_put_req_fn; 67 elevator_put_req_fn *elevator_put_req_fn;
61 68
@@ -63,7 +70,6 @@ struct elevator_ops
63 70
64 elevator_init_fn *elevator_init_fn; 71 elevator_init_fn *elevator_init_fn;
65 elevator_exit_fn *elevator_exit_fn; 72 elevator_exit_fn *elevator_exit_fn;
66 void (*trim)(struct io_context *);
67}; 73};
68 74
69#define ELV_NAME_MAX (16) 75#define ELV_NAME_MAX (16)
@@ -79,11 +85,20 @@ struct elv_fs_entry {
79 */ 85 */
80struct elevator_type 86struct elevator_type
81{ 87{
82 struct list_head list; 88 /* managed by elevator core */
89 struct kmem_cache *icq_cache;
90
91 /* fields provided by elevator implementation */
83 struct elevator_ops ops; 92 struct elevator_ops ops;
93 size_t icq_size; /* see iocontext.h */
94 size_t icq_align; /* ditto */
84 struct elv_fs_entry *elevator_attrs; 95 struct elv_fs_entry *elevator_attrs;
85 char elevator_name[ELV_NAME_MAX]; 96 char elevator_name[ELV_NAME_MAX];
86 struct module *elevator_owner; 97 struct module *elevator_owner;
98
99 /* managed by elevator core */
100 char icq_cache_name[ELV_NAME_MAX + 5]; /* elvname + "_io_cq" */
101 struct list_head list;
87}; 102};
88 103
89/* 104/*
@@ -91,10 +106,9 @@ struct elevator_type
91 */ 106 */
92struct elevator_queue 107struct elevator_queue
93{ 108{
94 struct elevator_ops *ops; 109 struct elevator_type *type;
95 void *elevator_data; 110 void *elevator_data;
96 struct kobject kobj; 111 struct kobject kobj;
97 struct elevator_type *elevator_type;
98 struct mutex sysfs_lock; 112 struct mutex sysfs_lock;
99 struct hlist_head *hash; 113 struct hlist_head *hash;
100 unsigned int registered:1; 114 unsigned int registered:1;
@@ -129,7 +143,7 @@ extern void elv_drain_elevator(struct request_queue *);
129/* 143/*
130 * io scheduler registration 144 * io scheduler registration
131 */ 145 */
132extern void elv_register(struct elevator_type *); 146extern int elv_register(struct elevator_type *);
133extern void elv_unregister(struct elevator_type *); 147extern void elv_unregister(struct elevator_type *);
134 148
135/* 149/*
@@ -197,22 +211,5 @@ enum {
197 INIT_LIST_HEAD(&(rq)->csd.list); \ 211 INIT_LIST_HEAD(&(rq)->csd.list); \
198 } while (0) 212 } while (0)
199 213
200/*
201 * io context count accounting
202 */
203#define elv_ioc_count_mod(name, __val) this_cpu_add(name, __val)
204#define elv_ioc_count_inc(name) this_cpu_inc(name)
205#define elv_ioc_count_dec(name) this_cpu_dec(name)
206
207#define elv_ioc_count_read(name) \
208({ \
209 unsigned long __val = 0; \
210 int __cpu; \
211 smp_wmb(); \
212 for_each_possible_cpu(__cpu) \
213 __val += per_cpu(name, __cpu); \
214 __val; \
215})
216
217#endif /* CONFIG_BLOCK */ 214#endif /* CONFIG_BLOCK */
218#endif 215#endif