Safe stop procedure

This commit is contained in:
Vitaliy Filippov
2019-11-25 01:29:07 +03:00
parent 50cf3667fa
commit be3015169f
5 changed files with 37 additions and 3 deletions
+25 -2
View File
@@ -176,9 +176,32 @@ void blockstore::loop()
}
}
bool blockstore::stop()
bool blockstore::is_safe_to_stop()
{
return false;
// It's safe to stop blockstore when there are no in-flight operations,
// no in-progress syncs and flusher isn't doing anything
if (submit_queue.size() > 0 || in_progress_syncs.size() > 0 || flusher->is_active())
{
return false;
}
if (unsynced_big_writes.size() > 0 || unsynced_small_writes.size() > 0)
{
if (!stop_sync_submitted)
{
// We should sync the blockstore before unmounting
blockstore_operation *op = new blockstore_operation;
op->flags = OP_SYNC;
op->buf = NULL;
op->callback = [&](blockstore_operation *op)
{
delete op;
};
enqueue_op(op);
stop_sync_submitted = true;
}
return false;
}
return true;
}
void blockstore::check_wait(blockstore_operation *op)