Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 345667
b: refs/heads/master
c: 807592a
h: refs/heads/master
i:
  345665: d371da9
  345663: 6245e8e
v: v3
  • Loading branch information
Bart Van Assche authored and Jens Axboe committed Dec 6, 2012
1 parent 5a5cfa4 commit ed17e20
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 3f3299d5c0268d6cc3f47b446e8aca436e4a5651
refs/heads/master: 807592a4fafba1fea6e98b9cf1fb02b7c38fb24c
30 changes: 18 additions & 12 deletions trunk/block/blk-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,23 +349,25 @@ void blk_put_queue(struct request_queue *q)
EXPORT_SYMBOL(blk_put_queue);

/**
* blk_drain_queue - drain requests from request_queue
* __blk_drain_queue - drain requests from request_queue
* @q: queue to drain
* @drain_all: whether to drain all requests or only the ones w/ ELVPRIV
*
* Drain requests from @q. If @drain_all is set, all requests are drained.
* If not, only ELVPRIV requests are drained. The caller is responsible
* for ensuring that no new requests which need to be drained are queued.
*/
void blk_drain_queue(struct request_queue *q, bool drain_all)
static void __blk_drain_queue(struct request_queue *q, bool drain_all)
__releases(q->queue_lock)
__acquires(q->queue_lock)
{
int i;

lockdep_assert_held(q->queue_lock);

while (true) {
bool drain = false;

spin_lock_irq(q->queue_lock);

/*
* The caller might be trying to drain @q before its
* elevator is initialized.
Expand Down Expand Up @@ -401,11 +403,14 @@ void blk_drain_queue(struct request_queue *q, bool drain_all)
}
}

spin_unlock_irq(q->queue_lock);

if (!drain)
break;

spin_unlock_irq(q->queue_lock);

msleep(10);

spin_lock_irq(q->queue_lock);
}

/*
Expand All @@ -416,13 +421,9 @@ void blk_drain_queue(struct request_queue *q, bool drain_all)
if (q->request_fn) {
struct request_list *rl;

spin_lock_irq(q->queue_lock);

blk_queue_for_each_rl(rl, q)
for (i = 0; i < ARRAY_SIZE(rl->wait); i++)
wake_up_all(&rl->wait[i]);

spin_unlock_irq(q->queue_lock);
}
}

Expand All @@ -446,7 +447,10 @@ void blk_queue_bypass_start(struct request_queue *q)
spin_unlock_irq(q->queue_lock);

if (drain) {
blk_drain_queue(q, false);
spin_lock_irq(q->queue_lock);
__blk_drain_queue(q, false);
spin_unlock_irq(q->queue_lock);

/* ensure blk_queue_bypass() is %true inside RCU read lock */
synchronize_rcu();
}
Expand Down Expand Up @@ -504,7 +508,9 @@ void blk_cleanup_queue(struct request_queue *q)
mutex_unlock(&q->sysfs_lock);

/* drain all requests queued before DYING marking */
blk_drain_queue(q, true);
spin_lock_irq(lock);
__blk_drain_queue(q, true);
spin_unlock_irq(lock);

/* @q won't process any more request, flush async actions */
del_timer_sync(&q->backing_dev_info.laptop_mode_wb_timer);
Expand Down

0 comments on commit ed17e20

Please sign in to comment.