From 5f2b46bb57a76f7987757ff60b33c91d5c666c31 Mon Sep 17 00:00:00 2001 From: Changwei Ye Date: Fri, 28 Aug 2026 11:15:43 +0800 Subject: [PATCH 1/2] Fix misleading COPY_BUF_JOURNAL flag on hole slices MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit During compaction (`fill_partial_checksum_blocks`), when a partially overwritten checksum block is encountered, the old data needs to be read from the base layer (`clean_wr`). A coalesced slice is inserted into `read_vec` to logically reference this base block data. Previously, this coalesced slice was marked with `COPY_BUF_JOURNAL`. This is a misuse of the flag because the underlying data originates from the data area (a BIG_WRITE block), not the journal area. It should conceptually use `COPY_BUF_DATA`. Although this misuse did not cause any functional bugs—because the coalesced slice also carries the `COPY_BUF_COALESCED` flag, which perfectly short-circuits the I/O submission in `read_buffered` and avoids erroneously reading from `journal_fd`—it creates semantic confusion for future maintainers. `COPY_BUF_JOURNAL` is consistently used elsewhere to denote small writes (journal data). This commit changes the flag to `COPY_BUF_DATA` to ensure semantic correctness and code self-consistency. --- src/blockstore/blockstore_flush.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/blockstore/blockstore_flush.cpp b/src/blockstore/blockstore_flush.cpp index f157dae9..743e6d8a 100644 --- a/src/blockstore/blockstore_flush.cpp +++ b/src/blockstore/blockstore_flush.cpp @@ -563,7 +563,7 @@ void journal_flusher_co::fill_partial_checksum_blocks() } auto & vec = read_vec[read_vec.size()-1]; read_vec.insert(read_vec.begin()+vec_pos, (copy_buffer_t){ - .copy_flags = COPY_BUF_JOURNAL|COPY_BUF_COALESCED, + .copy_flags = COPY_BUF_DATA|COPY_BUF_COALESCED, .offset = hole_start, .len = hole_end - hole_start, .disk_offset = hole_start, -- 2.47.3 From 10a6782bdfa8eae0857484ee89af3619ae498972 Mon Sep 17 00:00:00 2001 From: Changwei Ye Date: Mon, 31 Aug 2026 15:50:01 +0800 Subject: [PATCH 2/2] Fix compilation errors regarding type conversions and pointer arithmetic - src/blockstore/v1/init.cpp: Add explicit uint32_t cast to fix narrowing conversion error when initializing dirty_entry state. - src/client/msgr_receive.cpp: Cast void pointer (iov_base) to char* before performing pointer arithmetic. --- src/blockstore/v1/init.cpp | 4 ++-- src/client/msgr_receive.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/blockstore/v1/init.cpp b/src/blockstore/v1/init.cpp index 771bd589..b0abc1e5 100644 --- a/src/blockstore/v1/init.cpp +++ b/src/blockstore/v1/init.cpp @@ -1006,7 +1006,7 @@ int blockstore_init_journal::handle_journal_part(void *buf, uint64_t done_pos, u memcpy((uint8_t*)dyn+sizeof(int), dyn_from, dyn_size); } bs->dirty_db.emplace(ov, (dirty_entry){ - .state = (BS_ST_SMALL_WRITE | BS_ST_SYNCED | (je->type == JE_SMALL_WRITE_INSTANT ? BS_ST_INSTANT : 0)), + .state = (uint32_t)(BS_ST_SMALL_WRITE | BS_ST_SYNCED | (je->type == JE_SMALL_WRITE_INSTANT ? BS_ST_INSTANT : 0)), .flags = 0, .location = location, .offset = je->small_write.offset, @@ -1090,7 +1090,7 @@ int blockstore_init_journal::handle_journal_part(void *buf, uint64_t done_pos, u memcpy((uint8_t*)dyn+sizeof(int), dyn_from, dyn_size); } auto dirty_it = bs->dirty_db.emplace(ov, (dirty_entry){ - .state = (BS_ST_BIG_WRITE | BS_ST_SYNCED | (je->type == JE_BIG_WRITE_INSTANT ? BS_ST_INSTANT : 0)), + .state = (uint32_t)(BS_ST_BIG_WRITE | BS_ST_SYNCED | (je->type == JE_BIG_WRITE_INSTANT ? BS_ST_INSTANT : 0)), .flags = 0, .location = je->big_write.location, .offset = je->big_write.offset, diff --git a/src/client/msgr_receive.cpp b/src/client/msgr_receive.cpp index f3e66fb9..afcf1cfd 100644 --- a/src/client/msgr_receive.cpp +++ b/src/client/msgr_receive.cpp @@ -527,7 +527,7 @@ out_wakeup: { if (result > 0 && cl->read_csum_state && !(cl->recv_flags[i] & RDR_NO_CSUM)) XXH3_64bits_update(cl->read_csum_state, cl->recv_list[i].iov_base, result); - cl->recv_list[i].iov_base += result; + cl->recv_list[i].iov_base = (char*)cl->recv_list[i].iov_base + result; cl->recv_list[i].iov_len -= result; } else -- 2.47.3