btrfs-progs: check: check main csum root if csum not in log tree

Fixes false positive in btrfs check that was causing btrfs/192 to fail.

It looks like there's circumstances in which btrfs_log_changed_extents
can also log unmodified extents, but not their csums. If that happens,
check the main csum root as well before showing an error.

Signed-off-by: Mark Harmstone <maharmstone@fb.com>
This commit is contained in:
Mark Harmstone 2024-10-07 11:55:16 +01:00 committed by Qu Wenruo
parent 175cbfc5a2
commit 6c7d2a323c
1 changed files with 11 additions and 2 deletions

View File

@ -9681,7 +9681,7 @@ static int zero_log_tree(struct btrfs_root *root)
return ret;
}
static int check_log_csum(struct btrfs_root *root, u64 addr, u64 length)
static int check_range_csummed(struct btrfs_root *root, u64 addr, u64 length)
{
struct btrfs_path path = { 0 };
struct btrfs_key key = {
@ -9816,12 +9816,21 @@ static int check_log_root(struct btrfs_root *root, struct cache_tree *root_cache
length = btrfs_file_extent_num_bytes(leaf, fi);
}
ret = check_log_csum(root, addr, length);
ret = check_range_csummed(root, addr, length);
if (ret < 0) {
err = 1;
break;
}
if (ret) {
ret = check_range_csummed(btrfs_csum_root(gfs_info, 0),
addr, length);
if (ret < 0) {
err = 1;
break;
}
}
if (ret) {
error(
"csum missing in log (root %llu inode %llu offset %llu address 0x%llx length %llu)",