aboutsummaryrefslogtreecommitdiffstats
path: root/block/elevator.c
diff options
context:
space:
mode:
authorJens Axboe <jens.axboe@oracle.com>2008-10-31 05:05:07 -0400
committerJens Axboe <jens.axboe@oracle.com>2008-12-29 02:29:50 -0500
commitb374d18a4bfce705e4a99ae9f501b53e86ecb283 (patch)
tree7e773464725a78e96a2017fa36cf9d4a4e29f73b /block/elevator.c
parentabf137dd7712132ee56d5b3143c2ff61a72a5faa (diff)
block: get rid of elevator_t typedef
Just use struct elevator_queue everywhere instead. Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'block/elevator.c')
-rw-r--r--block/elevator.c55
1 files changed, 29 insertions, 26 deletions
diff --git a/block/elevator.c b/block/elevator.c
index ff60177a3bab..98259eda0ef6 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -65,7 +65,7 @@ DEFINE_TRACE(block_rq_issue);
65static int elv_iosched_allow_merge(struct request *rq, struct bio *bio) 65static int elv_iosched_allow_merge(struct request *rq, struct bio *bio)
66{ 66{
67 struct request_queue *q = rq->q; 67 struct request_queue *q = rq->q;
68 elevator_t *e = q->elevator; 68 struct elevator_queue *e = q->elevator;
69 69
70 if (e->ops->elevator_allow_merge_fn) 70 if (e->ops->elevator_allow_merge_fn)
71 return e->ops->elevator_allow_merge_fn(q, rq, bio); 71 return e->ops->elevator_allow_merge_fn(q, rq, bio);
@@ -208,13 +208,13 @@ __setup("elevator=", elevator_setup);
208 208
209static struct kobj_type elv_ktype; 209static struct kobj_type elv_ktype;
210 210
211static elevator_t *elevator_alloc(struct request_queue *q, 211static struct elevator_queue *elevator_alloc(struct request_queue *q,
212 struct elevator_type *e) 212 struct elevator_type *e)
213{ 213{
214 elevator_t *eq; 214 struct elevator_queue *eq;
215 int i; 215 int i;
216 216
217 eq = kmalloc_node(sizeof(elevator_t), GFP_KERNEL | __GFP_ZERO, q->node); 217 eq = kmalloc_node(sizeof(*eq), GFP_KERNEL | __GFP_ZERO, q->node);
218 if (unlikely(!eq)) 218 if (unlikely(!eq))
219 goto err; 219 goto err;
220 220
@@ -240,8 +240,9 @@ err:
240 240
241static void elevator_release(struct kobject *kobj) 241static void elevator_release(struct kobject *kobj)
242{ 242{
243 elevator_t *e = container_of(kobj, elevator_t, kobj); 243 struct elevator_queue *e;
244 244
245 e = container_of(kobj, struct elevator_queue, kobj);
245 elevator_put(e->elevator_type); 246 elevator_put(e->elevator_type);
246 kfree(e->hash); 247 kfree(e->hash);
247 kfree(e); 248 kfree(e);
@@ -297,7 +298,7 @@ int elevator_init(struct request_queue *q, char *name)
297} 298}
298EXPORT_SYMBOL(elevator_init); 299EXPORT_SYMBOL(elevator_init);
299 300
300void elevator_exit(elevator_t *e) 301void elevator_exit(struct elevator_queue *e)
301{ 302{
302 mutex_lock(&e->sysfs_lock); 303 mutex_lock(&e->sysfs_lock);
303 if (e->ops->elevator_exit_fn) 304 if (e->ops->elevator_exit_fn)
@@ -311,7 +312,7 @@ EXPORT_SYMBOL(elevator_exit);
311 312
312static void elv_activate_rq(struct request_queue *q, struct request *rq) 313static void elv_activate_rq(struct request_queue *q, struct request *rq)
313{ 314{
314 elevator_t *e = q->elevator; 315 struct elevator_queue *e = q->elevator;
315 316
316 if (e->ops->elevator_activate_req_fn) 317 if (e->ops->elevator_activate_req_fn)
317 e->ops->elevator_activate_req_fn(q, rq); 318 e->ops->elevator_activate_req_fn(q, rq);
@@ -319,7 +320,7 @@ static void elv_activate_rq(struct request_queue *q, struct request *rq)
319 320
320static void elv_deactivate_rq(struct request_queue *q, struct request *rq) 321static void elv_deactivate_rq(struct request_queue *q, struct request *rq)
321{ 322{
322 elevator_t *e = q->elevator; 323 struct elevator_queue *e = q->elevator;
323 324
324 if (e->ops->elevator_deactivate_req_fn) 325 if (e->ops->elevator_deactivate_req_fn)
325 e->ops->elevator_deactivate_req_fn(q, rq); 326 e->ops->elevator_deactivate_req_fn(q, rq);
@@ -338,7 +339,7 @@ static void elv_rqhash_del(struct request_queue *q, struct request *rq)
338 339
339static void elv_rqhash_add(struct request_queue *q, struct request *rq) 340static void elv_rqhash_add(struct request_queue *q, struct request *rq)
340{ 341{
341 elevator_t *e = q->elevator; 342 struct elevator_queue *e = q->elevator;
342 343
343 BUG_ON(ELV_ON_HASH(rq)); 344 BUG_ON(ELV_ON_HASH(rq));
344 hlist_add_head(&rq->hash, &e->hash[ELV_HASH_FN(rq_hash_key(rq))]); 345 hlist_add_head(&rq->hash, &e->hash[ELV_HASH_FN(rq_hash_key(rq))]);
@@ -352,7 +353,7 @@ static void elv_rqhash_reposition(struct request_queue *q, struct request *rq)
352 353
353static struct request *elv_rqhash_find(struct request_queue *q, sector_t offset) 354static struct request *elv_rqhash_find(struct request_queue *q, sector_t offset)
354{ 355{
355 elevator_t *e = q->elevator; 356 struct elevator_queue *e = q->elevator;
356 struct hlist_head *hash_list = &e->hash[ELV_HASH_FN(offset)]; 357 struct hlist_head *hash_list = &e->hash[ELV_HASH_FN(offset)];
357 struct hlist_node *entry, *next; 358 struct hlist_node *entry, *next;
358 struct request *rq; 359 struct request *rq;
@@ -494,7 +495,7 @@ EXPORT_SYMBOL(elv_dispatch_add_tail);
494 495
495int elv_merge(struct request_queue *q, struct request **req, struct bio *bio) 496int elv_merge(struct request_queue *q, struct request **req, struct bio *bio)
496{ 497{
497 elevator_t *e = q->elevator; 498 struct elevator_queue *e = q->elevator;
498 struct request *__rq; 499 struct request *__rq;
499 int ret; 500 int ret;
500 501
@@ -529,7 +530,7 @@ int elv_merge(struct request_queue *q, struct request **req, struct bio *bio)
529 530
530void elv_merged_request(struct request_queue *q, struct request *rq, int type) 531void elv_merged_request(struct request_queue *q, struct request *rq, int type)
531{ 532{
532 elevator_t *e = q->elevator; 533 struct elevator_queue *e = q->elevator;
533 534
534 if (e->ops->elevator_merged_fn) 535 if (e->ops->elevator_merged_fn)
535 e->ops->elevator_merged_fn(q, rq, type); 536 e->ops->elevator_merged_fn(q, rq, type);
@@ -543,7 +544,7 @@ void elv_merged_request(struct request_queue *q, struct request *rq, int type)
543void elv_merge_requests(struct request_queue *q, struct request *rq, 544void elv_merge_requests(struct request_queue *q, struct request *rq,
544 struct request *next) 545 struct request *next)
545{ 546{
546 elevator_t *e = q->elevator; 547 struct elevator_queue *e = q->elevator;
547 548
548 if (e->ops->elevator_merge_req_fn) 549 if (e->ops->elevator_merge_req_fn)
549 e->ops->elevator_merge_req_fn(q, rq, next); 550 e->ops->elevator_merge_req_fn(q, rq, next);
@@ -846,7 +847,7 @@ void elv_dequeue_request(struct request_queue *q, struct request *rq)
846 847
847int elv_queue_empty(struct request_queue *q) 848int elv_queue_empty(struct request_queue *q)
848{ 849{
849 elevator_t *e = q->elevator; 850 struct elevator_queue *e = q->elevator;
850 851
851 if (!list_empty(&q->queue_head)) 852 if (!list_empty(&q->queue_head))
852 return 0; 853 return 0;
@@ -860,7 +861,7 @@ EXPORT_SYMBOL(elv_queue_empty);
860 861
861struct request *elv_latter_request(struct request_queue *q, struct request *rq) 862struct request *elv_latter_request(struct request_queue *q, struct request *rq)
862{ 863{
863 elevator_t *e = q->elevator; 864 struct elevator_queue *e = q->elevator;
864 865
865 if (e->ops->elevator_latter_req_fn) 866 if (e->ops->elevator_latter_req_fn)
866 return e->ops->elevator_latter_req_fn(q, rq); 867 return e->ops->elevator_latter_req_fn(q, rq);
@@ -869,7 +870,7 @@ struct request *elv_latter_request(struct request_queue *q, struct request *rq)
869 870
870struct request *elv_former_request(struct request_queue *q, struct request *rq) 871struct request *elv_former_request(struct request_queue *q, struct request *rq)
871{ 872{
872 elevator_t *e = q->elevator; 873 struct elevator_queue *e = q->elevator;
873 874
874 if (e->ops->elevator_former_req_fn) 875 if (e->ops->elevator_former_req_fn)
875 return e->ops->elevator_former_req_fn(q, rq); 876 return e->ops->elevator_former_req_fn(q, rq);
@@ -878,7 +879,7 @@ struct request *elv_former_request(struct request_queue *q, struct request *rq)
878 879
879int elv_set_request(struct request_queue *q, struct request *rq, gfp_t gfp_mask) 880int elv_set_request(struct request_queue *q, struct request *rq, gfp_t gfp_mask)
880{ 881{
881 elevator_t *e = q->elevator; 882 struct elevator_queue *e = q->elevator;
882 883
883 if (e->ops->elevator_set_req_fn) 884 if (e->ops->elevator_set_req_fn)
884 return e->ops->elevator_set_req_fn(q, rq, gfp_mask); 885 return e->ops->elevator_set_req_fn(q, rq, gfp_mask);
@@ -889,7 +890,7 @@ int elv_set_request(struct request_queue *q, struct request *rq, gfp_t gfp_mask)
889 890
890void elv_put_request(struct request_queue *q, struct request *rq) 891void elv_put_request(struct request_queue *q, struct request *rq)
891{ 892{
892 elevator_t *e = q->elevator; 893 struct elevator_queue *e = q->elevator;
893 894
894 if (e->ops->elevator_put_req_fn) 895 if (e->ops->elevator_put_req_fn)
895 e->ops->elevator_put_req_fn(rq); 896 e->ops->elevator_put_req_fn(rq);
@@ -897,7 +898,7 @@ void elv_put_request(struct request_queue *q, struct request *rq)
897 898
898int elv_may_queue(struct request_queue *q, int rw) 899int elv_may_queue(struct request_queue *q, int rw)
899{ 900{
900 elevator_t *e = q->elevator; 901 struct elevator_queue *e = q->elevator;
901 902
902 if (e->ops->elevator_may_queue_fn) 903 if (e->ops->elevator_may_queue_fn)
903 return e->ops->elevator_may_queue_fn(q, rw); 904 return e->ops->elevator_may_queue_fn(q, rw);
@@ -920,7 +921,7 @@ EXPORT_SYMBOL(elv_abort_queue);
920 921
921void elv_completed_request(struct request_queue *q, struct request *rq) 922void elv_completed_request(struct request_queue *q, struct request *rq)
922{ 923{
923 elevator_t *e = q->elevator; 924 struct elevator_queue *e = q->elevator;
924 925
925 /* 926 /*
926 * request is released from the driver, io must be done 927 * request is released from the driver, io must be done
@@ -955,13 +956,14 @@ void elv_completed_request(struct request_queue *q, struct request *rq)
955static ssize_t 956static ssize_t
956elv_attr_show(struct kobject *kobj, struct attribute *attr, char *page) 957elv_attr_show(struct kobject *kobj, struct attribute *attr, char *page)
957{ 958{
958 elevator_t *e = container_of(kobj, elevator_t, kobj);
959 struct elv_fs_entry *entry = to_elv(attr); 959 struct elv_fs_entry *entry = to_elv(attr);
960 struct elevator_queue *e;
960 ssize_t error; 961 ssize_t error;
961 962
962 if (!entry->show) 963 if (!entry->show)
963 return -EIO; 964 return -EIO;
964 965
966 e = container_of(kobj, struct elevator_queue, kobj);
965 mutex_lock(&e->sysfs_lock); 967 mutex_lock(&e->sysfs_lock);
966 error = e->ops ? entry->show(e, page) : -ENOENT; 968 error = e->ops ? entry->show(e, page) : -ENOENT;
967 mutex_unlock(&e->sysfs_lock); 969 mutex_unlock(&e->sysfs_lock);
@@ -972,13 +974,14 @@ static ssize_t
972elv_attr_store(struct kobject *kobj, struct attribute *attr, 974elv_attr_store(struct kobject *kobj, struct attribute *attr,
973 const char *page, size_t length) 975 const char *page, size_t length)
974{ 976{
975 elevator_t *e = container_of(kobj, elevator_t, kobj);
976 struct elv_fs_entry *entry = to_elv(attr); 977 struct elv_fs_entry *entry = to_elv(attr);
978 struct elevator_queue *e;
977 ssize_t error; 979 ssize_t error;
978 980
979 if (!entry->store) 981 if (!entry->store)
980 return -EIO; 982 return -EIO;
981 983
984 e = container_of(kobj, struct elevator_queue, kobj);
982 mutex_lock(&e->sysfs_lock); 985 mutex_lock(&e->sysfs_lock);
983 error = e->ops ? entry->store(e, page, length) : -ENOENT; 986 error = e->ops ? entry->store(e, page, length) : -ENOENT;
984 mutex_unlock(&e->sysfs_lock); 987 mutex_unlock(&e->sysfs_lock);
@@ -997,7 +1000,7 @@ static struct kobj_type elv_ktype = {
997 1000
998int elv_register_queue(struct request_queue *q) 1001int elv_register_queue(struct request_queue *q)
999{ 1002{
1000 elevator_t *e = q->elevator; 1003 struct elevator_queue *e = q->elevator;
1001 int error; 1004 int error;
1002 1005
1003 error = kobject_add(&e->kobj, &q->kobj, "%s", "iosched"); 1006 error = kobject_add(&e->kobj, &q->kobj, "%s", "iosched");
@@ -1015,7 +1018,7 @@ int elv_register_queue(struct request_queue *q)
1015 return error; 1018 return error;
1016} 1019}
1017 1020
1018static void __elv_unregister_queue(elevator_t *e) 1021static void __elv_unregister_queue(struct elevator_queue *e)
1019{ 1022{
1020 kobject_uevent(&e->kobj, KOBJ_REMOVE); 1023 kobject_uevent(&e->kobj, KOBJ_REMOVE);
1021 kobject_del(&e->kobj); 1024 kobject_del(&e->kobj);
@@ -1078,7 +1081,7 @@ EXPORT_SYMBOL_GPL(elv_unregister);
1078 */ 1081 */
1079static int elevator_switch(struct request_queue *q, struct elevator_type *new_e) 1082static int elevator_switch(struct request_queue *q, struct elevator_type *new_e)
1080{ 1083{
1081 elevator_t *old_elevator, *e; 1084 struct elevator_queue *old_elevator, *e;
1082 void *data; 1085 void *data;
1083 1086
1084 /* 1087 /*
@@ -1184,7 +1187,7 @@ ssize_t elv_iosched_store(struct request_queue *q, const char *name,
1184 1187
1185ssize_t elv_iosched_show(struct request_queue *q, char *name) 1188ssize_t elv_iosched_show(struct request_queue *q, char *name)
1186{ 1189{
1187 elevator_t *e = q->elevator; 1190 struct elevator_queue *e = q->elevator;
1188 struct elevator_type *elv = e->elevator_type; 1191 struct elevator_type *elv = e->elevator_type;
1189 struct elevator_type *__e; 1192 struct elevator_type *__e;
1190 int len = 0; 1193 int len = 0;