diff options
Diffstat (limited to 'include/linux/elevator.h')
-rw-r--r-- | include/linux/elevator.h | 68 |
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 | |||
4 | typedef int (elevator_merge_fn) (request_queue_t *, struct request **, | 8 | typedef int (elevator_merge_fn) (request_queue_t *, struct request **, |
5 | struct bio *); | 9 | struct bio *); |
6 | 10 | ||
7 | typedef void (elevator_merge_req_fn) (request_queue_t *, struct request *, struct request *); | 11 | typedef void (elevator_merge_req_fn) (request_queue_t *, struct request *, struct request *); |
8 | 12 | ||
9 | typedef void (elevator_merged_fn) (request_queue_t *, struct request *); | 13 | typedef void (elevator_merged_fn) (request_queue_t *, struct request *, int); |
10 | 14 | ||
11 | typedef int (elevator_dispatch_fn) (request_queue_t *, int); | 15 | typedef 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 *); | |||
14 | typedef int (elevator_queue_empty_fn) (request_queue_t *); | 18 | typedef int (elevator_queue_empty_fn) (request_queue_t *); |
15 | typedef struct request *(elevator_request_list_fn) (request_queue_t *, struct request *); | 19 | typedef struct request *(elevator_request_list_fn) (request_queue_t *, struct request *); |
16 | typedef void (elevator_completed_req_fn) (request_queue_t *, struct request *); | 20 | typedef void (elevator_completed_req_fn) (request_queue_t *, struct request *); |
17 | typedef int (elevator_may_queue_fn) (request_queue_t *, int, struct bio *); | 21 | typedef int (elevator_may_queue_fn) (request_queue_t *, int); |
18 | 22 | ||
19 | typedef int (elevator_set_req_fn) (request_queue_t *, struct request *, struct bio *, gfp_t); | 23 | typedef int (elevator_set_req_fn) (request_queue_t *, struct request *, gfp_t); |
20 | typedef void (elevator_put_req_fn) (request_queue_t *, struct request *); | 24 | typedef void (elevator_put_req_fn) (request_queue_t *, struct request *); |
21 | typedef void (elevator_activate_req_fn) (request_queue_t *, struct request *); | 25 | typedef void (elevator_activate_req_fn) (request_queue_t *, struct request *); |
22 | typedef void (elevator_deactivate_req_fn) (request_queue_t *, struct request *); | 26 | typedef 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 | */ |
90 | extern void elv_dispatch_sort(request_queue_t *, struct request *); | 95 | extern void elv_dispatch_sort(request_queue_t *, struct request *); |
96 | extern void elv_dispatch_add_tail(request_queue_t *, struct request *); | ||
91 | extern void elv_add_request(request_queue_t *, struct request *, int, int); | 97 | extern void elv_add_request(request_queue_t *, struct request *, int, int); |
92 | extern void __elv_add_request(request_queue_t *, struct request *, int, int); | 98 | extern void __elv_add_request(request_queue_t *, struct request *, int, int); |
93 | extern void elv_insert(request_queue_t *, struct request *, int); | 99 | extern void elv_insert(request_queue_t *, struct request *, int); |
94 | extern int elv_merge(request_queue_t *, struct request **, struct bio *); | 100 | extern int elv_merge(request_queue_t *, struct request **, struct bio *); |
95 | extern void elv_merge_requests(request_queue_t *, struct request *, | 101 | extern void elv_merge_requests(request_queue_t *, struct request *, |
96 | struct request *); | 102 | struct request *); |
97 | extern void elv_merged_request(request_queue_t *, struct request *); | 103 | extern void elv_merged_request(request_queue_t *, struct request *, int); |
98 | extern void elv_dequeue_request(request_queue_t *, struct request *); | 104 | extern void elv_dequeue_request(request_queue_t *, struct request *); |
99 | extern void elv_requeue_request(request_queue_t *, struct request *); | 105 | extern void elv_requeue_request(request_queue_t *, struct request *); |
100 | extern int elv_queue_empty(request_queue_t *); | 106 | extern int elv_queue_empty(request_queue_t *); |
@@ -103,9 +109,9 @@ extern struct request *elv_former_request(request_queue_t *, struct request *); | |||
103 | extern struct request *elv_latter_request(request_queue_t *, struct request *); | 109 | extern struct request *elv_latter_request(request_queue_t *, struct request *); |
104 | extern int elv_register_queue(request_queue_t *q); | 110 | extern int elv_register_queue(request_queue_t *q); |
105 | extern void elv_unregister_queue(request_queue_t *q); | 111 | extern void elv_unregister_queue(request_queue_t *q); |
106 | extern int elv_may_queue(request_queue_t *, int, struct bio *); | 112 | extern int elv_may_queue(request_queue_t *, int); |
107 | extern void elv_completed_request(request_queue_t *, struct request *); | 113 | extern void elv_completed_request(request_queue_t *, struct request *); |
108 | extern int elv_set_request(request_queue_t *, struct request *, struct bio *, gfp_t); | 114 | extern int elv_set_request(request_queue_t *, struct request *, gfp_t); |
109 | extern void elv_put_request(request_queue_t *, struct request *); | 115 | extern void elv_put_request(request_queue_t *, struct request *); |
110 | 116 | ||
111 | /* | 117 | /* |
@@ -125,6 +131,19 @@ extern void elevator_exit(elevator_t *); | |||
125 | extern int elv_rq_merge_ok(struct request *, struct bio *); | 131 | extern int elv_rq_merge_ok(struct request *, struct bio *); |
126 | 132 | ||
127 | /* | 133 | /* |
134 | * Helper functions. | ||
135 | */ | ||
136 | extern struct request *elv_rb_former_request(request_queue_t *, struct request *); | ||
137 | extern struct request *elv_rb_latter_request(request_queue_t *, struct request *); | ||
138 | |||
139 | /* | ||
140 | * rb support functions. | ||
141 | */ | ||
142 | extern struct request *elv_rb_add(struct rb_root *, struct request *); | ||
143 | extern void elv_rb_del(struct rb_root *, struct request *); | ||
144 | extern 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 |