diff --git a/blockstore_flush.cpp b/blockstore_flush.cpp index da65a00b..8ae72ca3 100644 --- a/blockstore_flush.cpp +++ b/blockstore_flush.cpp @@ -53,14 +53,14 @@ journal_flusher_t::~journal_flusher_t() bool journal_flusher_t::is_active() { - return active_flushers > 0 || flush_queue.size() >= sync_threshold; + return active_flushers > 0 || start_forced && flush_queue.size() > 0 || flush_queue.size() >= sync_threshold; } void journal_flusher_t::loop() { for (int i = 0; i < flusher_count; i++) { - if (!active_flushers && flush_queue.size() < sync_threshold) + if (!active_flushers && (start_forced ? !flush_queue.size() : (flush_queue.size() < sync_threshold))) { return; } @@ -98,6 +98,12 @@ void journal_flusher_t::unshift_flush(obj_ver_id ov) } } +void journal_flusher_t::force_start() +{ + start_forced = true; + bs->ringloop->wakeup(bs->ring_consumer); +} + #define await_sqe(label) \ resume_##label:\ sqe = bs->get_sqe();\ @@ -148,8 +154,9 @@ bool journal_flusher_co::loop() goto resume_18; resume_0: if (!flusher->flush_queue.size() || - !flusher->active_flushers && flusher->flush_queue.size() < flusher->sync_threshold) + !flusher->start_forced && !flusher->active_flushers && flusher->flush_queue.size() < flusher->sync_threshold) { + flusher->start_forced = false; wait_state = 0; return true; } diff --git a/blockstore_flush.h b/blockstore_flush.h index 3f5929ad..f1c5f54f 100644 --- a/blockstore_flush.h +++ b/blockstore_flush.h @@ -60,6 +60,7 @@ public: // Journal flusher itself class journal_flusher_t { + bool start_forced = false; int flusher_count; int sync_threshold; journal_flusher_co *co; @@ -81,6 +82,7 @@ public: ~journal_flusher_t(); void loop(); bool is_active(); + void force_start(); void enqueue_flush(obj_ver_id oid); void unshift_flush(obj_ver_id oid); }; diff --git a/blockstore_journal.cpp b/blockstore_journal.cpp index 154fd93d..6d6f6654 100644 --- a/blockstore_journal.cpp +++ b/blockstore_journal.cpp @@ -57,6 +57,7 @@ int blockstore_journal_check_t::check_available(blockstore_operation *op, int re { // No space in the journal. Wait until used_start changes. op->wait_for = WAIT_JOURNAL; + bs->flusher->force_start(); op->wait_detail = bs->journal.used_start; return 0; }