From 4fbe4b565441c8f947b6d87f5b64e0dbb4afd64e Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Wed, 4 Feb 2026 01:52:34 +0300 Subject: [PATCH] Fix BIG_INTENT rechecks with enabled checksums --- src/blockstore/blockstore_heap.cpp | 8 ++++---- src/blockstore/blockstore_heap.h | 2 +- src/test/test_heap.cpp | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/blockstore/blockstore_heap.cpp b/src/blockstore/blockstore_heap.cpp index 2a16c974..937e106f 100644 --- a/src/blockstore/blockstore_heap.cpp +++ b/src/blockstore/blockstore_heap.cpp @@ -837,7 +837,6 @@ bool blockstore_heap_t::calc_checksums(heap_entry_t *wr, uint8_t *data, bool set { return true; } - uint32_t len = 0; if (wr->type() == BS_HEAP_SMALL_WRITE || wr->type() == BS_HEAP_INTENT_WRITE) len = wr->small().len; else if (wr->type() == BS_HEAP_BIG_INTENT) @@ -854,13 +853,14 @@ bool blockstore_heap_t::calc_checksums(heap_entry_t *wr, uint8_t *data, bool set } if (wr->type() == BS_HEAP_BIG_WRITE) { + assert(offset != UINT32_MAX && len != UINT32_MAX); return calc_block_checksums((uint32_t*)(wr->get_checksums(this) + offset/dsk->csum_block_size * (dsk->data_csum_type & 0xFF)), data, wr->get_int_bitmap(this), offset, offset+len, set, NULL); } if (wr->type() == BS_HEAP_BIG_INTENT) { auto & bi = wr->big_intent(); - return calc_block_checksums((uint32_t*)(wr->get_checksums(this) + offset/dsk->csum_block_size * (dsk->data_csum_type & 0xFF)), + return calc_block_checksums((uint32_t*)(wr->get_checksums(this) + bi.offset/dsk->csum_block_size * (dsk->data_csum_type & 0xFF)), data, wr->get_int_bitmap(this), bi.offset, bi.offset+bi.len, set, NULL); } assert(wr->type() == BS_HEAP_SMALL_WRITE || wr->type() == BS_HEAP_INTENT_WRITE); @@ -1418,7 +1418,7 @@ int blockstore_heap_t::add_redirect_intent(object_id oid, heap_entry_t **obj_ptr bitmap_set(wr->get_int_bitmap(this), offset, len, dsk->bitmap_granularity); if (dsk->data_csum_type) memset(wr->get_checksums(this), 0, get_csum_size(wr)); - calc_checksums(wr, (uint8_t*)data, true, offset, len); + calc_checksums(wr, (uint8_t*)data, true); *obj_ptr = wr; }); } @@ -1461,7 +1461,7 @@ int blockstore_heap_t::add_big_intent(object_id oid, heap_entry_t **obj_ptr, uin else { memcpy(wr->get_checksums(this), obj->get_checksums(this), get_csum_size(wr)); - calc_checksums(wr, (uint8_t*)data, true, offset, len); + calc_checksums(wr, (uint8_t*)data, true); } } else diff --git a/src/blockstore/blockstore_heap.h b/src/blockstore/blockstore_heap.h index cefc9eff..a677865f 100644 --- a/src/blockstore/blockstore_heap.h +++ b/src/blockstore/blockstore_heap.h @@ -261,7 +261,7 @@ public: // unlock an entry bool unlock_entry(object_id oid); // set or verify checksums in a write request - bool calc_checksums(heap_entry_t *wr, uint8_t *data, bool set, uint32_t offset = 0, uint32_t len = 0); + bool calc_checksums(heap_entry_t *wr, uint8_t *data, bool set, uint32_t offset = UINT32_MAX, uint32_t len = UINT32_MAX); // set or verify raw block checksums bool calc_block_checksums(uint32_t *block_csums, uint8_t *data, uint8_t *bitmap, uint32_t start, uint32_t end, bool set, std::function bad_block_cb); diff --git a/src/test/test_heap.cpp b/src/test/test_heap.cpp index e7f9ea05..7d37bfbe 100644 --- a/src/test/test_heap.cpp +++ b/src/test/test_heap.cpp @@ -461,7 +461,7 @@ void test_compact(bool csum, bool stable) assert(!memcmp(obj->get_int_bitmap(&heap), ref_int_bitmap, dsk.clean_entry_bitmap_size)); if (csum) { - assert(heap.calc_checksums(obj, buffer_area.data(), false)); + assert(heap.calc_checksums(obj, buffer_area.data(), false, 0, dsk.data_block_size)); size_t csum_count = dsk.data_block_size/(dsk.csum_block_size ? dsk.csum_block_size : 4096); std::vector csums(csum_count); csums[0] = crc32c(0, buffer_area.data(), 4096);