Skip to contentSkip to conversation

btrfs: fix missing fields in superblock backup with BLOCK_GROUP_TREE

PATCH In review Mark Harmstone 2 participants 2 messages Jan 13 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs: fix missing fields in superblock backup with BLOCK_GROUP_TREE

When the BLOCK_GROUP_TREE compat_ro flag is set, the extent root and csum root fields are getting missed.

This is because EXTENT_TREE_V2 treated these differently, and when they were split off this special-casing was mistakenly assigned to BGT rather than the rump EXTENT_TREE_V2. There's no reason why the existence of the block group tree should mean that we don't record the details of the last commit's extent root and csum root.

Fix the code in backup_super_roots() so that the correct check gets made.

Fixes 1c56ab991903 ("btrfs: separate BLOCK_GROUP_TREE compat RO flag from EXTENT_TREE_V2")
---
 fs/btrfs/disk-io.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/disk-io.c +1 -1
index 0491b799148f..54c4496c30d7 100644
@@ -1650,7 +1650,7 @@ static void backup_super_roots(struct btrfs_fs_info *info)
 	btrfs_set_backup_chunk_root_level(root_backup,
 			       btrfs_header_level(info->chunk_root->node));
 
-	if (!btrfs_fs_compat_ro(info, BLOCK_GROUP_TREE)) {
+	if (!btrfs_fs_incompat(info, EXTENT_TREE_V2)) {
 		struct btrfs_root *extent_root = btrfs_extent_root(info, 0);
 		struct btrfs_root *csum_root = btrfs_csum_root(info, 0);
 
Signature · 1 line
2.51.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Mark Harmstone

When the BLOCK_GROUP_TREE compat_ro flag is set, the extent root and csum root fields are getting missed.

This is because EXTENT_TREE_V2 treated these differently, and when they were split off this special-casing was mistakenly assigned to BGT rather than the rump EXTENT_TREE_V2. There's no reason why the existence of the block group tree should mean that we don't record the details of the last commit's extent root and csum root.

Quoted 5 lines

Fix the code in backup_super_roots() so that the correct check gets made.

Fixes 1c56ab991903 ("btrfs: separate BLOCK_GROUP_TREE compat RO flag from EXTENT_TREE_V2")

Thanks,
Qu

Quoted 17 lines
---
  fs/btrfs/disk-io.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/disk-io.c +1 -1
index 0491b799148f..54c4496c30d7 100644
@@ -1650,7 +1650,7 @@ static void backup_super_roots(struct btrfs_fs_info *info)
  	btrfs_set_backup_chunk_root_level(root_backup,
  			       btrfs_header_level(info->chunk_root->node));
 
-	if (!btrfs_fs_compat_ro(info, BLOCK_GROUP_TREE)) {
+	if (!btrfs_fs_incompat(info, EXTENT_TREE_V2)) {
  		struct btrfs_root *extent_root = btrfs_extent_root(info, 0);
  		struct btrfs_root *csum_root = btrfs_csum_root(info, 0);