Store v1: Do not skip checksum verification of reads that start after a parallel flush #128

Open
koolkhel wants to merge 1 commits from koolkhel/vitastor:blockstore-v1-sticky-was-changed into master
Contributor

Description

used_clean_obj_t::was_changed was set by a flush (or by a read started during one) and never reset while the used_clean_objects entry had references. So a read that started after the flush had finished, but while an older read still held the same clean block, also returned data without verifying checksums. Under continuously overlapping reads of the same block this could last indefinitely.

Count flushes in the entry instead and remember the count at the start of each read. Verification is skipped only if the count changed during the read or a flush was already running when it started, which is the case the skip exists for.

Tested:

  • New test_read_after_flush_verifies_csum in test_blockstore_v1 (crc32c, csum_block_size 16k): read A holds a clean block across an in-place flush, then read B of a corrupted csum block must return -EDOM. It fails without the fix and passes with it; all other test_blockstore_v1 tests pass.
  • test_blockstore_chaos on v1 configs with csum 16k/4k (seeds 1-400 of configs 14, 17, 20, 23, plus a read-heavy run), csum 4k/4k and no csum: same results before and after the change, no checksum mismatches. One seed (--seed 133 --config 17) fails the same way with and without the change, on content after a power outage; that is a separate issue.

Contributor Name

Yury Luneff (MIND Software LLC, https://mindsw.io)

CLA

### Description `used_clean_obj_t::was_changed` was set by a flush (or by a read started during one) and never reset while the `used_clean_objects` entry had references. So a read that started after the flush had finished, but while an older read still held the same clean block, also returned data without verifying checksums. Under continuously overlapping reads of the same block this could last indefinitely. Count flushes in the entry instead and remember the count at the start of each read. Verification is skipped only if the count changed during the read or a flush was already running when it started, which is the case the skip exists for. Tested: - New `test_read_after_flush_verifies_csum` in `test_blockstore_v1` (crc32c, csum_block_size 16k): read A holds a clean block across an in-place flush, then read B of a corrupted csum block must return -EDOM. It fails without the fix and passes with it; all other `test_blockstore_v1` tests pass. - `test_blockstore_chaos` on v1 configs with csum 16k/4k (seeds 1-400 of configs 14, 17, 20, 23, plus a read-heavy run), csum 4k/4k and no csum: same results before and after the change, no checksum mismatches. One seed (`--seed 133 --config 17`) fails the same way with and without the change, on content after a power outage; that is a separate issue. ### Contributor Name Yury Luneff (MIND Software LLC, https://mindsw.io) ### CLA - [x] I accept Vitastor CLA agreement: https://git.yourcmc.ru/vitalif/vitastor/src/branch/master/CLA-en.md
koolkhel added 1 commit 2026-11-18 11:43:31 +03:00
used_clean_obj_t::was_changed was set by a flush (or by a read started
during one) and never reset while the entry had references, so a read
started after the flush had finished, but while an older read still held
the same clean block, also returned data without verifying checksums.
Count flushes in the entry instead and remember the count at the start
of each read, skipping verification only if it changed or a flush was
already running.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u blockstore-v1-sticky-was-changed:koolkhel-blockstore-v1-sticky-was-changed
git checkout koolkhel-blockstore-v1-sticky-was-changed
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#128
No description provided.