mirror of
https://github.com/kdave/btrfs-progs
synced 2025-02-19 03:06:50 +00:00
btrfs-progs: check: output proper csum values for --check-data-csum
[BUG] When running "btrfs check --check-data-csum" on fs with corrupted data, the error message almost makes no sense: $ btrfs check --check-data-csum /dev/test/test Opening filesystem to check... Checking filesystem on /dev/test/test UUID: c31afe0a-55bc-4e7d-aba0-9dfa9ddf8090 [1/7] checking root items [2/7] checking extents [3/7] checking free space cache [4/7] checking fs roots [5/7] checking csums against data mirror 1 bytenr 13631488 csum 19 expected csum 152 <<< ERROR: errors found in csum tree [6/7] checking root refs [7/7] checking quota groups skipped (not enabled on this FS) found 147456 bytes used, error(s) found total csum bytes: 16 total tree bytes: 131072 total fs tree bytes: 32768 total extent tree bytes: 16384 btree space waste bytes: 124799 file data blocks allocated: 16384 referenced 16384 [CAUSE] We're just outputting the first byte and in decimal, which is completely different from what we did in kernel space, nor what we did for metadata csum mismatch. [FIX] Use btrfs_format_csum() for btrfs-check to output csum. Now the result looks much better: [5/7] checking csums against data mirror 1 bytenr 13631488 csum 0x13fec125 expected csum 0x98757625 Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
773afad3e6
commit
325dba6432
12
check/main.c
12
check/main.c
@ -5812,12 +5812,16 @@ static int check_extent_csums(struct btrfs_root *root, u64 bytenr,
|
||||
read_extent_buffer(eb, (char *)&csum_expected,
|
||||
csum_offset, csum_size);
|
||||
if (memcmp(result, csum_expected, csum_size) != 0) {
|
||||
char found[BTRFS_CSUM_STRING_LEN];
|
||||
char want[BTRFS_CSUM_STRING_LEN];
|
||||
|
||||
csum_mismatch = true;
|
||||
/* FIXME: format of the checksum value */
|
||||
btrfs_format_csum(csum_type, result, found);
|
||||
btrfs_format_csum(csum_type,
|
||||
csum_expected, want);
|
||||
fprintf(stderr,
|
||||
"mirror %d bytenr %llu csum %u expected csum %u\n",
|
||||
mirror, bytenr + tmp,
|
||||
result[0], csum_expected[0]);
|
||||
"mirror %d bytenr %llu csum %s expected csum %s\n",
|
||||
mirror, bytenr + tmp, found, want);
|
||||
}
|
||||
data_checked += gfs_info->sectorsize;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user