diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2008-12-31 07:35:57 -0500 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2008-12-31 07:35:57 -0500 |
commit | 2ca1a615835d9f4990f42102ab1f2ef434e7e89c (patch) | |
tree | 726cf3d5f29a6c66c44e4bd68e7ebed2fd83d059 /block/elevator.c | |
parent | e12f0102ac81d660c9f801d0a0e10ccf4537a9de (diff) | |
parent | 6a94cb73064c952255336cc57731904174b2c58f (diff) |
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
Conflicts:
arch/x86/kernel/io_apic.c
Diffstat (limited to 'block/elevator.c')
-rw-r--r-- | block/elevator.c | 73 |
1 files changed, 36 insertions, 37 deletions
diff --git a/block/elevator.c b/block/elevator.c index 86836dd179c0..98259eda0ef6 100644 --- a/block/elevator.c +++ b/block/elevator.c | |||
@@ -65,7 +65,7 @@ DEFINE_TRACE(block_rq_issue); | |||
65 | static int elv_iosched_allow_merge(struct request *rq, struct bio *bio) | 65 | static 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 | ||
209 | static struct kobj_type elv_ktype; | 209 | static struct kobj_type elv_ktype; |
210 | 210 | ||
211 | static elevator_t *elevator_alloc(struct request_queue *q, | 211 | static 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 | ||
241 | static void elevator_release(struct kobject *kobj) | 241 | static 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 | } |
298 | EXPORT_SYMBOL(elevator_init); | 299 | EXPORT_SYMBOL(elevator_init); |
299 | 300 | ||
300 | void elevator_exit(elevator_t *e) | 301 | void 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 | ||
312 | static void elv_activate_rq(struct request_queue *q, struct request *rq) | 313 | static 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 | ||
320 | static void elv_deactivate_rq(struct request_queue *q, struct request *rq) | 321 | static 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 | ||
339 | static void elv_rqhash_add(struct request_queue *q, struct request *rq) | 340 | static 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 | ||
353 | static struct request *elv_rqhash_find(struct request_queue *q, sector_t offset) | 354 | static 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 | ||
495 | int elv_merge(struct request_queue *q, struct request **req, struct bio *bio) | 496 | int 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 | ||
530 | void elv_merged_request(struct request_queue *q, struct request *rq, int type) | 531 | void 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) | |||
543 | void elv_merge_requests(struct request_queue *q, struct request *rq, | 544 | void 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); |
@@ -755,14 +756,6 @@ struct request *elv_next_request(struct request_queue *q) | |||
755 | int ret; | 756 | int ret; |
756 | 757 | ||
757 | while ((rq = __elv_next_request(q)) != NULL) { | 758 | while ((rq = __elv_next_request(q)) != NULL) { |
758 | /* | ||
759 | * Kill the empty barrier place holder, the driver must | ||
760 | * not ever see it. | ||
761 | */ | ||
762 | if (blk_empty_barrier(rq)) { | ||
763 | __blk_end_request(rq, 0, blk_rq_bytes(rq)); | ||
764 | continue; | ||
765 | } | ||
766 | if (!(rq->cmd_flags & REQ_STARTED)) { | 759 | if (!(rq->cmd_flags & REQ_STARTED)) { |
767 | /* | 760 | /* |
768 | * This is the first time the device driver | 761 | * This is the first time the device driver |
@@ -854,7 +847,7 @@ void elv_dequeue_request(struct request_queue *q, struct request *rq) | |||
854 | 847 | ||
855 | int elv_queue_empty(struct request_queue *q) | 848 | int elv_queue_empty(struct request_queue *q) |
856 | { | 849 | { |
857 | elevator_t *e = q->elevator; | 850 | struct elevator_queue *e = q->elevator; |
858 | 851 | ||
859 | if (!list_empty(&q->queue_head)) | 852 | if (!list_empty(&q->queue_head)) |
860 | return 0; | 853 | return 0; |
@@ -868,7 +861,7 @@ EXPORT_SYMBOL(elv_queue_empty); | |||
868 | 861 | ||
869 | struct request *elv_latter_request(struct request_queue *q, struct request *rq) | 862 | struct request *elv_latter_request(struct request_queue *q, struct request *rq) |
870 | { | 863 | { |
871 | elevator_t *e = q->elevator; | 864 | struct elevator_queue *e = q->elevator; |
872 | 865 | ||
873 | if (e->ops->elevator_latter_req_fn) | 866 | if (e->ops->elevator_latter_req_fn) |
874 | return e->ops->elevator_latter_req_fn(q, rq); | 867 | return e->ops->elevator_latter_req_fn(q, rq); |
@@ -877,7 +870,7 @@ struct request *elv_latter_request(struct request_queue *q, struct request *rq) | |||
877 | 870 | ||
878 | struct request *elv_former_request(struct request_queue *q, struct request *rq) | 871 | struct request *elv_former_request(struct request_queue *q, struct request *rq) |
879 | { | 872 | { |
880 | elevator_t *e = q->elevator; | 873 | struct elevator_queue *e = q->elevator; |
881 | 874 | ||
882 | if (e->ops->elevator_former_req_fn) | 875 | if (e->ops->elevator_former_req_fn) |
883 | return e->ops->elevator_former_req_fn(q, rq); | 876 | return e->ops->elevator_former_req_fn(q, rq); |
@@ -886,7 +879,7 @@ struct request *elv_former_request(struct request_queue *q, struct request *rq) | |||
886 | 879 | ||
887 | int elv_set_request(struct request_queue *q, struct request *rq, gfp_t gfp_mask) | 880 | int elv_set_request(struct request_queue *q, struct request *rq, gfp_t gfp_mask) |
888 | { | 881 | { |
889 | elevator_t *e = q->elevator; | 882 | struct elevator_queue *e = q->elevator; |
890 | 883 | ||
891 | if (e->ops->elevator_set_req_fn) | 884 | if (e->ops->elevator_set_req_fn) |
892 | return e->ops->elevator_set_req_fn(q, rq, gfp_mask); | 885 | return e->ops->elevator_set_req_fn(q, rq, gfp_mask); |
@@ -897,7 +890,7 @@ int elv_set_request(struct request_queue *q, struct request *rq, gfp_t gfp_mask) | |||
897 | 890 | ||
898 | void elv_put_request(struct request_queue *q, struct request *rq) | 891 | void elv_put_request(struct request_queue *q, struct request *rq) |
899 | { | 892 | { |
900 | elevator_t *e = q->elevator; | 893 | struct elevator_queue *e = q->elevator; |
901 | 894 | ||
902 | if (e->ops->elevator_put_req_fn) | 895 | if (e->ops->elevator_put_req_fn) |
903 | e->ops->elevator_put_req_fn(rq); | 896 | e->ops->elevator_put_req_fn(rq); |
@@ -905,7 +898,7 @@ void elv_put_request(struct request_queue *q, struct request *rq) | |||
905 | 898 | ||
906 | int elv_may_queue(struct request_queue *q, int rw) | 899 | int elv_may_queue(struct request_queue *q, int rw) |
907 | { | 900 | { |
908 | elevator_t *e = q->elevator; | 901 | struct elevator_queue *e = q->elevator; |
909 | 902 | ||
910 | if (e->ops->elevator_may_queue_fn) | 903 | if (e->ops->elevator_may_queue_fn) |
911 | return e->ops->elevator_may_queue_fn(q, rw); | 904 | return e->ops->elevator_may_queue_fn(q, rw); |
@@ -928,7 +921,7 @@ EXPORT_SYMBOL(elv_abort_queue); | |||
928 | 921 | ||
929 | void elv_completed_request(struct request_queue *q, struct request *rq) | 922 | void elv_completed_request(struct request_queue *q, struct request *rq) |
930 | { | 923 | { |
931 | elevator_t *e = q->elevator; | 924 | struct elevator_queue *e = q->elevator; |
932 | 925 | ||
933 | /* | 926 | /* |
934 | * request is released from the driver, io must be done | 927 | * request is released from the driver, io must be done |
@@ -944,10 +937,14 @@ void elv_completed_request(struct request_queue *q, struct request *rq) | |||
944 | * drained for flush sequence. | 937 | * drained for flush sequence. |
945 | */ | 938 | */ |
946 | if (unlikely(q->ordseq)) { | 939 | if (unlikely(q->ordseq)) { |
947 | struct request *first_rq = list_entry_rq(q->queue_head.next); | 940 | struct request *next = NULL; |
948 | if (q->in_flight == 0 && | 941 | |
942 | if (!list_empty(&q->queue_head)) | ||
943 | next = list_entry_rq(q->queue_head.next); | ||
944 | |||
945 | if (!q->in_flight && | ||
949 | blk_ordered_cur_seq(q) == QUEUE_ORDSEQ_DRAIN && | 946 | blk_ordered_cur_seq(q) == QUEUE_ORDSEQ_DRAIN && |
950 | blk_ordered_req_seq(first_rq) > QUEUE_ORDSEQ_DRAIN) { | 947 | (!next || blk_ordered_req_seq(next) > QUEUE_ORDSEQ_DRAIN)) { |
951 | blk_ordered_complete_seq(q, QUEUE_ORDSEQ_DRAIN, 0); | 948 | blk_ordered_complete_seq(q, QUEUE_ORDSEQ_DRAIN, 0); |
952 | blk_start_queueing(q); | 949 | blk_start_queueing(q); |
953 | } | 950 | } |
@@ -959,13 +956,14 @@ void elv_completed_request(struct request_queue *q, struct request *rq) | |||
959 | static ssize_t | 956 | static ssize_t |
960 | elv_attr_show(struct kobject *kobj, struct attribute *attr, char *page) | 957 | elv_attr_show(struct kobject *kobj, struct attribute *attr, char *page) |
961 | { | 958 | { |
962 | elevator_t *e = container_of(kobj, elevator_t, kobj); | ||
963 | struct elv_fs_entry *entry = to_elv(attr); | 959 | struct elv_fs_entry *entry = to_elv(attr); |
960 | struct elevator_queue *e; | ||
964 | ssize_t error; | 961 | ssize_t error; |
965 | 962 | ||
966 | if (!entry->show) | 963 | if (!entry->show) |
967 | return -EIO; | 964 | return -EIO; |
968 | 965 | ||
966 | e = container_of(kobj, struct elevator_queue, kobj); | ||
969 | mutex_lock(&e->sysfs_lock); | 967 | mutex_lock(&e->sysfs_lock); |
970 | error = e->ops ? entry->show(e, page) : -ENOENT; | 968 | error = e->ops ? entry->show(e, page) : -ENOENT; |
971 | mutex_unlock(&e->sysfs_lock); | 969 | mutex_unlock(&e->sysfs_lock); |
@@ -976,13 +974,14 @@ static ssize_t | |||
976 | elv_attr_store(struct kobject *kobj, struct attribute *attr, | 974 | elv_attr_store(struct kobject *kobj, struct attribute *attr, |
977 | const char *page, size_t length) | 975 | const char *page, size_t length) |
978 | { | 976 | { |
979 | elevator_t *e = container_of(kobj, elevator_t, kobj); | ||
980 | struct elv_fs_entry *entry = to_elv(attr); | 977 | struct elv_fs_entry *entry = to_elv(attr); |
978 | struct elevator_queue *e; | ||
981 | ssize_t error; | 979 | ssize_t error; |
982 | 980 | ||
983 | if (!entry->store) | 981 | if (!entry->store) |
984 | return -EIO; | 982 | return -EIO; |
985 | 983 | ||
984 | e = container_of(kobj, struct elevator_queue, kobj); | ||
986 | mutex_lock(&e->sysfs_lock); | 985 | mutex_lock(&e->sysfs_lock); |
987 | error = e->ops ? entry->store(e, page, length) : -ENOENT; | 986 | error = e->ops ? entry->store(e, page, length) : -ENOENT; |
988 | mutex_unlock(&e->sysfs_lock); | 987 | mutex_unlock(&e->sysfs_lock); |
@@ -1001,7 +1000,7 @@ static struct kobj_type elv_ktype = { | |||
1001 | 1000 | ||
1002 | int elv_register_queue(struct request_queue *q) | 1001 | int elv_register_queue(struct request_queue *q) |
1003 | { | 1002 | { |
1004 | elevator_t *e = q->elevator; | 1003 | struct elevator_queue *e = q->elevator; |
1005 | int error; | 1004 | int error; |
1006 | 1005 | ||
1007 | error = kobject_add(&e->kobj, &q->kobj, "%s", "iosched"); | 1006 | error = kobject_add(&e->kobj, &q->kobj, "%s", "iosched"); |
@@ -1019,7 +1018,7 @@ int elv_register_queue(struct request_queue *q) | |||
1019 | return error; | 1018 | return error; |
1020 | } | 1019 | } |
1021 | 1020 | ||
1022 | static void __elv_unregister_queue(elevator_t *e) | 1021 | static void __elv_unregister_queue(struct elevator_queue *e) |
1023 | { | 1022 | { |
1024 | kobject_uevent(&e->kobj, KOBJ_REMOVE); | 1023 | kobject_uevent(&e->kobj, KOBJ_REMOVE); |
1025 | kobject_del(&e->kobj); | 1024 | kobject_del(&e->kobj); |
@@ -1082,7 +1081,7 @@ EXPORT_SYMBOL_GPL(elv_unregister); | |||
1082 | */ | 1081 | */ |
1083 | static int elevator_switch(struct request_queue *q, struct elevator_type *new_e) | 1082 | static int elevator_switch(struct request_queue *q, struct elevator_type *new_e) |
1084 | { | 1083 | { |
1085 | elevator_t *old_elevator, *e; | 1084 | struct elevator_queue *old_elevator, *e; |
1086 | void *data; | 1085 | void *data; |
1087 | 1086 | ||
1088 | /* | 1087 | /* |
@@ -1188,7 +1187,7 @@ ssize_t elv_iosched_store(struct request_queue *q, const char *name, | |||
1188 | 1187 | ||
1189 | ssize_t elv_iosched_show(struct request_queue *q, char *name) | 1188 | ssize_t elv_iosched_show(struct request_queue *q, char *name) |
1190 | { | 1189 | { |
1191 | elevator_t *e = q->elevator; | 1190 | struct elevator_queue *e = q->elevator; |
1192 | struct elevator_type *elv = e->elevator_type; | 1191 | struct elevator_type *elv = e->elevator_type; |
1193 | struct elevator_type *__e; | 1192 | struct elevator_type *__e; |
1194 | int len = 0; | 1193 | int len = 0; |