From a4587ebf88978be9625bf5652ee73e5672d169ac Mon Sep 17 00:00:00 2001 From: Mark Harmstone Date: Mon, 7 Oct 2024 11:55:16 +0100 Subject: [PATCH] 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 --- check/main.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/check/main.c b/check/main.c index f7209b48..873a5d04 100644 --- a/check/main.c +++ b/check/main.c @@ -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)",