Commit d22e4c78 authored by Muthukumar Ratty's avatar Muthukumar Ratty Committed by Willy Tarreau

block: Fix blk_execute_rq_nowait() dead queue handling

commit e81ca6fe upstream.

If the queue is dead blk_execute_rq_nowait() doesn't invoke the done()
callback function. That will result in blk_execute_rq() being stuck
in wait_for_completion(). Avoid this by initializing rq->end_io to the
done() callback before we check the queue state. Also, make sure the
queue lock is held around the invocation of the done() callback. Found
this through source code review.
Signed-off-by: default avatarMuthukumar Ratty <muthur@gmail.com>
Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
Reviewed-by: default avatarTejun Heo <tj@kernel.org>
Acked-by: default avatarJens Axboe <axboe@kernel.dk>
Signed-off-by: default avatarJames Bottomley <JBottomley@Parallels.com>
[bwh: Backported to 2.6.32: adjust context]
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
parent 3b77fc36
...@@ -43,6 +43,9 @@ static void blk_end_sync_rq(struct request *rq, int error) ...@@ -43,6 +43,9 @@ static void blk_end_sync_rq(struct request *rq, int error)
* Description: * Description:
* Insert a fully prepared request at the back of the I/O scheduler queue * Insert a fully prepared request at the back of the I/O scheduler queue
* for execution. Don't wait for completion. * for execution. Don't wait for completion.
*
* Note:
* This function will invoke @done directly if the queue is dead.
*/ */
void blk_execute_rq_nowait(struct request_queue *q, struct gendisk *bd_disk, void blk_execute_rq_nowait(struct request_queue *q, struct gendisk *bd_disk,
struct request *rq, int at_head, struct request *rq, int at_head,
...@@ -51,18 +54,20 @@ void blk_execute_rq_nowait(struct request_queue *q, struct gendisk *bd_disk, ...@@ -51,18 +54,20 @@ void blk_execute_rq_nowait(struct request_queue *q, struct gendisk *bd_disk,
int where = at_head ? ELEVATOR_INSERT_FRONT : ELEVATOR_INSERT_BACK; int where = at_head ? ELEVATOR_INSERT_FRONT : ELEVATOR_INSERT_BACK;
WARN_ON(irqs_disabled()); WARN_ON(irqs_disabled());
rq->rq_disk = bd_disk;
rq->end_io = done;
spin_lock_irq(q->queue_lock); spin_lock_irq(q->queue_lock);
if (unlikely(test_bit(QUEUE_FLAG_DEAD, &q->queue_flags))) { if (unlikely(test_bit(QUEUE_FLAG_DEAD, &q->queue_flags))) {
spin_unlock_irq(q->queue_lock);
rq->errors = -ENXIO; rq->errors = -ENXIO;
if (rq->end_io) if (rq->end_io)
rq->end_io(rq, rq->errors); rq->end_io(rq, rq->errors);
spin_unlock_irq(q->queue_lock);
return; return;
} }
rq->rq_disk = bd_disk;
rq->end_io = done;
__elv_add_request(q, rq, where, 1); __elv_add_request(q, rq, where, 1);
__generic_unplug_device(q); __generic_unplug_device(q);
/* the queue is stopped so it won't be plugged+unplugged */ /* the queue is stopped so it won't be plugged+unplugged */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment