From 1d80bcc8d0160cff0fd74948c32129d64f0ea284 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Wed, 21 Dec 2022 02:39:57 +0300 Subject: [PATCH] Fix blockstore returning garbage for unstable reads if there is an in-flight version "In-flight" versions are added into dirty_db when writes are enqueued. And they weren't ignored by subsequent reads even though they didn't have data location yet. This bug was leading to test_heal.sh not passing sometimes with replicated setups. --- src/blockstore_read.cpp | 4 ++-- src/blockstore_write.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/blockstore_read.cpp b/src/blockstore_read.cpp index 06679a68..a1071226 100644 --- a/src/blockstore_read.cpp +++ b/src/blockstore_read.cpp @@ -139,7 +139,7 @@ int blockstore_impl_t::dequeue_read(blockstore_op_t *read_op) while (dirty_it->first.oid == read_op->oid) { dirty_entry& dirty = dirty_it->second; - bool version_ok = read_op->version >= dirty_it->first.version; + bool version_ok = !IS_IN_FLIGHT(dirty.state) && read_op->version >= dirty_it->first.version; if (IS_SYNCED(dirty.state)) { if (!version_ok && read_op->version != 0) @@ -174,7 +174,7 @@ int blockstore_impl_t::dequeue_read(blockstore_op_t *read_op) dirty_it--; } } - if (clean_it != clean_db.end()) + if (clean_found) { if (!result_version) { diff --git a/src/blockstore_write.cpp b/src/blockstore_write.cpp index 2274cbbc..689b5d8d 100644 --- a/src/blockstore_write.cpp +++ b/src/blockstore_write.cpp @@ -139,7 +139,7 @@ bool blockstore_impl_t::enqueue_write(blockstore_op_t *op) uint8_t *bmp_ptr = (uint8_t*)(dsk.clean_entry_bitmap_size > sizeof(void*) ? bmp : &bmp); uint32_t bit = op->offset/dsk.bitmap_granularity; uint32_t bits_left = op->len/dsk.bitmap_granularity; - while (!(bit % 8) && bits_left > 8) + while (!(bit % 8) && bits_left >= 8) { // Copy bytes bmp_ptr[bit/8] = ((uint8_t*)op->bitmap)[bit/8];