diff options
Diffstat (limited to 'drivers/block/deadline-iosched.c')
-rw-r--r-- | drivers/block/deadline-iosched.c | 125 |
1 files changed, 19 insertions, 106 deletions
diff --git a/drivers/block/deadline-iosched.c b/drivers/block/deadline-iosched.c index 52a3ae5289a..7929471d7df 100644 --- a/drivers/block/deadline-iosched.c +++ b/drivers/block/deadline-iosched.c | |||
@@ -50,7 +50,6 @@ struct deadline_data { | |||
50 | * next in sort order. read, write or both are NULL | 50 | * next in sort order. read, write or both are NULL |
51 | */ | 51 | */ |
52 | struct deadline_rq *next_drq[2]; | 52 | struct deadline_rq *next_drq[2]; |
53 | struct list_head *dispatch; /* driver dispatch queue */ | ||
54 | struct list_head *hash; /* request hash */ | 53 | struct list_head *hash; /* request hash */ |
55 | unsigned int batching; /* number of sequential requests made */ | 54 | unsigned int batching; /* number of sequential requests made */ |
56 | sector_t last_sector; /* head position */ | 55 | sector_t last_sector; /* head position */ |
@@ -113,15 +112,6 @@ static inline void deadline_del_drq_hash(struct deadline_rq *drq) | |||
113 | __deadline_del_drq_hash(drq); | 112 | __deadline_del_drq_hash(drq); |
114 | } | 113 | } |
115 | 114 | ||
116 | static void | ||
117 | deadline_remove_merge_hints(request_queue_t *q, struct deadline_rq *drq) | ||
118 | { | ||
119 | deadline_del_drq_hash(drq); | ||
120 | |||
121 | if (q->last_merge == drq->request) | ||
122 | q->last_merge = NULL; | ||
123 | } | ||
124 | |||
125 | static inline void | 115 | static inline void |
126 | deadline_add_drq_hash(struct deadline_data *dd, struct deadline_rq *drq) | 116 | deadline_add_drq_hash(struct deadline_data *dd, struct deadline_rq *drq) |
127 | { | 117 | { |
@@ -239,10 +229,9 @@ deadline_del_drq_rb(struct deadline_data *dd, struct deadline_rq *drq) | |||
239 | dd->next_drq[data_dir] = rb_entry_drq(rbnext); | 229 | dd->next_drq[data_dir] = rb_entry_drq(rbnext); |
240 | } | 230 | } |
241 | 231 | ||
242 | if (ON_RB(&drq->rb_node)) { | 232 | BUG_ON(!ON_RB(&drq->rb_node)); |
243 | rb_erase(&drq->rb_node, DRQ_RB_ROOT(dd, drq)); | 233 | rb_erase(&drq->rb_node, DRQ_RB_ROOT(dd, drq)); |
244 | RB_CLEAR(&drq->rb_node); | 234 | RB_CLEAR(&drq->rb_node); |
245 | } | ||
246 | } | 235 | } |
247 | 236 | ||
248 | static struct request * | 237 | static struct request * |
@@ -286,7 +275,7 @@ deadline_find_first_drq(struct deadline_data *dd, int data_dir) | |||
286 | /* | 275 | /* |
287 | * add drq to rbtree and fifo | 276 | * add drq to rbtree and fifo |
288 | */ | 277 | */ |
289 | static inline void | 278 | static void |
290 | deadline_add_request(struct request_queue *q, struct request *rq) | 279 | deadline_add_request(struct request_queue *q, struct request *rq) |
291 | { | 280 | { |
292 | struct deadline_data *dd = q->elevator->elevator_data; | 281 | struct deadline_data *dd = q->elevator->elevator_data; |
@@ -301,12 +290,8 @@ deadline_add_request(struct request_queue *q, struct request *rq) | |||
301 | drq->expires = jiffies + dd->fifo_expire[data_dir]; | 290 | drq->expires = jiffies + dd->fifo_expire[data_dir]; |
302 | list_add_tail(&drq->fifo, &dd->fifo_list[data_dir]); | 291 | list_add_tail(&drq->fifo, &dd->fifo_list[data_dir]); |
303 | 292 | ||
304 | if (rq_mergeable(rq)) { | 293 | if (rq_mergeable(rq)) |
305 | deadline_add_drq_hash(dd, drq); | 294 | deadline_add_drq_hash(dd, drq); |
306 | |||
307 | if (!q->last_merge) | ||
308 | q->last_merge = rq; | ||
309 | } | ||
310 | } | 295 | } |
311 | 296 | ||
312 | /* | 297 | /* |
@@ -315,14 +300,11 @@ deadline_add_request(struct request_queue *q, struct request *rq) | |||
315 | static void deadline_remove_request(request_queue_t *q, struct request *rq) | 300 | static void deadline_remove_request(request_queue_t *q, struct request *rq) |
316 | { | 301 | { |
317 | struct deadline_rq *drq = RQ_DATA(rq); | 302 | struct deadline_rq *drq = RQ_DATA(rq); |
303 | struct deadline_data *dd = q->elevator->elevator_data; | ||
318 | 304 | ||
319 | if (drq) { | 305 | list_del_init(&drq->fifo); |
320 | struct deadline_data *dd = q->elevator->elevator_data; | 306 | deadline_del_drq_rb(dd, drq); |
321 | 307 | deadline_del_drq_hash(drq); | |
322 | list_del_init(&drq->fifo); | ||
323 | deadline_remove_merge_hints(q, drq); | ||
324 | deadline_del_drq_rb(dd, drq); | ||
325 | } | ||
326 | } | 308 | } |
327 | 309 | ||
328 | static int | 310 | static int |
@@ -333,15 +315,6 @@ deadline_merge(request_queue_t *q, struct request **req, struct bio *bio) | |||
333 | int ret; | 315 | int ret; |
334 | 316 | ||
335 | /* | 317 | /* |
336 | * try last_merge to avoid going to hash | ||
337 | */ | ||
338 | ret = elv_try_last_merge(q, bio); | ||
339 | if (ret != ELEVATOR_NO_MERGE) { | ||
340 | __rq = q->last_merge; | ||
341 | goto out_insert; | ||
342 | } | ||
343 | |||
344 | /* | ||
345 | * see if the merge hash can satisfy a back merge | 318 | * see if the merge hash can satisfy a back merge |
346 | */ | 319 | */ |
347 | __rq = deadline_find_drq_hash(dd, bio->bi_sector); | 320 | __rq = deadline_find_drq_hash(dd, bio->bi_sector); |
@@ -373,8 +346,6 @@ deadline_merge(request_queue_t *q, struct request **req, struct bio *bio) | |||
373 | 346 | ||
374 | return ELEVATOR_NO_MERGE; | 347 | return ELEVATOR_NO_MERGE; |
375 | out: | 348 | out: |
376 | q->last_merge = __rq; | ||
377 | out_insert: | ||
378 | if (ret) | 349 | if (ret) |
379 | deadline_hot_drq_hash(dd, RQ_DATA(__rq)); | 350 | deadline_hot_drq_hash(dd, RQ_DATA(__rq)); |
380 | *req = __rq; | 351 | *req = __rq; |
@@ -399,8 +370,6 @@ static void deadline_merged_request(request_queue_t *q, struct request *req) | |||
399 | deadline_del_drq_rb(dd, drq); | 370 | deadline_del_drq_rb(dd, drq); |
400 | deadline_add_drq_rb(dd, drq); | 371 | deadline_add_drq_rb(dd, drq); |
401 | } | 372 | } |
402 | |||
403 | q->last_merge = req; | ||
404 | } | 373 | } |
405 | 374 | ||
406 | static void | 375 | static void |
@@ -452,7 +421,7 @@ deadline_move_to_dispatch(struct deadline_data *dd, struct deadline_rq *drq) | |||
452 | request_queue_t *q = drq->request->q; | 421 | request_queue_t *q = drq->request->q; |
453 | 422 | ||
454 | deadline_remove_request(q, drq->request); | 423 | deadline_remove_request(q, drq->request); |
455 | list_add_tail(&drq->request->queuelist, dd->dispatch); | 424 | elv_dispatch_add_tail(q, drq->request); |
456 | } | 425 | } |
457 | 426 | ||
458 | /* | 427 | /* |
@@ -502,8 +471,9 @@ static inline int deadline_check_fifo(struct deadline_data *dd, int ddir) | |||
502 | * deadline_dispatch_requests selects the best request according to | 471 | * deadline_dispatch_requests selects the best request according to |
503 | * read/write expire, fifo_batch, etc | 472 | * read/write expire, fifo_batch, etc |
504 | */ | 473 | */ |
505 | static int deadline_dispatch_requests(struct deadline_data *dd) | 474 | static int deadline_dispatch_requests(request_queue_t *q, int force) |
506 | { | 475 | { |
476 | struct deadline_data *dd = q->elevator->elevator_data; | ||
507 | const int reads = !list_empty(&dd->fifo_list[READ]); | 477 | const int reads = !list_empty(&dd->fifo_list[READ]); |
508 | const int writes = !list_empty(&dd->fifo_list[WRITE]); | 478 | const int writes = !list_empty(&dd->fifo_list[WRITE]); |
509 | struct deadline_rq *drq; | 479 | struct deadline_rq *drq; |
@@ -597,65 +567,12 @@ dispatch_request: | |||
597 | return 1; | 567 | return 1; |
598 | } | 568 | } |
599 | 569 | ||
600 | static struct request *deadline_next_request(request_queue_t *q) | ||
601 | { | ||
602 | struct deadline_data *dd = q->elevator->elevator_data; | ||
603 | struct request *rq; | ||
604 | |||
605 | /* | ||
606 | * if there are still requests on the dispatch queue, grab the first one | ||
607 | */ | ||
608 | if (!list_empty(dd->dispatch)) { | ||
609 | dispatch: | ||
610 | rq = list_entry_rq(dd->dispatch->next); | ||
611 | return rq; | ||
612 | } | ||
613 | |||
614 | if (deadline_dispatch_requests(dd)) | ||
615 | goto dispatch; | ||
616 | |||
617 | return NULL; | ||
618 | } | ||
619 | |||
620 | static void | ||
621 | deadline_insert_request(request_queue_t *q, struct request *rq, int where) | ||
622 | { | ||
623 | struct deadline_data *dd = q->elevator->elevator_data; | ||
624 | |||
625 | /* barriers must flush the reorder queue */ | ||
626 | if (unlikely(rq->flags & (REQ_SOFTBARRIER | REQ_HARDBARRIER) | ||
627 | && where == ELEVATOR_INSERT_SORT)) | ||
628 | where = ELEVATOR_INSERT_BACK; | ||
629 | |||
630 | switch (where) { | ||
631 | case ELEVATOR_INSERT_BACK: | ||
632 | while (deadline_dispatch_requests(dd)) | ||
633 | ; | ||
634 | list_add_tail(&rq->queuelist, dd->dispatch); | ||
635 | break; | ||
636 | case ELEVATOR_INSERT_FRONT: | ||
637 | list_add(&rq->queuelist, dd->dispatch); | ||
638 | break; | ||
639 | case ELEVATOR_INSERT_SORT: | ||
640 | BUG_ON(!blk_fs_request(rq)); | ||
641 | deadline_add_request(q, rq); | ||
642 | break; | ||
643 | default: | ||
644 | printk("%s: bad insert point %d\n", __FUNCTION__,where); | ||
645 | return; | ||
646 | } | ||
647 | } | ||
648 | |||
649 | static int deadline_queue_empty(request_queue_t *q) | 570 | static int deadline_queue_empty(request_queue_t *q) |
650 | { | 571 | { |
651 | struct deadline_data *dd = q->elevator->elevator_data; | 572 | struct deadline_data *dd = q->elevator->elevator_data; |
652 | 573 | ||
653 | if (!list_empty(&dd->fifo_list[WRITE]) | 574 | return list_empty(&dd->fifo_list[WRITE]) |
654 | || !list_empty(&dd->fifo_list[READ]) | 575 | && list_empty(&dd->fifo_list[READ]); |
655 | || !list_empty(dd->dispatch)) | ||
656 | return 0; | ||
657 | |||
658 | return 1; | ||
659 | } | 576 | } |
660 | 577 | ||
661 | static struct request * | 578 | static struct request * |
@@ -733,7 +650,6 @@ static int deadline_init_queue(request_queue_t *q, elevator_t *e) | |||
733 | INIT_LIST_HEAD(&dd->fifo_list[WRITE]); | 650 | INIT_LIST_HEAD(&dd->fifo_list[WRITE]); |
734 | dd->sort_list[READ] = RB_ROOT; | 651 | dd->sort_list[READ] = RB_ROOT; |
735 | dd->sort_list[WRITE] = RB_ROOT; | 652 | dd->sort_list[WRITE] = RB_ROOT; |
736 | dd->dispatch = &q->queue_head; | ||
737 | dd->fifo_expire[READ] = read_expire; | 653 | dd->fifo_expire[READ] = read_expire; |
738 | dd->fifo_expire[WRITE] = write_expire; | 654 | dd->fifo_expire[WRITE] = write_expire; |
739 | dd->writes_starved = writes_starved; | 655 | dd->writes_starved = writes_starved; |
@@ -748,15 +664,13 @@ static void deadline_put_request(request_queue_t *q, struct request *rq) | |||
748 | struct deadline_data *dd = q->elevator->elevator_data; | 664 | struct deadline_data *dd = q->elevator->elevator_data; |
749 | struct deadline_rq *drq = RQ_DATA(rq); | 665 | struct deadline_rq *drq = RQ_DATA(rq); |
750 | 666 | ||
751 | if (drq) { | 667 | mempool_free(drq, dd->drq_pool); |
752 | mempool_free(drq, dd->drq_pool); | 668 | rq->elevator_private = NULL; |
753 | rq->elevator_private = NULL; | ||
754 | } | ||
755 | } | 669 | } |
756 | 670 | ||
757 | static int | 671 | static int |
758 | deadline_set_request(request_queue_t *q, struct request *rq, struct bio *bio, | 672 | deadline_set_request(request_queue_t *q, struct request *rq, struct bio *bio, |
759 | int gfp_mask) | 673 | gfp_t gfp_mask) |
760 | { | 674 | { |
761 | struct deadline_data *dd = q->elevator->elevator_data; | 675 | struct deadline_data *dd = q->elevator->elevator_data; |
762 | struct deadline_rq *drq; | 676 | struct deadline_rq *drq; |
@@ -917,9 +831,8 @@ static struct elevator_type iosched_deadline = { | |||
917 | .elevator_merge_fn = deadline_merge, | 831 | .elevator_merge_fn = deadline_merge, |
918 | .elevator_merged_fn = deadline_merged_request, | 832 | .elevator_merged_fn = deadline_merged_request, |
919 | .elevator_merge_req_fn = deadline_merged_requests, | 833 | .elevator_merge_req_fn = deadline_merged_requests, |
920 | .elevator_next_req_fn = deadline_next_request, | 834 | .elevator_dispatch_fn = deadline_dispatch_requests, |
921 | .elevator_add_req_fn = deadline_insert_request, | 835 | .elevator_add_req_fn = deadline_add_request, |
922 | .elevator_remove_req_fn = deadline_remove_request, | ||
923 | .elevator_queue_empty_fn = deadline_queue_empty, | 836 | .elevator_queue_empty_fn = deadline_queue_empty, |
924 | .elevator_former_req_fn = deadline_former_request, | 837 | .elevator_former_req_fn = deadline_former_request, |
925 | .elevator_latter_req_fn = deadline_latter_request, | 838 | .elevator_latter_req_fn = deadline_latter_request, |