aboutsummaryrefslogtreecommitdiffstats
path: root/block/blk-core.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2011-10-19 08:32:38 -0400
committerJens Axboe <axboe@kernel.dk>2011-10-19 08:32:38 -0400
commite3c78ca524d230bc145e902625e88c392a58ddf3 (patch)
tree833eb544dd4180fd626f60da17788aae7830f4dc /block/blk-core.c
parent315fceee81155ef2aeed9316ca72aeea9347db5c (diff)
block: reorganize queue draining
Reorganize queue draining related code in preparation of queue exit changes. * Factor out actual draining from elv_quiesce_start() to blk_drain_queue(). * Make elv_quiesce_start/end() responsible for their own locking. * Replace open-coded ELVSWITCH clearing in elevator_switch() with elv_quiesce_end(). This patch doesn't cause any visible functional difference. 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.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/block/blk-core.c b/block/blk-core.c
index a3d2fdc8ed1c..149149dd7f7b 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -28,6 +28,7 @@
28#include <linux/task_io_accounting_ops.h> 28#include <linux/task_io_accounting_ops.h>
29#include <linux/fault-inject.h> 29#include <linux/fault-inject.h>
30#include <linux/list_sort.h> 30#include <linux/list_sort.h>
31#include <linux/delay.h>
31 32
32#define CREATE_TRACE_POINTS 33#define CREATE_TRACE_POINTS
33#include <trace/events/block.h> 34#include <trace/events/block.h>
@@ -345,6 +346,33 @@ void blk_put_queue(struct request_queue *q)
345} 346}
346EXPORT_SYMBOL(blk_put_queue); 347EXPORT_SYMBOL(blk_put_queue);
347 348
349/**
350 * blk_drain_queue - drain requests from request_queue
351 * @q: queue to drain
352 *
353 * Drain ELV_PRIV requests from @q. The caller is responsible for ensuring
354 * that no new requests which need to be drained are queued.
355 */
356void blk_drain_queue(struct request_queue *q)
357{
358 while (true) {
359 int nr_rqs;
360
361 spin_lock_irq(q->queue_lock);
362
363 elv_drain_elevator(q);
364
365 __blk_run_queue(q);
366 nr_rqs = q->rq.elvpriv;
367
368 spin_unlock_irq(q->queue_lock);
369
370 if (!nr_rqs)
371 break;
372 msleep(10);
373 }
374}
375
348/* 376/*
349 * Note: If a driver supplied the queue lock, it is disconnected 377 * Note: If a driver supplied the queue lock, it is disconnected
350 * by this function. The actual state of the lock doesn't matter 378 * by this function. The actual state of the lock doesn't matter