From c392e914e2bc795f2bfbb440dc59558fe3907ca4 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Sun, 13 Jul 2025 01:31:35 +0300 Subject: [PATCH] Do not block writes on previous writes --- src/blockstore/blockstore_impl.cpp | 23 +++-------------------- src/blockstore/blockstore_sync.cpp | 2 +- 2 files changed, 4 insertions(+), 21 deletions(-) diff --git a/src/blockstore/blockstore_impl.cpp b/src/blockstore/blockstore_impl.cpp index 83963636..89896537 100644 --- a/src/blockstore/blockstore_impl.cpp +++ b/src/blockstore/blockstore_impl.cpp @@ -96,30 +96,21 @@ void blockstore_impl_t::loop() { // try to submit ops unsigned initial_ring_space = ringloop->space_left(); - // has_writes == 0 - no writes before the current queue item - // has_writes == 1 - some writes in progress - // has_writes == 2 - tried to submit some writes, but failed - int has_writes = 0, op_idx = 0, new_idx = 0; + int op_idx = 0, new_idx = 0; for (; op_idx < submit_queue.size(); op_idx++, new_idx++) { auto op = submit_queue[op_idx]; submit_queue[new_idx] = op; - // FIXME: This needs some simplification - // Writes should not block reads if the ring is not full and reads don't depend on them - // In all other cases we should stop submission if (PRIV(op)->wait_for) { check_wait(op); if (PRIV(op)->wait_for == WAIT_SQE) { + // ring is full, stop submission break; } else if (PRIV(op)->wait_for) { - if (op->opcode == BS_OP_WRITE || op->opcode == BS_OP_WRITE_STABLE || op->opcode == BS_OP_DELETE) - { - has_writes = 2; - } continue; } } @@ -134,19 +125,11 @@ void blockstore_impl_t::loop() } else if (op->opcode == BS_OP_WRITE || op->opcode == BS_OP_WRITE_STABLE || op->opcode == BS_OP_DELETE) { - if (has_writes == 2) - { - // Some writes already could not be submitted - continue; - } wr_st = dequeue_write(op); - has_writes = wr_st > 0 ? 1 : 2; } else if (op->opcode == BS_OP_SYNC) { - // sync only completed writes? - // wait for the data device fsync to complete, then submit journal writes for big writes - // then submit an fsync operation + // syncs only completed writes, so doesn't have to be blocked by anything wr_st = continue_sync(op); } else if (op->opcode == BS_OP_STABLE || op->opcode == BS_OP_ROLLBACK) diff --git a/src/blockstore/blockstore_sync.cpp b/src/blockstore/blockstore_sync.cpp index 72baf4f1..8a84f1d6 100644 --- a/src/blockstore/blockstore_sync.cpp +++ b/src/blockstore/blockstore_sync.cpp @@ -31,7 +31,7 @@ int blockstore_impl_t::do_sync(blockstore_op_t *op, int base_state) } if (dsk.disable_journal_fsync && dsk.disable_meta_fsync || !unsynced_big_write_count && !unsynced_small_write_count) { - // We can return immediately because sync is only dequeued after all previous writes + // We can return immediately because sync only syncs previous writes unsynced_big_write_count = unsynced_small_write_count = 0; return 2; }