diff mbox series

[v2,06/15] btrfs-progs: check: update block group used properly for extent tree v2

Message ID a2bed9aba2b557ef349ce04082a75d18bd396219.1646691128.git.josef@toxicpanda.com (mailing list archive)
State New, archived
Headers show
Series btrfs-progs: extent tree v2 gc tree and metadata ref changes | expand

Commit Message

Josef Bacik March 7, 2022, 10:13 p.m. UTC
For extent tree v2 we do not have metadata tracked in the extent root,
so every block we find we must account for as used in the appropriate
block group.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 check/main.c | 8 ++++++++
 1 file changed, 8 insertions(+)
diff mbox series

Patch

diff --git a/check/main.c b/check/main.c
index 5fb765c5..aab6b3a0 100644
--- a/check/main.c
+++ b/check/main.c
@@ -6425,6 +6425,14 @@  static int run_next_block(struct btrfs_root *root,
 	if (ret)
 		goto out;
 
+	/*
+	 * Extent tree v2 doesn't track metadata in the extent tree, mark any
+	 * blocks we find as used for the block group.
+	 */
+	if (btrfs_fs_incompat(gfs_info, EXTENT_TREE_V2))
+		update_block_group_used(block_group_cache, buf->start,
+					gfs_info->nodesize);
+
 	if (btrfs_is_leaf(buf)) {
 		btree_space_waste += btrfs_leaf_free_space(buf);
 		for (i = 0; i < nritems; i++) {