Fix submitting forced fsyncs in flusher
This commit is contained in:
@@ -18,10 +18,18 @@ int blockstore_impl_t::continue_sync(blockstore_op_t *op)
|
||||
return res;
|
||||
}
|
||||
|
||||
bool blockstore_impl_t::has_unsynced()
|
||||
{
|
||||
bool data = (!dsk.disable_data_fsync && unsynced_data_write_count);
|
||||
bool buffer = (!dsk.disable_journal_fsync && unsynced_buffer_write_count);
|
||||
bool meta = (!dsk.disable_meta_fsync && unsynced_meta_write_count);
|
||||
return data || buffer || meta;
|
||||
}
|
||||
|
||||
bool blockstore_impl_t::submit_fsyncs(int & wait_count)
|
||||
{
|
||||
int n = ((unsynced_small_write_count > 0 || unsynced_data_write_count > 0 || unsynced_meta_write_count > 0) && !dsk.disable_meta_fsync) +
|
||||
(unsynced_small_write_count > 0 && !dsk.disable_journal_fsync && dsk.journal_fd != dsk.meta_fd) +
|
||||
int n = (unsynced_meta_write_count > 0 && !dsk.disable_meta_fsync) +
|
||||
(unsynced_buffer_write_count > 0 && !dsk.disable_journal_fsync && dsk.journal_fd != dsk.meta_fd) +
|
||||
(unsynced_data_write_count > 0 && !dsk.disable_data_fsync && dsk.data_fd != dsk.meta_fd && dsk.data_fd != dsk.journal_fd);
|
||||
if (ringloop->space_left() < n)
|
||||
{
|
||||
@@ -40,7 +48,7 @@ bool blockstore_impl_t::submit_fsyncs(int & wait_count)
|
||||
if (!wait_count)
|
||||
ringloop->wakeup();
|
||||
};
|
||||
if ((unsynced_small_write_count > 0 || unsynced_data_write_count > 0 || unsynced_meta_write_count > 0) && !dsk.disable_meta_fsync)
|
||||
if (unsynced_meta_write_count > 0 && !dsk.disable_meta_fsync)
|
||||
{
|
||||
// fsync meta
|
||||
io_uring_sqe *sqe = get_sqe();
|
||||
@@ -51,7 +59,7 @@ bool blockstore_impl_t::submit_fsyncs(int & wait_count)
|
||||
data->callback = cb;
|
||||
wait_count++;
|
||||
}
|
||||
if (unsynced_small_write_count > 0 && !dsk.disable_journal_fsync && dsk.meta_fd != dsk.journal_fd)
|
||||
if (unsynced_buffer_write_count > 0 && !dsk.disable_journal_fsync && dsk.meta_fd != dsk.journal_fd)
|
||||
{
|
||||
// fsync buffer
|
||||
io_uring_sqe *sqe = get_sqe();
|
||||
@@ -74,7 +82,7 @@ bool blockstore_impl_t::submit_fsyncs(int & wait_count)
|
||||
wait_count++;
|
||||
}
|
||||
unsynced_data_write_count = 0;
|
||||
unsynced_small_write_count = 0;
|
||||
unsynced_buffer_write_count = 0;
|
||||
unsynced_meta_write_count = 0;
|
||||
return true;
|
||||
}
|
||||
@@ -90,11 +98,10 @@ int blockstore_impl_t::do_sync(blockstore_op_t *op, int base_state)
|
||||
// Wait for flusher-initiated sync
|
||||
return 0;
|
||||
}
|
||||
if (dsk.disable_journal_fsync && dsk.disable_meta_fsync && dsk.disable_data_fsync ||
|
||||
!unsynced_data_write_count && !unsynced_small_write_count && !unsynced_meta_write_count)
|
||||
if (!has_unsynced())
|
||||
{
|
||||
// We can return immediately because sync only syncs previous writes
|
||||
unsynced_data_write_count = unsynced_small_write_count = unsynced_meta_write_count = 0;
|
||||
unsynced_data_write_count = unsynced_buffer_write_count = unsynced_meta_write_count = 0;
|
||||
return 2;
|
||||
}
|
||||
PRIV(op)->modified_block = heap->get_completed_lsn();
|
||||
|
||||
Reference in New Issue
Block a user