All of lore.kernel.org
 help / color / mirror / Atom feed
From: Boris Burkov <boris@bur.io>
To: linux-btrfs@vger.kernel.org, kernel-team@fb.com
Subject: [PATCH v7 03/12] btrfs: only mark bg->needs_free_space if free space tree is on
Date: Wed, 18 Nov 2020 15:06:18 -0800	[thread overview]
Message-ID: <c821817babc7501e53657501c5803157924fcb4e.1605736355.git.boris@bur.io> (raw)
In-Reply-To: <cover.1605736355.git.boris@bur.io>

If we attempt to create a free space tree while any block groups have
needs_free_space set, we will double add the new free space item
and hit EEXIST. Previously, we only created the free space tree on a new
mount, so we never hit the case, but if we try to create it on a
remount, such block groups could exist and trip us up.

We don't do anything with this field unless the free space tree is
enabled, so there is no harm in not setting it.

Signed-off-by: Boris Burkov <boris@bur.io>
---
 fs/btrfs/block-group.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c
index ccc3271c20ca..00e2fe1d0f32 100644
--- a/fs/btrfs/block-group.c
+++ b/fs/btrfs/block-group.c
@@ -2156,7 +2156,8 @@ int btrfs_make_block_group(struct btrfs_trans_handle *trans, u64 bytes_used,
 	cache->flags = type;
 	cache->last_byte_to_unpin = (u64)-1;
 	cache->cached = BTRFS_CACHE_FINISHED;
-	cache->needs_free_space = 1;
+	if (btrfs_fs_compat_ro(fs_info, FREE_SPACE_TREE))
+		cache->needs_free_space = 1;
 	ret = exclude_super_stripes(cache);
 	if (ret) {
 		/* We may have excluded something, so call this just in case */
-- 
2.24.1


  parent reply	other threads:[~2020-11-18 23:06 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-18 23:06 [PATCH v7 00/10] btrfs: free space tree mounting fixes Boris Burkov
2020-11-18 23:06 ` [PATCH v7 01/12] btrfs: lift rw mount setup from mount and remount Boris Burkov
2020-11-23 16:50   ` David Sterba
2020-11-30 23:31     ` Boris Burkov
2020-12-15 18:01       ` David Sterba
2020-11-23 16:57   ` David Sterba
2020-12-01  0:01     ` Boris Burkov
2020-12-15 17:50       ` David Sterba
2020-11-18 23:06 ` [PATCH v7 02/12] btrfs: cleanup all orphan inodes on ro->rw remount Boris Burkov
2020-11-18 23:06 ` Boris Burkov [this message]
2020-11-18 23:06 ` [PATCH v7 04/12] btrfs: create free space tree " Boris Burkov
2020-11-18 23:06 ` [PATCH v7 05/12] btrfs: clear oneshot options on mount and remount Boris Burkov
2020-11-18 23:06 ` [PATCH v7 06/12] btrfs: clear free space tree on ro->rw remount Boris Burkov
2020-11-30 19:49   ` David Sterba
2020-11-18 23:06 ` [PATCH v7 07/12] btrfs: keep sb cache_generation consistent with space_cache Boris Burkov
2020-11-18 23:06 ` [PATCH v7 08/12] btrfs: use sb state to print space_cache mount option Boris Burkov
2020-11-18 23:06 ` [PATCH v7 09/12] btrfs: warn when remount will not change the free space tree Boris Burkov
2020-11-30 20:05   ` David Sterba
2020-11-18 23:06 ` [PATCH v7 10/12] btrfs: remove free space items when disabling space cache v1 Boris Burkov
2020-11-18 23:06 ` [PATCH v7 11/12] btrfs: skip space_cache v1 setup when not using it Boris Burkov
2020-11-18 23:06 ` [PATCH v7 12/12] btrfs: fix lockdep error creating free space tree Boris Burkov
2020-11-20 21:32 ` [PATCH v7 00/10] btrfs: free space tree mounting fixes David Sterba
2020-11-30 18:24   ` Boris Burkov
2020-11-30 20:29     ` David Sterba
2020-11-30 20:33 ` David Sterba

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=c821817babc7501e53657501c5803157924fcb4e.1605736355.git.boris@bur.io \
    --to=boris@bur.io \
    --cc=kernel-team@fb.com \
    --cc=linux-btrfs@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.