From: "Edmund Nadolski (Microsoft)" <edmund.f.nadolski@gmail.com>
To: Hannes Reinecke <hare@suse.de>, Ming Lei <ming.lei@redhat.com>
Cc: Jens Axboe <axboe@kernel.dk>, Hannes Reinecke <hare@suse.com>,
Bart van Assche <bvanassche@acm.org>,
Ming Lei <ming.lei@gmail.com>,
neilb@suse.com, linux-nvme@lists.infradead.org,
linux-block@vger.kernel.org, Christoph Hellwig <hch@lst.de>
Subject: Re: [PATCH] block: use static bio_set for bio_split() calls
Date: Thu, 18 Apr 2019 11:26:26 -0700 [thread overview]
Message-ID: <532b6027-3bc9-def3-0fd8-2b6f32c4463b@gmail.com> (raw)
In-Reply-To: <28f8343f-3159-9ca2-f98f-a37ecce31fd5@suse.de>
On 4/18/19 8:02 AM, Hannes Reinecke wrote:
> On 4/18/19 4:34 PM, Ming Lei wrote:
>> Hi Hannes,
>>
>> On Thu, Apr 18, 2019 at 04:06:32PM +0200, Hannes Reinecke wrote:
>>> When calling blk_queue_split() it will be using the per-queue
>>> bioset to allocate the split bio from. However, blk_steal_bios()
>>> might move the bio to another queue, _and_ the original queue
>>> might be removed completely (nvme is especially prone to do so).
>>
>> Could you explain a bit how the original queue is removed in case
>> that blk_steal_bios() is involved?
>>
> It's not blk_steal_bios() which removes the queue. What happens is:
>
> - bio returns with error
> - blk_steal_bios() moves bio over to a different queue
> - nvme_reset_ctrl() is called
> - Error detection finds that the original device is gone
> - nvme calls nvme_remove_ns()
> - nvme_remove_ns() removes the original request queue alongside the
> bio_set from which the bvecs have been allocated from.
> - 'stolen' bio is completed
> - 'stolen' bio calls bio_endio()
> - bio_endio() calls mempool_free() on the bvecs, referencing the mempool
> from the original queue
> - crash
>
>>> That leaves the bvecs of the split bio with a missing / destroyed
>>> mempool, and a really fun crash in bio_endio().
>>
>> per-queue bioset is used originally for avoiding deadlock, are you
>> sure the static bioset is safe?
>>
> If that turns out be be an issue we could be having a per 'ns_head'
> bio_set for allocating the split bio from.
> But the main point is that we cannot use the bioset from the request
> queue as the queue (and the bioset) might be removed during the lifetime
> of the bio.
Does this mean that as-is, this is safe because nvme (currently) is the
only consumer of blk_steal_bios()?
(Sorry if this is a lame question, I'm in the process of learning this
code.)
TIA,
Ed
WARNING: multiple messages have this Message-ID (diff)
From: edmund.f.nadolski@gmail.com (Edmund Nadolski (Microsoft))
Subject: [PATCH] block: use static bio_set for bio_split() calls
Date: Thu, 18 Apr 2019 11:26:26 -0700 [thread overview]
Message-ID: <532b6027-3bc9-def3-0fd8-2b6f32c4463b@gmail.com> (raw)
In-Reply-To: <28f8343f-3159-9ca2-f98f-a37ecce31fd5@suse.de>
On 4/18/19 8:02 AM, Hannes Reinecke wrote:
> On 4/18/19 4:34 PM, Ming Lei wrote:
>> Hi Hannes,
>>
>> On Thu, Apr 18, 2019@04:06:32PM +0200, Hannes Reinecke wrote:
>>> When calling blk_queue_split() it will be using the per-queue
>>> bioset to allocate the split bio from. However, blk_steal_bios()
>>> might move the bio to another queue, _and_ the original queue
>>> might be removed completely (nvme is especially prone to do so).
>>
>> Could you explain a bit how the original queue is removed in case
>> that blk_steal_bios() is involved?
>>
> It's not blk_steal_bios() which removes the queue. What happens is:
>
> - bio returns with error
> - blk_steal_bios() moves bio over to a different queue
> - nvme_reset_ctrl() is called
> - Error detection finds that the original device is gone
> - nvme calls nvme_remove_ns()
> - nvme_remove_ns() removes the original request queue alongside the
> bio_set from which the bvecs have been allocated from.
> - 'stolen' bio is completed
> - 'stolen' bio calls bio_endio()
> - bio_endio() calls mempool_free() on the bvecs, referencing the mempool
> from the original queue
> - crash
>
>>> That leaves the bvecs of the split bio with a missing / destroyed
>>> mempool, and a really fun crash in bio_endio().
>>
>> per-queue bioset is used originally for avoiding deadlock, are you
>> sure the static bioset is safe?
>>
> If that turns out be be an issue we could be having a per 'ns_head'
> bio_set for allocating the split bio from.
> But the main point is that we cannot use the bioset from the request
> queue as the queue (and the bioset) might be removed during the lifetime
> of the bio.
Does this mean that as-is, this is safe because nvme (currently) is the
only consumer of blk_steal_bios()?
(Sorry if this is a lame question, I'm in the process of learning this
code.)
TIA,
Ed
next prev parent reply other threads:[~2019-04-18 18:26 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-18 14:06 [PATCH] block: use static bio_set for bio_split() calls Hannes Reinecke
2019-04-18 14:06 ` Hannes Reinecke
2019-04-18 14:34 ` Ming Lei
2019-04-18 14:34 ` Ming Lei
2019-04-18 15:02 ` Hannes Reinecke
2019-04-18 15:02 ` Hannes Reinecke
2019-04-18 18:26 ` Edmund Nadolski (Microsoft) [this message]
2019-04-18 18:26 ` Edmund Nadolski (Microsoft)
2019-04-24 17:20 ` Sagi Grimberg
2019-04-24 17:20 ` Sagi Grimberg
2019-04-24 18:56 ` Hannes Reinecke
2019-04-24 18:56 ` Hannes Reinecke
2019-04-24 18:58 ` Sagi Grimberg
2019-04-24 18:58 ` Sagi Grimberg
2019-04-24 22:14 ` Ming Lei
2019-04-24 22:14 ` Ming Lei
2019-04-25 0:41 ` Ming Lei
2019-04-25 0:41 ` Ming Lei
2019-04-25 14:32 ` Hannes Reinecke
2019-04-25 14:32 ` Hannes Reinecke
2019-04-25 15:36 ` Ming Lei
2019-04-25 15:36 ` Ming Lei
2019-04-30 11:48 ` Hannes Reinecke
2019-04-30 11:48 ` Hannes Reinecke
2019-04-24 19:49 ` Bart Van Assche
2019-04-24 19:49 ` Bart Van Assche
2019-04-25 6:06 ` Hannes Reinecke
2019-04-25 6:06 ` Hannes Reinecke
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=532b6027-3bc9-def3-0fd8-2b6f32c4463b@gmail.com \
--to=edmund.f.nadolski@gmail.com \
--cc=axboe@kernel.dk \
--cc=bvanassche@acm.org \
--cc=hare@suse.com \
--cc=hare@suse.de \
--cc=hch@lst.de \
--cc=linux-block@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=ming.lei@gmail.com \
--cc=ming.lei@redhat.com \
--cc=neilb@suse.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.