From: James Bottomley <James.Bottomley@HansenPartnership.com>
To: Tejun Heo <tj@kernel.org>
Cc: Steven Whitehouse <swhiteho@redhat.com>,
linux-kernel@vger.kernel.org, Jens Axboe <jaxboe@fusionio.com>
Subject: Re: Strange block/scsi/workqueue issue
Date: Wed, 13 Apr 2011 09:15:22 -0500 [thread overview]
Message-ID: <1302704122.2597.13.camel@mulgrave.site> (raw)
In-Reply-To: <20110413051139.GC24161@mtj.dyndns.org>
On Wed, 2011-04-13 at 14:11 +0900, Tejun Heo wrote:
> > > Hmmm... maybe but at least I prefer doing explicit shutdown/draining
> > > on destruction even if the base data structure is refcounted. Things
> > > become much more predictable that way.
> >
> > It is pretty much instantaneous. Unless we're executing, we cancel the
> > work. If the work is already running, we just let it complete instead
> > of waiting for it.
> >
> > Synchronous waits are dangerous because they cause entanglement.
>
> There are two different types of dangers involved. One is of getting
> trapped into deadlock by recursing and ending up waiting for oneself.
> The other of continuing operation on objects which could be in dubious
> state. I guess my point is that I prefer the former by a large
> margin.
>
> The deadlocks are more reliable in reproducibility. Lockdep and soft
> hang check can detect them easily and a single stack dump will point
> us right to where the problem is. The latter is much trickier.
I agree, but this is a bit of a false dichotomy. The hang will only
detect the thread waiting on itself. Even in the flush model, we still
have to detect inappropriate object use because others may still have
references.
So, in the sync model, on blk_cleanup_queue() you flush the pending
requests and destroy the elevator. However, because the queue is
refcounted, you still have to cope with the case where one of the
reference holders submits more I/O or does anything else with the queue.
This is what I don't like about the sync then shut down various bits
before the refcount goes to zero. Now we don't have a fully functional
queue so we need state guards on all the entry points to detect this and
error out (that's some of the QUEUE_FLAG_DEAD checks we put in in the
patch).
In the async model, you can either do as above (state guards on the
entry points) and impose a shutting down state, or you can delay
destruction until final put. The former is an identical solution to the
synchronous one, except that you don't have the flush. The latter loses
the state guard on entry points requirements (because the queue is
always fully functional until final put.
> The
> problem is more difficult to trigger and even when it triggers the
> effect often wouldn't be obvious. Auditing for correctness is more
> difficult too - which fields are safe to access post-mortem?
But in a refcounted model you always have to expect postmortem
operations ... you just have to make sure they're properly rejected.
This is true for both sync or async if you impose a dying or dead state
on the model.
> Is there
> any chance that the ongoing operation might reach out to hardware
> which is already gone or claimed by another software entity?
Yes ... in fact SCSI fully expects this ... that's why they dead queue
check in the SCSI request function using a NULL ->queuedata signal
(another thing that wasn't working quite right).
We tear down the device in scsi_remove_device() including destroying the
queue. If we go with the sync model for block, I'd actually move
blk_cleanup_queue() into that function. There's no real point delaying
queue destruction to final put of the SCSI object, since we won't accept
I/O after scsi_remove_device() returns.
> In this particular case, IMHO it's reasonable for block layer to
> require that the destruction function not to be called directly from
> request queue path although it definitely could have used better
> documentation.
I think we've both stated our cases, so it's time for Jens to decide
what he wants to do. Given that block already has a state model which
includes some QUEUE_FLAG_DEAD state guard checks, it probably makes
sense to enhance that, rather than to delay all destruction until final
put.
James
prev parent reply other threads:[~2011-04-13 14:15 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-11 14:56 Steven Whitehouse
2011-04-11 17:18 ` Tejun Heo
2011-04-11 17:29 ` Jens Axboe
2011-04-11 17:52 ` Steven Whitehouse
2011-04-12 0:14 ` Tejun Heo
2011-04-12 8:49 ` Steven Whitehouse
2011-04-12 0:47 ` James Bottomley
2011-04-12 2:51 ` Tejun Heo
2011-04-12 4:49 ` James Bottomley
2011-04-12 5:02 ` James Bottomley
2011-04-12 8:42 ` Steven Whitehouse
2011-04-12 13:42 ` James Bottomley
2011-04-12 14:06 ` Steven Whitehouse
2011-04-12 15:14 ` James Bottomley
2011-04-12 16:04 ` Steven Whitehouse
2011-04-12 16:27 ` James Bottomley
2011-04-12 16:51 ` Steven Whitehouse
2011-04-12 17:41 ` James Bottomley
2011-04-12 18:33 ` Steven Whitehouse
2011-04-12 19:56 ` James Bottomley
2011-04-12 20:30 ` Steven Whitehouse
2011-04-12 20:43 ` James Bottomley
2011-04-13 5:18 ` Tejun Heo
2011-04-13 6:06 ` Tejun Heo
2011-04-13 9:20 ` Steven Whitehouse
2011-04-13 14:00 ` Steven Whitehouse
2011-04-13 17:01 ` James Bottomley
2011-04-13 19:35 ` Steven Whitehouse
2011-04-13 20:12 ` Jens Axboe
2011-04-13 20:17 ` James Bottomley
2011-04-22 18:01 ` Tejun Heo
2011-04-22 18:06 ` James Bottomley
2011-04-22 18:30 ` Tejun Heo
2011-05-31 6:05 ` Anton V. Boyarshinov
2011-04-22 18:03 ` Tejun Heo
2011-04-12 5:15 ` Tejun Heo
2011-04-12 15:15 ` James Bottomley
2011-04-13 5:11 ` Tejun Heo
2011-04-13 14:15 ` James Bottomley [this message]
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=1302704122.2597.13.camel@mulgrave.site \
--to=james.bottomley@hansenpartnership.com \
--cc=jaxboe@fusionio.com \
--cc=linux-kernel@vger.kernel.org \
--cc=swhiteho@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®