btrfs: handle unexpected free-space-tree key types

Replace the conditional assertions with proper error handling and
transaction abort if we find an unexpected key type in the free space
tree.

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba
2026-04-21 04:02:02 +02:00
parent 999757231c
commit 4d95b9efd7
+15 -3
View File
@@ -259,7 +259,11 @@ int btrfs_convert_free_space_to_bitmaps(struct btrfs_trans_handle *trans,
nr++;
path->slots[0]--;
} else {
ASSERT(0);
btrfs_err(fs_info, "unexpected free space tree key type %u",
found_key.type);
ret = -EUCLEAN;
btrfs_abort_transaction(trans, ret);
goto out;
}
}
@@ -405,7 +409,11 @@ int btrfs_convert_free_space_to_extents(struct btrfs_trans_handle *trans,
nr++;
} else {
ASSERT(0);
btrfs_err(fs_info, "unexpected free space tree key type %u",
found_key.type);
ret = -EUCLEAN;
btrfs_abort_transaction(trans, ret);
goto out;
}
}
@@ -1518,7 +1526,11 @@ int btrfs_remove_block_group_free_space(struct btrfs_trans_handle *trans,
nr++;
path->slots[0]--;
} else {
ASSERT(0);
btrfs_err(trans->fs_info, "unexpected free space tree key type %u",
found_key.type);
ret = -EUCLEAN;
btrfs_abort_transaction(trans, ret);
return ret;
}
}