From a2994ecd0d35469f5f235cbf2f5f180e040a3c11 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Fri, 5 Apr 2024 23:14:39 +0300 Subject: [PATCH] Fix flusher possibly not trimming journal on rollback --- src/blockstore_flush.cpp | 7 +++++-- src/blockstore_flush.h | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/blockstore_flush.cpp b/src/blockstore_flush.cpp index 25b6f454..c70c6760 100644 --- a/src/blockstore_flush.cpp +++ b/src/blockstore_flush.cpp @@ -86,6 +86,8 @@ void journal_flusher_t::loop() cur_flusher_count--; } } + if (trim_wanted) + co[0].try_trim = true; for (int i = 0; (active_flushers > 0 || dequeuing || trim_wanted > 0) && i < cur_flusher_count; i++) co[i].loop(); } @@ -364,10 +366,10 @@ resume_0: !flusher->flush_queue.size() || !flusher->dequeuing) { stop_flusher: - if (flusher->trim_wanted > 0 && cur.oid.inode != 0) + if (flusher->trim_wanted > 0 && try_trim) { // Attempt forced trim - cur.oid = {}; + try_trim = false; flusher->active_flushers++; goto trim_journal; } @@ -375,6 +377,7 @@ stop_flusher: wait_state = 0; return true; } + try_trim = true; cur.oid = flusher->flush_queue.front(); cur.version = flusher->flush_versions[cur.oid]; flusher->flush_queue.pop_front(); diff --git a/src/blockstore_flush.h b/src/blockstore_flush.h index 14f5c67c..1f4392a4 100644 --- a/src/blockstore_flush.h +++ b/src/blockstore_flush.h @@ -60,6 +60,7 @@ class journal_flusher_co std::map::iterator repeat_it; std::function simple_callback_r, simple_callback_rj, simple_callback_w; + bool try_trim = false; bool skip_copy, has_delete, has_writes; std::vector v; std::vector::iterator it;