Fix incorrect checksums for small initial writes in the old store
Details: - Write size should be exactly csum_block_size (4k by default) - Write should be made into a new object (unallocated space) - In this case, the checksum of the block was calculated as if the block was padded with extra (2^32 - size) zero bytes due to a simple integer overflow - As a cherry on the cake, such calculation was 'slightly' slow because it was processing almost 4 GB of zeroes for a small write
This commit is contained in:
@@ -183,7 +183,7 @@ bool blockstore_impl_t::enqueue_write(blockstore_op_t *op)
|
||||
uint32_t end = (op->offset+op->len-1) / dsk.csum_block_size;
|
||||
auto fn = state & BS_ST_BIG_WRITE ? crc32c_pad : crc32c_nopad;
|
||||
if (start == end)
|
||||
data_csums[0] = fn(0, op->buf, op->len, op->offset - start*dsk.csum_block_size, end*dsk.csum_block_size - (op->offset+op->len));
|
||||
data_csums[0] = fn(0, op->buf, op->len, op->offset - start*dsk.csum_block_size, (end+1)*dsk.csum_block_size - (op->offset+op->len));
|
||||
else
|
||||
{
|
||||
// First block
|
||||
|
||||
Reference in New Issue
Block a user