aboutsummaryrefslogtreecommitdiffstats
path: root/block/elevator.c
diff options
context:
space:
mode:
Diffstat (limited to 'block/elevator.c')
-rw-r--r--block/elevator.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/block/elevator.c b/block/elevator.c
index a475b1a19f67..73aa46b6db49 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -226,6 +226,7 @@ void elv_dispatch_sort(request_queue_t *q, struct request *rq)
226 226
227 if (q->last_merge == rq) 227 if (q->last_merge == rq)
228 q->last_merge = NULL; 228 q->last_merge = NULL;
229 q->nr_sorted--;
229 230
230 boundary = q->end_sector; 231 boundary = q->end_sector;
231 232
@@ -284,6 +285,7 @@ void elv_merge_requests(request_queue_t *q, struct request *rq,
284 285
285 if (e->ops->elevator_merge_req_fn) 286 if (e->ops->elevator_merge_req_fn)
286 e->ops->elevator_merge_req_fn(q, rq, next); 287 e->ops->elevator_merge_req_fn(q, rq, next);
288 q->nr_sorted--;
287 289
288 q->last_merge = rq; 290 q->last_merge = rq;
289} 291}
@@ -315,6 +317,20 @@ void elv_requeue_request(request_queue_t *q, struct request *rq)
315 __elv_add_request(q, rq, ELEVATOR_INSERT_FRONT, 0); 317 __elv_add_request(q, rq, ELEVATOR_INSERT_FRONT, 0);
316} 318}
317 319
320static void elv_drain_elevator(request_queue_t *q)
321{
322 static int printed;
323 while (q->elevator->ops->elevator_dispatch_fn(q, 1))
324 ;
325 if (q->nr_sorted == 0)
326 return;
327 if (printed++ < 10) {
328 printk(KERN_ERR "%s: forced dispatching is broken "
329 "(nr_sorted=%u), please report this\n",
330 q->elevator->elevator_type->elevator_name, q->nr_sorted);
331 }
332}
333
318void __elv_add_request(request_queue_t *q, struct request *rq, int where, 334void __elv_add_request(request_queue_t *q, struct request *rq, int where,
319 int plug) 335 int plug)
320{ 336{
@@ -349,9 +365,7 @@ void __elv_add_request(request_queue_t *q, struct request *rq, int where,
349 365
350 case ELEVATOR_INSERT_BACK: 366 case ELEVATOR_INSERT_BACK:
351 rq->flags |= REQ_SOFTBARRIER; 367 rq->flags |= REQ_SOFTBARRIER;
352 368 elv_drain_elevator(q);
353 while (q->elevator->ops->elevator_dispatch_fn(q, 1))
354 ;
355 list_add_tail(&rq->queuelist, &q->queue_head); 369 list_add_tail(&rq->queuelist, &q->queue_head);
356 /* 370 /*
357 * We kick the queue here for the following reasons. 371 * We kick the queue here for the following reasons.
@@ -370,6 +384,7 @@ void __elv_add_request(request_queue_t *q, struct request *rq, int where,
370 case ELEVATOR_INSERT_SORT: 384 case ELEVATOR_INSERT_SORT:
371 BUG_ON(!blk_fs_request(rq)); 385 BUG_ON(!blk_fs_request(rq));
372 rq->flags |= REQ_SORTED; 386 rq->flags |= REQ_SORTED;
387 q->nr_sorted++;
373 if (q->last_merge == NULL && rq_mergeable(rq)) 388 if (q->last_merge == NULL && rq_mergeable(rq))
374 q->last_merge = rq; 389 q->last_merge = rq;
375 /* 390 /*
@@ -692,8 +707,7 @@ static void elevator_switch(request_queue_t *q, struct elevator_type *new_e)
692 707
693 set_bit(QUEUE_FLAG_ELVSWITCH, &q->queue_flags); 708 set_bit(QUEUE_FLAG_ELVSWITCH, &q->queue_flags);
694 709
695 while (q->elevator->ops->elevator_dispatch_fn(q, 1)) 710 elv_drain_elevator(q);
696 ;
697 711
698 while (q->rq.elvpriv) { 712 while (q->rq.elvpriv) {
699 blk_remove_plug(q); 713 blk_remove_plug(q);
@@ -701,6 +715,7 @@ static void elevator_switch(request_queue_t *q, struct elevator_type *new_e)
701 spin_unlock_irq(q->queue_lock); 715 spin_unlock_irq(q->queue_lock);
702 msleep(10); 716 msleep(10);
703 spin_lock_irq(q->queue_lock); 717 spin_lock_irq(q->queue_lock);
718 elv_drain_elevator(q);
704 } 719 }
705 720
706 spin_unlock_irq(q->queue_lock); 721 spin_unlock_irq(q->queue_lock);