Skip to content

Commit 1383cda

Browse files
andriytkixhamza
authored andcommitted
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 <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Alexander Motin <[email protected]> Closes openzfs#17547
1 parent 010893b commit 1383cda

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

cmd/zdb/zdb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9120,7 +9120,7 @@ zdb_read_block(char *thing, spa_t *spa)
91209120
ck_zio->io_offset =
91219121
DVA_GET_OFFSET(&bp->blk_dva[0]);
91229122
ck_zio->io_bp = bp;
9123-
zio_checksum_compute(ck_zio, ck, pabd, lsize);
9123+
zio_checksum_compute(ck_zio, ck, pabd, psize);
91249124
printf(
91259125
"%12s\t"
91269126
"cksum=%016llx:%016llx:%016llx:%016llx\n",

0 commit comments

Comments
 (0)