From 0bc81f532074992bb5c3e4d8f3940d2e6bf28641 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Sun, 6 Jul 2025 18:50:27 +0300 Subject: [PATCH] Fix pending_ops --- src/blockstore/blockstore_impl.cpp | 1 + src/blockstore/blockstore_sync.cpp | 10 +++++----- src/blockstore/blockstore_write.cpp | 3 +-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/blockstore/blockstore_impl.cpp b/src/blockstore/blockstore_impl.cpp index bfde937b..83963636 100644 --- a/src/blockstore/blockstore_impl.cpp +++ b/src/blockstore/blockstore_impl.cpp @@ -166,6 +166,7 @@ void blockstore_impl_t::loop() } if (wr_st == 0) { + PRIV(op)->pending_ops = 0; ringloop->restore(prev_sqe_pos); if (PRIV(op)->wait_for == WAIT_SQE) { diff --git a/src/blockstore/blockstore_sync.cpp b/src/blockstore/blockstore_sync.cpp index 4be66253..ee57eb45 100644 --- a/src/blockstore/blockstore_sync.cpp +++ b/src/blockstore/blockstore_sync.cpp @@ -6,6 +6,10 @@ int blockstore_impl_t::continue_sync(blockstore_op_t *op) { + int op_state = PRIV(op)->op_state; + if (op_state == 1) goto resume_1; + if (op_state == 2) goto resume_2; + assert(!op_state); if (immediate_commit == IMMEDIATE_ALL || !unsynced_big_write_count && !unsynced_small_write_count) { // We can return immediately because sync is only dequeued after all previous writes @@ -14,10 +18,6 @@ int blockstore_impl_t::continue_sync(blockstore_op_t *op) FINISH_OP(op); return 2; } - int op_state = PRIV(op)->op_state; - if (op_state == 1) goto resume_1; - if (op_state == 2) goto resume_2; - assert(!op_state); stop_sync_submitted = false; if (unsynced_small_write_count > 0 && !disable_journal_fsync) { @@ -28,7 +28,7 @@ int blockstore_impl_t::continue_sync(blockstore_op_t *op) data->callback = [this, op](ring_data_t *data) { handle_write_event(data, op); }; PRIV(op)->pending_ops++; } - if (!disable_meta_fsync) + if (!disable_meta_fsync && dsk.meta_fd != dsk.journal_fd) { // fsync meta BS_SUBMIT_GET_SQE(sqe, data); diff --git a/src/blockstore/blockstore_write.cpp b/src/blockstore/blockstore_write.cpp index 8f665037..737d156c 100644 --- a/src/blockstore/blockstore_write.cpp +++ b/src/blockstore/blockstore_write.cpp @@ -87,7 +87,6 @@ int blockstore_impl_t::dequeue_write(blockstore_op_t *op) int res = heap->post_delete(op->oid, &modified_block); assert(res == 0); prepare_meta_block_write(op, modified_block); - PRIV(op)->pending_ops++; PRIV(op)->op_state = 5; write_iodepth++; } @@ -142,7 +141,7 @@ int blockstore_impl_t::dequeue_write(blockstore_op_t *op) io_uring_prep_writev( sqe, dsk.data_fd, PRIV(op)->iov_zerofill, vcnt, dsk.data_offset + loc + op->offset - stripe_offset ); - PRIV(op)->pending_ops = 1; + PRIV(op)->pending_ops++; unsynced_big_write_count++; PRIV(op)->op_state = 1; write_iodepth++;