linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chris Mason <clm@fb.com>
To: Filipe Manana <fdmanana@suse.com>, <linux-btrfs@vger.kernel.org>
Cc: <stable@vger.kernel.org>
Subject: Re: [PATCH] Btrfs: fix csum tree corruption, duplicate and outdated checksums
Date: Sat, 9 Aug 2014 16:25:26 -0400	[thread overview]
Message-ID: <53E683B6.6080400@fb.com> (raw)
In-Reply-To: <1407615747-12949-1-git-send-email-fdmanana@suse.com>



On 08/09/2014 04:22 PM, Filipe Manana wrote:
> Under rare circumstances we can end up leaving 2 versions of a checksum
> for the same file extent range.
> 
> The reason for this is that after calling btrfs_next_leaf we process
> slot 0 of the leaf it returns, instead of processing the slot set in
> path->slots[0]. Most of the time (by far) path->slots[0] is 0, but after
> btrfs_next_leaf() releases the path and before it searches for the next
> leaf, another task might cause a split of the next leaf, which migrates
> some of its keys to the leaf we were processing before calling
> btrfs_next_leaf(). In this case btrfs_next_leaf() returns again the
> same leaf but with path->slots[0] having a slot number corresponding
> to the first new key it got, that is, a slot number that didn't exist
> before calling btrfs_next_leaf(), as the leaf now has more keys than
> it had before. So we must really process the returned leaf starting at
> path->slots[0] always, as it isn't always 0, and the key at slot 0 can
> have an offset much lower than our search offset/bytenr.

And the bug goes all the way back to 2007.  I'd like to blame Yan Zheng,
but it was in my original code too.

Great find and explanation, I've added this to my merge window pull.
Thanks!

-chris

      parent reply	other threads:[~2014-08-09 20:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-09 20:22 [PATCH] Btrfs: fix csum tree corruption, duplicate and outdated checksums Filipe Manana
2014-08-09 19:40 ` Josef Bacik
2014-08-09 20:10 ` Marc MERLIN
2014-08-09 20:25 ` Chris Mason [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=53E683B6.6080400@fb.com \
    --to=clm@fb.com \
    --cc=fdmanana@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=stable@vger.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;
as well as URLs for NNTP newsgroup(s).