From 4bd7a2eaa587cf2e408af020dddcfdc79f8d3431 Mon Sep 17 00:00:00 2001 From: Andriy Tkachuk Date: Fri, 25 Jul 2025 02:24:15 +0100 Subject: [PATCH] zdb: fix checksum calculation for decompressed blocks Currently, when reading compressed blocks with -R and decompressing them with :d option and specifying lsize, which is normally bigger than psize for compressed blocks, the checksum is calculated on decompressed data. But it makes no sense since zfs always calculates checksum on physical, i.e. compressed data. So reading the same block produces different checksum results depending on how we read it, whether we decompress it or not, which, again, makes no sense. Fix: use psize instead of lsize when calculating the checksum so that it is always calculated on the physical block size, no matter was it compressed or not. Signed-off-by: Andriy Tkachuk Reviewed-by: Brian Behlendorf Reviewed-by: Alexander Motin Closes #17547 --- cmd/zdb/zdb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/zdb/zdb.c b/cmd/zdb/zdb.c index 6a4865899..06b286704 100644 --- a/cmd/zdb/zdb.c +++ b/cmd/zdb/zdb.c @@ -9138,7 +9138,7 @@ zdb_read_block(char *thing, spa_t *spa) ck_zio->io_offset = DVA_GET_OFFSET(&bp->blk_dva[0]); ck_zio->io_bp = bp; - zio_checksum_compute(ck_zio, ck, pabd, lsize); + zio_checksum_compute(ck_zio, ck, pabd, psize); printf( "%12s\t" "cksum=%016llx:%016llx:%016llx:%016llx\n",