diff options
author | Tejun Heo <tj@kernel.org> | 2011-12-13 18:33:37 -0500 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2011-12-13 18:33:37 -0500 |
commit | 481a7d64790cd7ca61a8bbcbd9d017ce58e6fe39 (patch) | |
tree | 2e8fe86240a5e95600cdad5de223050df37ab116 /block/blk-core.c | |
parent | 34f6055c80285e4efb3f602a9119db75239744dc (diff) |
block: fix drain_all condition in blk_drain_queue()
When trying to drain all requests, blk_drain_queue() checked only
q->rq.count[]; however, this only tracks REQ_ALLOCED requests. This
patch updates blk_drain_queue() such that it looks at all the counters
and queues so that request_queue is actually empty on completion.
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/blk-core.c')
-rw-r--r-- | block/blk-core.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/block/blk-core.c b/block/blk-core.c index b5ed4f4a8d96..c37e9e7c9d07 100644 --- a/block/blk-core.c +++ b/block/blk-core.c | |||
@@ -358,7 +358,8 @@ EXPORT_SYMBOL(blk_put_queue); | |||
358 | void blk_drain_queue(struct request_queue *q, bool drain_all) | 358 | void blk_drain_queue(struct request_queue *q, bool drain_all) |
359 | { | 359 | { |
360 | while (true) { | 360 | while (true) { |
361 | int nr_rqs; | 361 | bool drain = false; |
362 | int i; | ||
362 | 363 | ||
363 | spin_lock_irq(q->queue_lock); | 364 | spin_lock_irq(q->queue_lock); |
364 | 365 | ||
@@ -368,14 +369,25 @@ void blk_drain_queue(struct request_queue *q, bool drain_all) | |||
368 | 369 | ||
369 | __blk_run_queue(q); | 370 | __blk_run_queue(q); |
370 | 371 | ||
371 | if (drain_all) | 372 | drain |= q->rq.elvpriv; |
372 | nr_rqs = q->rq.count[0] + q->rq.count[1]; | 373 | |
373 | else | 374 | /* |
374 | nr_rqs = q->rq.elvpriv; | 375 | * Unfortunately, requests are queued at and tracked from |
376 | * multiple places and there's no single counter which can | ||
377 | * be drained. Check all the queues and counters. | ||
378 | */ | ||
379 | if (drain_all) { | ||
380 | drain |= !list_empty(&q->queue_head); | ||
381 | for (i = 0; i < 2; i++) { | ||
382 | drain |= q->rq.count[i]; | ||
383 | drain |= q->in_flight[i]; | ||
384 | drain |= !list_empty(&q->flush_queue[i]); | ||
385 | } | ||
386 | } | ||
375 | 387 | ||
376 | spin_unlock_irq(q->queue_lock); | 388 | spin_unlock_irq(q->queue_lock); |
377 | 389 | ||
378 | if (!nr_rqs) | 390 | if (!drain) |
379 | break; | 391 | break; |
380 | msleep(10); | 392 | msleep(10); |
381 | } | 393 | } |