From d0690091c1a7578f74ee6fc159284154212970b1 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Tue, 29 Jul 2025 00:32:01 +0300 Subject: [PATCH] Fix op_stable slowdowns --- src/blockstore/blockstore_stable.cpp | 2 +- src/blockstore/blockstore_write.cpp | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/blockstore/blockstore_stable.cpp b/src/blockstore/blockstore_stable.cpp index 6e5e25a7..4ea9e030 100644 --- a/src/blockstore/blockstore_stable.cpp +++ b/src/blockstore/blockstore_stable.cpp @@ -65,7 +65,7 @@ resume_1: if (priv->pending_ops > 0) { priv->op_state = 1; - return 0; + return 1; } // Mark writes as completed to allow compaction for (uint64_t lsn = priv->lsn; lsn <= priv->to_lsn; lsn++) diff --git a/src/blockstore/blockstore_write.cpp b/src/blockstore/blockstore_write.cpp index f8d5a4d0..3b5c0fa6 100644 --- a/src/blockstore/blockstore_write.cpp +++ b/src/blockstore/blockstore_write.cpp @@ -277,6 +277,7 @@ bool blockstore_impl_t::make_big_write(blockstore_op_t *op, uint32_t offset, uin int blockstore_impl_t::continue_write(blockstore_op_t *op) { int op_state = PRIV(op)->op_state; +again: if (op_state == 2) goto resume_2; else if (op_state == 4) @@ -294,7 +295,11 @@ int blockstore_impl_t::continue_write(blockstore_op_t *op) else { // In progress - return 1; + assert(op_state < 10); + if (PRIV(op)->pending_ops > 0) + return 1; + op_state++; + goto again; } resume_2: // We must fsync all big writes to avoid complex write workflows @@ -372,7 +377,7 @@ resume_6: // Remember that the timer can in theory be called right here tfd->set_timer_us(ref_us-exec_us, false, [this, op](int timer_id) { - PRIV(op)->op_state++; + PRIV(op)->op_state = 8; ringloop->wakeup(); }); return 1; @@ -416,7 +421,6 @@ void blockstore_impl_t::handle_write_event(ring_data_t *data, blockstore_op_t *o assert(PRIV(op)->pending_ops >= 0); if (PRIV(op)->pending_ops == 0) { - PRIV(op)->op_state++; ringloop->wakeup(); } }