From: Bart Van Assche <bvanassche@acm.org>
Cc: linux-scsi <linux-scsi@vger.kernel.org>,
James Bottomley <jbottomley@parallels.com>,
Jens Axboe <axboe@kernel.dk>, Joe Lawrence <jdl1291@gmail.com>,
Jun'ichi Nomura <j-nomura@ce.jp.nec.com>,
Mike Christie <michaelc@cs.wisc.edu>,
Muthukumar Ratty <muthur@gmail.com>,
Stefan Richter <stefanr@s5r6.in-berlin.de>,
Tejun Heo <tj@kernel.org>
Subject: [PATCH 1/5] block: Fix blk_execute_rq_nowait() dead queue handling
Date: Fri, 29 Jun 2012 15:31:49 +0000 [thread overview]
Message-ID: <4FEDCA65.30608@acm.org> (raw)
In-Reply-To: <4FEDCA26.90804@acm.org>
From: Muthukumar Ratty <muthur@gmail.com>
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 <muthur@gmail.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Acked-by: Tejun Heo <tj@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: James Bottomley <JBottomley@parallels.com>
---
block/blk-exec.c | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/block/blk-exec.c b/block/blk-exec.c
index fb2cbd5..8b6dc5b 100644
--- a/block/blk-exec.c
+++ b/block/blk-exec.c
@@ -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,
@@ -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 */
--
1.7.7
next prev parent reply other threads:[~2012-06-29 15:31 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-29 15:30 [PATCH 0/4 v10] SCSI device removal fixes Bart Van Assche
2012-06-29 15:31 ` Bart Van Assche [this message]
2012-06-29 15:33 ` [PATCH 2/5] scsi: Fix device removal NULL pointer dereference Bart Van Assche
2012-06-29 15:34 ` [PATCH 3/5] scsi: Avoid dangling pointer in scsi_requeue_command() Bart Van Assche
2012-06-29 16:06 ` Mike Christie
2012-06-29 16:48 ` Tejun Heo
2012-06-29 15:35 ` [PATCH 4/5] scsi: Change return type of scsi_queue_insert() into void Bart Van Assche
2012-06-29 15:36 ` [PATCH 5/5] scsi: Stop accepting SCSI requests before removing a device Bart Van Assche
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4FEDCA65.30608@acm.org \
--to=bvanassche@acm.org \
--cc=axboe@kernel.dk \
--cc=j-nomura@ce.jp.nec.com \
--cc=jbottomley@parallels.com \
--cc=jdl1291@gmail.com \
--cc=linux-scsi@vger.kernel.org \
--cc=michaelc@cs.wisc.edu \
--cc=muthur@gmail.com \
--cc=stefanr@s5r6.in-berlin.de \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).