From e0d60dd49f0548c420f128fbffb773f97315dbbf Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Sat, 12 Jul 2025 10:59:18 +0300 Subject: [PATCH] Remove extra unneeded read_entry-s --- src/blockstore/blockstore_heap.cpp | 16 +++++++++++++++- src/blockstore/blockstore_heap.h | 2 ++ src/blockstore/blockstore_write.cpp | 12 +++++------- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/blockstore/blockstore_heap.cpp b/src/blockstore/blockstore_heap.cpp index 7ae58666..05b0bad7 100644 --- a/src/blockstore/blockstore_heap.cpp +++ b/src/blockstore/blockstore_heap.cpp @@ -1373,6 +1373,15 @@ int blockstore_heap_t::post_write(object_id oid, heap_write_t *wr, uint32_t *mod return update_object(block_num, obj, wr, modified_block); } +int blockstore_heap_t::post_write(uint32_t & block_num, object_id oid, heap_object_t *obj, heap_write_t *wr) +{ + if (!obj) + { + return add_object(oid, wr, &block_num); + } + return update_object(block_num, obj, wr, &block_num); +} + int blockstore_heap_t::post_stabilize(object_id oid, uint64_t version, uint32_t *modified_block, uint64_t *new_lsn, uint64_t *new_to_lsn) { uint32_t block_num = 0; @@ -1523,6 +1532,11 @@ int blockstore_heap_t::post_delete(object_id oid, uint64_t *new_lsn, uint32_t *m { *modified_block = block_num; } + return post_delete(block_num, obj, new_lsn); +} + +int blockstore_heap_t::post_delete(uint32_t block_num, heap_object_t *obj, uint64_t *new_lsn) +{ bool tracking_active = mvcc_save_copy(obj); auto & inf = block_info.at(block_num); assert(inf.data); @@ -1531,7 +1545,7 @@ int blockstore_heap_t::post_delete(object_id oid, uint64_t *new_lsn, uint32_t *m { *new_lsn = next_lsn; } - push_inflight_lsn(oid, next_lsn, 0); + push_inflight_lsn((object_id){ .inode = obj->inode, .stripe = obj->stripe }, next_lsn, 0); erase_object(block_num, obj, next_lsn, tracking_active); return 0; } diff --git a/src/blockstore/blockstore_heap.h b/src/blockstore/blockstore_heap.h index ce9f2292..eba40a6f 100644 --- a/src/blockstore/blockstore_heap.h +++ b/src/blockstore/blockstore_heap.h @@ -227,6 +227,7 @@ public: // auto-compacts the object, then adds a write entry to it and to the compaction queue // return 0 if OK, or maybe ENOSPC int post_write(object_id oid, heap_write_t *wr, uint32_t *modified_block); + int post_write(uint32_t & block_num, object_id oid, heap_object_t *obj, heap_write_t *wr); // stabilize an unstable object version // return 0 if OK, ENOENT if not exists int post_stabilize(object_id oid, uint64_t version, uint32_t *modified_block, uint64_t *new_lsn, uint64_t *new_to_lsn); @@ -236,6 +237,7 @@ public: // forget an object // return error code int post_delete(object_id oid, uint64_t *new_lsn, uint32_t *modified_block); + int post_delete(uint32_t block_num, heap_object_t *obj, uint64_t *new_lsn); // get the next object to compact // guaranteed to return objects in min lsn order // returns 0 if OK, ENOENT if nothing to compact diff --git a/src/blockstore/blockstore_write.cpp b/src/blockstore/blockstore_write.cpp index 4dc34112..e150753f 100644 --- a/src/blockstore/blockstore_write.cpp +++ b/src/blockstore/blockstore_write.cpp @@ -71,7 +71,8 @@ int blockstore_impl_t::dequeue_write(blockstore_op_t *op) return 0; } PRIV(op)->is_big = false; - heap_object_t *obj = heap->read_entry(op->oid, NULL); + uint32_t modified_block = 0; + heap_object_t *obj = heap->read_entry(op->oid, &modified_block); if (op->opcode == BS_OP_DELETE) { // Delete @@ -83,8 +84,7 @@ int blockstore_impl_t::dequeue_write(blockstore_op_t *op) return 2; } BS_SUBMIT_CHECK_SQES(1); - uint32_t modified_block; - int res = heap->post_delete(op->oid, &PRIV(op)->lsn, &modified_block); + int res = heap->post_delete(modified_block, obj, &PRIV(op)->lsn); assert(res == 0); prepare_meta_block_write(op, modified_block); PRIV(op)->op_state = 5; @@ -174,8 +174,7 @@ int blockstore_impl_t::dequeue_write(blockstore_op_t *op) if (op->bitmap) memcpy(wr->get_ext_bitmap(heap), op->bitmap, dsk.clean_entry_bitmap_size); heap->calc_checksums(wr, (uint8_t*)op->buf, true); - uint32_t modified_block; - int res = heap->post_write(op->oid, wr, &modified_block); + int res = heap->post_write(modified_block, op->oid, obj, wr); if (res == ENOSPC) { if (!heap->get_inflight_queue_size()) @@ -220,8 +219,7 @@ int blockstore_impl_t::dequeue_write(blockstore_op_t *op) if (op->bitmap) memcpy(wr->get_ext_bitmap(heap), op->bitmap, dsk.clean_entry_bitmap_size); heap->calc_checksums(wr, (uint8_t*)op->buf, true); - uint32_t modified_block; - int res = heap->post_write(op->oid, wr, &modified_block); + int res = heap->post_write(modified_block, op->oid, obj, wr); if (res == ENOSPC) { if (!heap->get_inflight_queue_size())