All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: Josef Bacik <josef@toxicpanda.com>
Cc: linux-btrfs@vger.kernel.org, kernel-team@fb.com, stable@vger.kernel.org
Subject: Re: [PATCH v2] btrfs: fix possible free space tree corruption with online conversion
Date: Tue, 15 Dec 2020 17:49:40 +0100	[thread overview]
Message-ID: <20201215164940.GW6430@twin.jikos.cz> (raw)
In-Reply-To: <e5f7fe3ad3a612efeda53f016904aff332db6f8a.1607610739.git.josef@toxicpanda.com>

On Thu, Dec 10, 2020 at 09:32:31AM -0500, Josef Bacik wrote:
> While running btrfs/011 in a loop I would often ASSERT() while trying to
> add a new free space entry that already existed, or get an -EEXIST while
> adding a new block to the extent tree, which is another indication of
> double allocation.

Do you have the stack traces? I'll update the changelog if you send it.

> This occurs because when we do the free space tree population, we create
> the new root and then populate the tree and commit the transaction.
> The problem is when you create a new root, the root node and commit root
> node are the same.  This means that caching a block group before the
> transaction is committed can race with other operations modifying the
> free space tree, and thus you can get double adds and other sort of
> shenanigans.  This is only a problem for the first transaction, once
> we've committed the transaction we created the free space tree in we're
> OK to use the free space tree to cache block groups.
> 
> Fix this by marking the fs_info as unsafe to load the free space tree,
> and fall back on the old slow method.  We could be smarter than this,
> for example caching the block group while we're populating the free
> space tree, but since this is a serious problem I've opted for the
> simplest solution.

Makes sense, this is a one-time thing during setup.

> cc: stable@vger.kernel.org

CC: stable@vger.kernel.org

If you send patch with the tag it's good to also note the minimal
version where it's relevant as you can easily reuse the knowledge from
developing the fix. The patch may not apply due to other changes, but
trivial context fixups are done by people interested in the backports.

> Fixes: a5ed91828518 ("Btrfs: implement the free space B-tree")

So if you know the offending commit, run

  $ git describe --contains a5ed91828518
  v4.5-rc1~21^2~22^2^2~3

which is 4.9.

      parent reply	other threads:[~2020-12-15 16:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-10 14:32 [PATCH v2] btrfs: fix possible free space tree corruption with online conversion Josef Bacik
2020-12-11 10:22 ` Filipe Manana
2020-12-15 16:49 ` David Sterba [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=20201215164940.GW6430@twin.jikos.cz \
    --to=dsterba@suse.cz \
    --cc=josef@toxicpanda.com \
    --cc=kernel-team@fb.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 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.