Fix false-positive -EDOM checksum errors on overlapping unaligned reads #79

Closed
changwei.ye wants to merge 1 commits from changwei.ye/vitastor:fix-intent-write-corruption into master
Contributor

Description

Fix false-positive -EDOM checksum errors on overlapping unaligned reads

When csum_block_size > bitmap_granularity and perfect_csum_update = false
(the default behavior), an unaligned INTENT_WRITE modifies the physical
block directly in-place without recalculating and updating the large
block's checksum.

During a subsequent read that requires padding to the checksum block
boundary (e.g., reading adjacent unaligned data), the read logic must
skip checksum verification for the underlying BIG_WRITE because the
physical data has been safely tampered with by the INTENT_WRITE.

Previously, the need_skip logic in blockstore_read.cpp correctly
identified and skipped the verification for overlapping SMALL_WRITEs
but mistakenly omitted INTENT_WRITEs. This caused the padded read to
verify the stale BIG_WRITE checksum against the newly modified physical
data, leading to a fatal false-positive -EDOM (checksum mismatch) IO
error on reads.

This commit fixes the bug by ensuring BS_HEAP_INTENT_WRITE is evaluated
alongside SMALL_WRITE to apply the COPY_BUF_SKIP_CSUM bypass during
overlapping padded reads.

A regression test case (test_intent_write_corruption) is also added to
reproduce this specific data-layout scenario and verify the fix.

Contributor Name

Changwei Ye

CLA

### Description Fix false-positive -EDOM checksum errors on overlapping unaligned reads When csum_block_size > bitmap_granularity and perfect_csum_update = false (the default behavior), an unaligned INTENT_WRITE modifies the physical block directly in-place without recalculating and updating the large block's checksum. During a subsequent read that requires padding to the checksum block boundary (e.g., reading adjacent unaligned data), the read logic must skip checksum verification for the underlying BIG_WRITE because the physical data has been safely tampered with by the INTENT_WRITE. Previously, the need_skip logic in blockstore_read.cpp correctly identified and skipped the verification for overlapping SMALL_WRITEs but mistakenly omitted INTENT_WRITEs. This caused the padded read to verify the stale BIG_WRITE checksum against the newly modified physical data, leading to a fatal false-positive -EDOM (checksum mismatch) IO error on reads. This commit fixes the bug by ensuring BS_HEAP_INTENT_WRITE is evaluated alongside SMALL_WRITE to apply the COPY_BUF_SKIP_CSUM bypass during overlapping padded reads. A regression test case (test_intent_write_corruption) is also added to reproduce this specific data-layout scenario and verify the fix. ### Contributor Name Changwei Ye ### CLA - [x] I accept Vitastor CLA agreement: https://git.yourcmc.ru/vitalif/vitastor/src/branch/master/CLA-en.md
changwei.ye added 1 commit 2026-08-28 11:43:05 +03:00
When csum_block_size > bitmap_granularity and perfect_csum_update = false
(the default behavior), an unaligned INTENT_WRITE modifies the physical
block directly in-place without recalculating and updating the large
block's checksum.

During a subsequent read that requires padding to the checksum block
boundary (e.g., reading adjacent unaligned data), the read logic must
skip checksum verification for the underlying BIG_WRITE because the
physical data has been safely tampered with by the INTENT_WRITE.

Previously, the need_skip logic in blockstore_read.cpp correctly
identified and skipped the verification for overlapping SMALL_WRITEs
but mistakenly omitted INTENT_WRITEs. This caused the padded read to
verify the stale BIG_WRITE checksum against the newly modified physical
data, leading to a fatal false-positive -EDOM (checksum mismatch) IO
error on reads.

This commit fixes the bug by ensuring BS_HEAP_INTENT_WRITE is evaluated
alongside SMALL_WRITE to apply the COPY_BUF_SKIP_CSUM bypass during
overlapping padded reads.

A regression test case (test_intent_write_corruption) is also added to
reproduce this specific data-layout scenario and verify the fix.
changwei.ye closed this pull request 2026-08-31 10:35:35 +03:00

Pull request closed

Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: vitalif/vitastor#79
No description provided.