From: fdmanana@kernel.org
To: linux-btrfs@vger.kernel.org
Subject: [PATCH 5/5] btrfs: add comment about list_is_singular() use at btrfs_delete_unused_bgs()
Date: Thu, 25 Jan 2024 10:26:28 +0000 [thread overview]
Message-ID: <fdc5a0a2cf0240c02c56521332a48409be65b326.1706177914.git.fdmanana@suse.com> (raw)
In-Reply-To: <cover.1706177914.git.fdmanana@suse.com>
From: Filipe Manana <fdmanana@suse.com>
At btrfs_delete_unused_bgs(), the use of the list_is_singular() check on
a block group may not be immediately obvious. It is there to prevent
losing raid profile information for a block group type (data, metadata or
system), as that information is removed from
fs_info->avail_[data|metadata|system]_alloc_bits when the last block group
of a given type is deleted. So deleting the block group would later result
in creating block groups of that type with a single profile (because
fs_info->avail_*_alloc_bits would have a value of 0).
This check was added in commit aefbe9a633b5 ("btrfs: Fix lost-data-profile
caused by auto removing bg").
So add a comment mentioning the need for the check.
Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
fs/btrfs/block-group.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c
index 378d9103a207..2dc39e8db995 100644
--- a/fs/btrfs/block-group.c
+++ b/fs/btrfs/block-group.c
@@ -1522,6 +1522,13 @@ void btrfs_delete_unused_bgs(struct btrfs_fs_info *fs_info)
* outstanding allocations in this block group. We do
* the ro check in case balance is currently acting on
* this block group.
+ *
+ * Also bail out if this is the only block group for its
+ * type, because otherwise we would lose profile
+ * information from fs_info->avail_*_alloc_bits and the
+ * next block group of this type would be created with a
+ * "single" profile (even if we're in a raid fs) because
+ * fs_info->avail_*_alloc_bits would be 0.
*/
trace_btrfs_skip_unused_block_group(block_group);
spin_unlock(&block_group->lock);
--
2.40.1
next prev parent reply other threads:[~2024-01-25 10:26 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-25 10:26 [PATCH 0/5] btrfs: some fixes around unused block deletion fdmanana
2024-01-25 10:26 ` [PATCH 1/5] btrfs: add and use helper to check if block group is used fdmanana
2024-01-25 10:26 ` [PATCH 2/5] btrfs: do not delete unused block group if it may be used soon fdmanana
2024-01-25 10:26 ` [PATCH 3/5] btrfs: add new unused block groups to the list of unused block groups fdmanana
2024-01-25 10:26 ` [PATCH 4/5] btrfs: document what the spinlock unused_bgs_lock protects fdmanana
2024-01-25 10:26 ` fdmanana [this message]
2024-01-25 15:16 ` [PATCH 0/5] btrfs: some fixes around unused block deletion Johannes Thumshirn
2024-01-25 20:57 ` Josef Bacik
2024-01-25 21:32 ` Boris Burkov
2024-01-27 21:39 ` Ivan Shapovalov
2024-01-29 12:49 ` Filipe Manana
2024-01-29 17:56 ` Ivan Shapovalov
2024-01-29 20:28 ` Filipe Manana
2024-02-02 0:52 ` Ivan Shapovalov
2024-02-02 16:48 ` Filipe Manana
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=fdc5a0a2cf0240c02c56521332a48409be65b326.1706177914.git.fdmanana@suse.com \
--to=fdmanana@kernel.org \
--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 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).