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.h68
1 files changed, 62 insertions, 6 deletions
diff --git a/include/linux/elevator.h b/include/linux/elevator.h
index 1713ace808bf..b3370ef5164d 100644
--- a/include/linux/elevator.h
+++ b/include/linux/elevator.h
@@ -1,12 +1,16 @@
1#ifndef _LINUX_ELEVATOR_H 1#ifndef _LINUX_ELEVATOR_H
2#define _LINUX_ELEVATOR_H 2#define _LINUX_ELEVATOR_H
3 3
4#include <linux/percpu.h>
5
6#ifdef CONFIG_BLOCK
7
4typedef int (elevator_merge_fn) (request_queue_t *, struct request **, 8typedef int (elevator_merge_fn) (request_queue_t *, struct request **,
5 struct bio *); 9 struct bio *);
6 10
7typedef void (elevator_merge_req_fn) (request_queue_t *, struct request *, struct request *); 11typedef void (elevator_merge_req_fn) (request_queue_t *, struct request *, struct request *);
8 12
9typedef void (elevator_merged_fn) (request_queue_t *, struct request *); 13typedef void (elevator_merged_fn) (request_queue_t *, struct request *, int);
10 14
11typedef int (elevator_dispatch_fn) (request_queue_t *, int); 15typedef int (elevator_dispatch_fn) (request_queue_t *, int);
12 16
@@ -14,9 +18,9 @@ typedef void (elevator_add_req_fn) (request_queue_t *, struct request *);
14typedef int (elevator_queue_empty_fn) (request_queue_t *); 18typedef int (elevator_queue_empty_fn) (request_queue_t *);
15typedef struct request *(elevator_request_list_fn) (request_queue_t *, struct request *); 19typedef struct request *(elevator_request_list_fn) (request_queue_t *, struct request *);
16typedef void (elevator_completed_req_fn) (request_queue_t *, struct request *); 20typedef void (elevator_completed_req_fn) (request_queue_t *, struct request *);
17typedef int (elevator_may_queue_fn) (request_queue_t *, int, struct bio *); 21typedef int (elevator_may_queue_fn) (request_queue_t *, int);
18 22
19typedef int (elevator_set_req_fn) (request_queue_t *, struct request *, struct bio *, gfp_t); 23typedef int (elevator_set_req_fn) (request_queue_t *, struct request *, gfp_t);
20typedef void (elevator_put_req_fn) (request_queue_t *, struct request *); 24typedef void (elevator_put_req_fn) (request_queue_t *, struct request *);
21typedef void (elevator_activate_req_fn) (request_queue_t *, struct request *); 25typedef void (elevator_activate_req_fn) (request_queue_t *, struct request *);
22typedef void (elevator_deactivate_req_fn) (request_queue_t *, struct request *); 26typedef void (elevator_deactivate_req_fn) (request_queue_t *, struct request *);
@@ -82,19 +86,21 @@ struct elevator_queue
82 struct kobject kobj; 86 struct kobject kobj;
83 struct elevator_type *elevator_type; 87 struct elevator_type *elevator_type;
84 struct mutex sysfs_lock; 88 struct mutex sysfs_lock;
89 struct hlist_head *hash;
85}; 90};
86 91
87/* 92/*
88 * block elevator interface 93 * block elevator interface
89 */ 94 */
90extern void elv_dispatch_sort(request_queue_t *, struct request *); 95extern void elv_dispatch_sort(request_queue_t *, struct request *);
96extern void elv_dispatch_add_tail(request_queue_t *, struct request *);
91extern void elv_add_request(request_queue_t *, struct request *, int, int); 97extern void elv_add_request(request_queue_t *, struct request *, int, int);
92extern void __elv_add_request(request_queue_t *, struct request *, int, int); 98extern void __elv_add_request(request_queue_t *, struct request *, int, int);
93extern void elv_insert(request_queue_t *, struct request *, int); 99extern void elv_insert(request_queue_t *, struct request *, int);
94extern int elv_merge(request_queue_t *, struct request **, struct bio *); 100extern int elv_merge(request_queue_t *, struct request **, struct bio *);
95extern void elv_merge_requests(request_queue_t *, struct request *, 101extern void elv_merge_requests(request_queue_t *, struct request *,
96 struct request *); 102 struct request *);
97extern void elv_merged_request(request_queue_t *, struct request *); 103extern void elv_merged_request(request_queue_t *, struct request *, int);
98extern void elv_dequeue_request(request_queue_t *, struct request *); 104extern void elv_dequeue_request(request_queue_t *, struct request *);
99extern void elv_requeue_request(request_queue_t *, struct request *); 105extern void elv_requeue_request(request_queue_t *, struct request *);
100extern int elv_queue_empty(request_queue_t *); 106extern int elv_queue_empty(request_queue_t *);
@@ -103,9 +109,9 @@ extern struct request *elv_former_request(request_queue_t *, struct request *);
103extern struct request *elv_latter_request(request_queue_t *, struct request *); 109extern struct request *elv_latter_request(request_queue_t *, struct request *);
104extern int elv_register_queue(request_queue_t *q); 110extern int elv_register_queue(request_queue_t *q);
105extern void elv_unregister_queue(request_queue_t *q); 111extern void elv_unregister_queue(request_queue_t *q);
106extern int elv_may_queue(request_queue_t *, int, struct bio *); 112extern int elv_may_queue(request_queue_t *, int);
107extern void elv_completed_request(request_queue_t *, struct request *); 113extern void elv_completed_request(request_queue_t *, struct request *);
108extern int elv_set_request(request_queue_t *, struct request *, struct bio *, gfp_t); 114extern int elv_set_request(request_queue_t *, struct request *, gfp_t);
109extern void elv_put_request(request_queue_t *, struct request *); 115extern void elv_put_request(request_queue_t *, struct request *);
110 116
111/* 117/*
@@ -125,6 +131,19 @@ extern void elevator_exit(elevator_t *);
125extern int elv_rq_merge_ok(struct request *, struct bio *); 131extern int elv_rq_merge_ok(struct request *, struct bio *);
126 132
127/* 133/*
134 * Helper functions.
135 */
136extern struct request *elv_rb_former_request(request_queue_t *, struct request *);
137extern struct request *elv_rb_latter_request(request_queue_t *, struct request *);
138
139/*
140 * rb support functions.
141 */
142extern struct request *elv_rb_add(struct rb_root *, struct request *);
143extern void elv_rb_del(struct rb_root *, struct request *);
144extern struct request *elv_rb_find(struct rb_root *, sector_t);
145
146/*
128 * Return values from elevator merger 147 * Return values from elevator merger
129 */ 148 */
130#define ELEVATOR_NO_MERGE 0 149#define ELEVATOR_NO_MERGE 0
@@ -149,5 +168,42 @@ enum {
149}; 168};
150 169
151#define rq_end_sector(rq) ((rq)->sector + (rq)->nr_sectors) 170#define rq_end_sector(rq) ((rq)->sector + (rq)->nr_sectors)
171#define rb_entry_rq(node) rb_entry((node), struct request, rb_node)
172
173/*
174 * Hack to reuse the donelist list_head as the fifo time holder while
175 * the request is in the io scheduler. Saves an unsigned long in rq.
176 */
177#define rq_fifo_time(rq) ((unsigned long) (rq)->donelist.next)
178#define rq_set_fifo_time(rq,exp) ((rq)->donelist.next = (void *) (exp))
179#define rq_entry_fifo(ptr) list_entry((ptr), struct request, queuelist)
180#define rq_fifo_clear(rq) do { \
181 list_del_init(&(rq)->queuelist); \
182 INIT_LIST_HEAD(&(rq)->donelist); \
183 } while (0)
152 184
185/*
186 * io context count accounting
187 */
188#define elv_ioc_count_mod(name, __val) \
189 do { \
190 preempt_disable(); \
191 __get_cpu_var(name) += (__val); \
192 preempt_enable(); \
193 } while (0)
194
195#define elv_ioc_count_inc(name) elv_ioc_count_mod(name, 1)
196#define elv_ioc_count_dec(name) elv_ioc_count_mod(name, -1)
197
198#define elv_ioc_count_read(name) \
199({ \
200 unsigned long __val = 0; \
201 int __cpu; \
202 smp_wmb(); \
203 for_each_possible_cpu(__cpu) \
204 __val += per_cpu(name, __cpu); \
205 __val; \
206})
207
208#endif /* CONFIG_BLOCK */
153#endif 209#endif