From: Bart Van Assche <bvanassche@acm.org>
To: Mike Christie <michaelc@cs.wisc.edu>
Cc: linux-scsi <linux-scsi@vger.kernel.org>,
James Bottomley <jbottomley@parallels.com>,
Jun'ichi Nomura <j-nomura@ce.jp.nec.com>,
Stefan Richter <stefanr@s5r6.in-berlin.de>,
Tomas Henzl <thenzl@redhat.com>,
Mike Snitzer <snitzer@redhat.com>,
Jens Axboe <jaxboe@fusionio.com>
Subject: Re: [PATCH 3/3] Make scsi_free_queue() abort pending requests
Date: Tue, 29 May 2012 14:56:44 +0000 [thread overview]
Message-ID: <4FC4E3AC.9020008@acm.org> (raw)
In-Reply-To: <4FB1523A.5010003@acm.org>
On 05/14/12 18:43, Bart Van Assche wrote:
> On 05/07/12 00:44, Mike Christie wrote:
>> On 05/05/2012 01:07 AM, Bart Van Assche wrote:
>>> On 05/04/12 20:32, Mike Christie wrote:
>>>> Oh not wait. I do not get the patch. After blk_cleanup_queue runs then
>>>> no IO should be running and no new IO can be queued can it?
>>>>
>>>>>> */
>>>>>> blk_cleanup_queue(q);
>>>>>> + blk_abort_queue(q);
>>>>>>
>>>>>> if (sdev->is_visible) {
>>>>>> if (scsi_device_set_state(sdev, SDEV_CANCEL) != 0)
>>>
>>> After blk_cleanup_queue() finished no new requests will be queued to a
>>> SCSI LLD. However, that function doesn't wait for already queued
>>> requests to finish. I have verified with ib_srp LLD that the\
>>
>> It does for me. It is supposed to isn't it? For BLOCK FS requests
>> blk_drain_queue will wait for the q->in_flight counters to go to zero.
>> They get incremented at scsi_request_fn-> blk_start_request ->
>> blk_dequeue_request time and decremented in scsi_end_request ->
>> blk_end_request -> blk_end_bidi_request -> blk_finish_request ->
>> blk_put_request -> elv_completed_request. For BLOCK PC and other
>> requests there is the rq.count tracking.
>
> I've had a closer look at this and noticed that the q->in_flight[]
> decrement in elv_completed_request() is non-atomic and also that that
> function is called from one context with the queue lock held
> (__blk_put_request()) but from another context without the queue lock
> held (blk_execute_rq_nowait() -> flush_end_io() ->
> elv_completed_request()). I'd appreciate it if someone who is more
> familiar with the block layer than myself could comment on this.
(replying to my own e-mail)
Does the patch below make sense ? It ensures that the queue lock
is held around all end_io invocations.
---
block/blk-core.c | 4 ++++
block/blk-exec.c | 2 +-
block/blk-flush.c | 2 ++
3 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/block/blk-core.c b/block/blk-core.c
index 1f61b74..41ff2af 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -394,6 +394,8 @@ void blk_drain_queue(struct request_queue *q, bool drain_all)
}
}
+ WARN_ON(drain == 0 && !list_empty(&q->timeout_list));
+
spin_unlock_irq(q->queue_lock);
if (!drain)
@@ -2287,6 +2289,8 @@ EXPORT_SYMBOL_GPL(blk_unprep_request);
*/
static void blk_finish_request(struct request *req, int error)
{
+ lockdep_assert_held(req->q->queue_lock);
+
if (blk_rq_tagged(req))
blk_queue_end_tag(req->q, req);
diff --git a/block/blk-exec.c b/block/blk-exec.c
index fb2cbd5..6724fab 100644
--- a/block/blk-exec.c
+++ b/block/blk-exec.c
@@ -54,10 +54,10 @@ void blk_execute_rq_nowait(struct request_queue *q, struct gendisk *bd_disk,
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;
}
diff --git a/block/blk-flush.c b/block/blk-flush.c
index 720ad60..7bb8ed0 100644
--- a/block/blk-flush.c
+++ b/block/blk-flush.c
@@ -198,6 +198,8 @@ static void flush_end_io(struct request *flush_rq, int error)
bool queued = false;
struct request *rq, *n;
+ lockdep_assert_held(q->queue_lock);
+
BUG_ON(q->flush_pending_idx == q->flush_running_idx);
/* account completion of the flush request */
next prev parent reply other threads:[~2012-05-29 14:56 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-04 15:00 [PATCH 0/3 v6] Fixes for SCSI device removal Bart Van Assche
2012-05-04 15:03 ` [PATCH 1/3] sd: Fix device removal NULL pointer dereference Bart Van Assche
2012-05-04 15:06 ` [PATCH 2/3] Stop accepting SCSI requests before removing a device Bart Van Assche
2012-05-04 20:16 ` Mike Christie
2012-05-04 20:30 ` Mike Christie
2012-05-05 13:04 ` Bart Van Assche
2012-05-29 15:00 ` Bart Van Assche
2012-05-29 17:35 ` Mike Christie
2012-05-30 6:56 ` Bart Van Assche
2012-05-30 17:27 ` Mike Christie
2012-05-30 20:00 ` Bart Van Assche
2012-06-01 3:13 ` Mike Christie
2012-05-04 15:07 ` [PATCH 3/3] Make scsi_free_queue() abort pending requests Bart Van Assche
2012-05-04 20:25 ` Mike Christie
2012-05-04 20:32 ` Mike Christie
2012-05-05 6:07 ` Bart Van Assche
2012-05-07 0:44 ` Mike Christie
2012-05-07 1:15 ` Mike Christie
2012-05-14 18:43 ` Bart Van Assche
2012-05-29 14:56 ` Bart Van Assche [this message]
2012-05-05 13:41 ` 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=4FC4E3AC.9020008@acm.org \
--to=bvanassche@acm.org \
--cc=j-nomura@ce.jp.nec.com \
--cc=jaxboe@fusionio.com \
--cc=jbottomley@parallels.com \
--cc=linux-scsi@vger.kernel.org \
--cc=michaelc@cs.wisc.edu \
--cc=snitzer@redhat.com \
--cc=stefanr@s5r6.in-berlin.de \
--cc=thenzl@redhat.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.