From: Bart Van Assche <bvanassche@acm.org>
To: Stanislaw Gruszka <sgruszka@redhat.com>
Cc: Tejun Heo <tj@kernel.org>, Jens Axboe <axboe@kernel.dk>,
linux-scsi <linux-scsi@vger.kernel.org>
Subject: Re: [PATCH] block: Make blk_drain_queue() work for stopped queues
Date: Mon, 19 Mar 2012 17:03:44 +0000 [thread overview]
Message-ID: <4F6766F0.1070805@acm.org> (raw)
In-Reply-To: <20120319072656.GB2251@redhat.com>
On 03/19/12 07:26, Stanislaw Gruszka wrote:
> On Sun, Mar 18, 2012 at 07:47:47PM +0000, Bart Van Assche wrote:
>> On 03/18/12 15:57, Tejun Heo wrote:
>>> On Sun, Mar 18, 2012 at 01:18:21PM +0000, Bart Van Assche wrote:
>>>> All queued requests must be processed eventually. Hence make sure
>>>> that blk_drain_queue() drains the queue even if the queue is in the
>>>> stopped state. This patch makes it safe to invoke blk_cleanup_queue()
>>>> on a stopped queue.
>>> ...
>>>> diff --git a/block/blk-core.c b/block/blk-core.c
>>>> index 3a78b00..bdcec86 100644
>>>> --- a/block/blk-core.c
>>>> +++ b/block/blk-core.c
>>>> @@ -300,10 +300,8 @@ EXPORT_SYMBOL(blk_sync_queue);
>>>> */
>>>> void __blk_run_queue(struct request_queue *q)
>>>> {
>>>> - if (unlikely(blk_queue_stopped(q)))
>>>> - return;
>>>> -
>>>> - q->request_fn(q);
>>>> + if (!blk_queue_stopped(q) || blk_queue_dead(q))
>>>> + q->request_fn(q);
> I'm not sure if that behaviour is correct, i.e. we can call q->request_fn(q)
> if someone stoped queue, but if it is why not just call q->request_fn(q)
> from blk_drain_queue() instead?
As far as I can see invoking q->request_fn(q) directly from
blk_drain_queue() would be a valid alternative.
>
>>> So, this allows calling request_fn for dead && stopped queue. Have
>>> you seen something which requires this?
>> Not servicing queued SCSI requests can e.g. cause user space processes
>> to hang. See also http://lkml.org/lkml/2011/8/27/6 for an example. Hence
>> commit 3308511c93e6ad0d3c58984ecd6e5e57f96b12c8 which causes pending
>> SCSI commands to be killed just before blk_cleanup_queue() is invoked.
>> However, there is still a tiny race window left by that patch - new
>> requests can get queued after the SCSI request function has been invoked
>> by scsi_free_queue() and before blk_cleanup_queue() gets invoked. Hence
>> the proposal to change the block layer to make sure that all queued
>> requests get processed eventually.
> That behaviour I can confirm using this script [1] running with usb
> dongle. I applied this patch and second one:
> http://marc.info/?l=linux-scsi&m=133207725114386&w=2
> (BTW: second one patch is mangled). My impression is, that the script run
> much longer before it finally hung at infinite loop in blk_drain_queue().
I'm not an USB expert but I've had a quick look at
usb_stor_release_resources() in drivers/usb/storage/usb.c. As far as I
can see that function will only stop the usb_stor_control_thread() if
that thread has been scheduled after the last complete() call by the USB
queuecommand() function and before the complete() call in
usb_stor_release_resources() is executed. That looks like a race
condition to me.
Bart.
next prev parent reply other threads:[~2012-03-19 17:03 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-18 13:18 [PATCH] block: Make blk_drain_queue() work for stopped queues Bart Van Assche
2012-03-18 15:57 ` Tejun Heo
2012-03-18 19:47 ` Bart Van Assche
2012-03-19 7:26 ` Stanislaw Gruszka
2012-03-19 17:03 ` Bart Van Assche [this message]
[not found] ` <4F6766F0.1070805-HInyCGIudOg@public.gmane.org>
2012-03-20 14:21 ` Stanislaw Gruszka
2012-03-20 14:31 ` Alan Stern
2012-03-19 17:04 ` Tejun Heo
2012-03-19 17:22 ` Bart Van Assche
2012-03-20 20:04 ` Bart Van Assche
2012-03-20 20:06 ` Bart Van Assche
2012-03-20 21:01 ` Dan Williams
2012-03-21 3:37 ` Dan Williams
2012-03-21 18:35 ` Dan Williams
2012-03-24 18:49 ` 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=4F6766F0.1070805@acm.org \
--to=bvanassche@acm.org \
--cc=axboe@kernel.dk \
--cc=linux-scsi@vger.kernel.org \
--cc=sgruszka@redhat.com \
--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 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.