Force start when journal is full

blocking-uring-test
Vitaliy Filippov 2019-12-03 01:45:10 +03:00
parent 2963ad98ec
commit fd13965b90
3 changed files with 13 additions and 3 deletions

View File

@ -53,14 +53,14 @@ journal_flusher_t::~journal_flusher_t()
bool journal_flusher_t::is_active() 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() void journal_flusher_t::loop()
{ {
for (int i = 0; i < flusher_count; i++) 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; 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) \ #define await_sqe(label) \
resume_##label:\ resume_##label:\
sqe = bs->get_sqe();\ sqe = bs->get_sqe();\
@ -148,8 +154,9 @@ bool journal_flusher_co::loop()
goto resume_18; goto resume_18;
resume_0: resume_0:
if (!flusher->flush_queue.size() || 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; wait_state = 0;
return true; return true;
} }

View File

@ -60,6 +60,7 @@ public:
// Journal flusher itself // Journal flusher itself
class journal_flusher_t class journal_flusher_t
{ {
bool start_forced = false;
int flusher_count; int flusher_count;
int sync_threshold; int sync_threshold;
journal_flusher_co *co; journal_flusher_co *co;
@ -81,6 +82,7 @@ public:
~journal_flusher_t(); ~journal_flusher_t();
void loop(); void loop();
bool is_active(); bool is_active();
void force_start();
void enqueue_flush(obj_ver_id oid); void enqueue_flush(obj_ver_id oid);
void unshift_flush(obj_ver_id oid); void unshift_flush(obj_ver_id oid);
}; };

View File

@ -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. // No space in the journal. Wait until used_start changes.
op->wait_for = WAIT_JOURNAL; op->wait_for = WAIT_JOURNAL;
bs->flusher->force_start();
op->wait_detail = bs->journal.used_start; op->wait_detail = bs->journal.used_start;
return 0; return 0;
} }