From ae2b1f780221f0a0c34db68fc1f77cedbd6e34a3 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Sat, 7 Mar 2026 00:15:16 +0300 Subject: [PATCH] Some useless code changes for beauty --- src/blockstore/blockstore_heap.cpp | 2 ++ src/blockstore/blockstore_impl.cpp | 2 +- src/blockstore/blockstore_write.cpp | 12 +++++++----- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/blockstore/blockstore_heap.cpp b/src/blockstore/blockstore_heap.cpp index af4f796f..57cd0783 100644 --- a/src/blockstore/blockstore_heap.cpp +++ b/src/blockstore/blockstore_heap.cpp @@ -2291,7 +2291,9 @@ void blockstore_heap_t::apply_inflight(heap_inflight_lsn_t & inflight) } if (!next) { + // The last freed entry must be a deletion assert(!prev); + assert(wr->entry_type == BS_HEAP_DELETE|BS_HEAP_STABLE); auto & pg_idx = block_index[get_pg_id(wr->inode, wr->stripe)]; auto & inode_idx = pg_idx[wr->inode]; heap_inode_map_t::iterator li_it; diff --git a/src/blockstore/blockstore_impl.cpp b/src/blockstore/blockstore_impl.cpp index 2c399088..c50cc19c 100644 --- a/src/blockstore/blockstore_impl.cpp +++ b/src/blockstore/blockstore_impl.cpp @@ -193,12 +193,12 @@ void blockstore_impl_t::loop() heap->start_block_write(block_num); mb.sent = true; } + pending_modified_blocks.clear(); int ret = ringloop->submit(); if (ret < 0) { throw std::runtime_error(std::string("io_uring_submit: ") + strerror(-ret)); } - pending_modified_blocks.clear(); if ((initial_ring_space - ringloop->space_left()) > 0) { live = true; diff --git a/src/blockstore/blockstore_write.cpp b/src/blockstore/blockstore_write.cpp index d5f2e082..b81e61e1 100644 --- a/src/blockstore/blockstore_write.cpp +++ b/src/blockstore/blockstore_write.cpp @@ -22,16 +22,18 @@ void blockstore_impl_t::prepare_meta_block_write(uint32_t modified_block) ring_data_t *data = ((ring_data_t*)sqe->user_data); uint8_t *buf = (uint8_t*)memalign_or_die(MEM_ALIGNMENT, dsk.meta_block_size); data->iov = (struct iovec){ buf, (size_t)dsk.meta_block_size }; - data->callback = [this, modified_block, buf](ring_data_t *data) + data->callback = [this, modified_block](ring_data_t *data) { - free(buf); live = true; if (data->res != data->iov.iov_len) { // FIXME: our state becomes corrupted after a write error. maybe do something better than just die disk_error_abort("data write", data->res, data->iov.iov_len); } - modified_blocks.erase(modified_block); + auto it = modified_blocks.find(modified_block); + assert(it != modified_blocks.end()); + free(it->second.buf); + modified_blocks.erase(it); heap->complete_block_write(modified_block); ringloop->wakeup(); }; @@ -249,13 +251,12 @@ enospc: goto enospc; assert(res == 0); PRIV(op)->lsn = obj->lsn; - if (op->len) - heap->use_buffer_area(op->oid.inode, loc, op->len); prepare_meta_block_write(PRIV(op)->modified_block); PRIV(op)->pending_ops++; if (op->len > 0) { // Prepare buffered data write + heap->use_buffer_area(op->oid.inode, loc, op->len); if (dsk.inmemory_journal) { memcpy((uint8_t*)buffer_area + loc, op->buf, op->len); @@ -348,6 +349,7 @@ resume_12: } resume_4: { + BS_SUBMIT_CHECK_SQES(1); auto obj = heap->read_entry(op->oid); int res = 0; if (PRIV(op)->write_type == _REDIRECT_INTENT)