public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: Filipe Manana <fdmanana@suse.com>,
	dsterba@suse.cz, Ming Lei <tom.leiming@gmail.com>
Cc: Liu Bo <bo.li.liu@oracle.com>, linux-block <linux-block@vger.kernel.org>
Subject: Re: [PATCH] block: note about cloned bios and bio_for_each_segment_all
Date: Fri, 14 Jul 2017 12:19:46 -0600	[thread overview]
Message-ID: <d10886f1-87b5-eff3-c1fa-99cb2d9407b2@kernel.dk> (raw)
In-Reply-To: <21cf4261-70b4-f7ee-5db3-9aece0e18a41@suse.com>

On 07/14/2017 11:56 AM, Filipe Manana wrote:
> 
> 
> On 07/14/2017 04:03 PM, David Sterba wrote:
>> On Fri, Jul 14, 2017 at 09:47:30PM +0800, Ming Lei wrote:
>>> On Fri, Jul 14, 2017 at 9:40 PM, David Sterba <dsterba@suse.com> wrote:
>>>> We've switched to cloned bios in btrfs and hit a nasty bug leading to
>>>> corruptions, when cloned bios are iterated by bio_for_each_segment_all.
>>>
>>> No, you simply can't use bio_for_each_segment_all on cloned bio, and the
>>> reason is obviously.
>>
>> This was not obvious to us, speaking for the btrfs developers trying to
>> make more use of the of the bio API, so we had to find out the hard way.
> 
> Yep, it might be obvious to those familiar with the block layer's
> internals, but for those not so familiar, it's not. There's no mention
> in bio_clone_fast() that the cloned bio's bi_vcnt shouldn't be used,
> and after finding that, one has to check which bio APIs use it and
> which don't. In this specific btrfs issue, it lead to silent write
> corruptions, making it harder to find (as opposed to crashes or other
> immediate failures).

It's hard to circulate info like that, but the WARN_ON() should have
been there from the get-go. I just need someone to test that patch
triggers for the problematic case, then I'd be happy to get it queued
up.

-- 
Jens Axboe

      reply	other threads:[~2017-07-14 18:19 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-14 13:40 [PATCH] block: note about cloned bios and bio_for_each_segment_all David Sterba
2017-07-14 13:47 ` Ming Lei
2017-07-14 14:22   ` Jens Axboe
2017-07-14 20:54     ` Liu Bo
2017-07-14 22:35       ` Ming Lei
2017-07-14 22:37         ` Jens Axboe
2017-07-14 23:20         ` Liu Bo
2017-07-18 22:19       ` Bart Van Assche
2017-07-24 16:19         ` Peter Zijlstra
2017-07-15  0:28     ` David Sterba
2017-07-14 15:03   ` David Sterba
2017-07-14 17:56     ` Filipe Manana
2017-07-14 18:19       ` Jens Axboe [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=d10886f1-87b5-eff3-c1fa-99cb2d9407b2@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=bo.li.liu@oracle.com \
    --cc=dsterba@suse.cz \
    --cc=fdmanana@suse.com \
    --cc=linux-block@vger.kernel.org \
    --cc=tom.leiming@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox