Skip to content

Commit

Permalink
[SCSI] block: Fix blk_execute_rq_nowait() dead queue handling
Browse files Browse the repository at this point in the history
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: Muthukumar Ratty <[email protected]>
Signed-off-by: Bart Van Assche <[email protected]>
Reviewed-by: Tejun Heo <[email protected]>
Acked-by: Jens Axboe <[email protected]>
Signed-off-by: James Bottomley <[email protected]>
  • Loading branch information
muthu-r authored and James Bottomley committed Jul 20, 2012
1 parent 6548b0e commit e81ca6f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions block/blk-exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ static void blk_end_sync_rq(struct request *rq, int error)
* Description:
* Insert a fully prepared request at the back of the I/O scheduler queue
* 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,
struct request *rq, int at_head,
Expand All @@ -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;

WARN_ON(irqs_disabled());

rq->rq_disk = bd_disk;
rq->end_io = done;

spin_lock_irq(q->queue_lock);

if (unlikely(blk_queue_dead(q))) {
spin_unlock_irq(q->queue_lock);
rq->errors = -ENXIO;
if (rq->end_io)
rq->end_io(rq, rq->errors);
spin_unlock_irq(q->queue_lock);
return;
}

rq->rq_disk = bd_disk;
rq->end_io = done;
__elv_add_request(q, rq, where);
__blk_run_queue(q);
/* the queue is stopped so it won't be run */
Expand Down

0 comments on commit e81ca6f

Please sign in to comment.