Actually fsync after stabilize

This commit is contained in:
Vitaliy Filippov
2025-12-02 01:52:12 +03:00
parent 5067554e46
commit 4143d56db7
3 changed files with 6 additions and 4 deletions
+1 -1
View File
@@ -115,7 +115,7 @@ public:
uint8_t* meta_superblock = NULL;
uint8_t *buffer_area = NULL;
std::vector<blockstore_op_t*> submit_queue;
int unsynced_big_write_count = 0, unsynced_small_write_count = 0;
int unsynced_big_write_count = 0, unsynced_small_write_count = 0, unsynced_meta_write_count = 0;
int unsynced_queued_ops = 0;
uint8_t *zero_object = NULL;
+1
View File
@@ -73,6 +73,7 @@ resume_1:
{
heap->mark_lsn_completed(lsn);
}
unsynced_meta_write_count++;
// Fsync, just because our semantics imply that commit (stabilize) is immediately fsynced
priv->op_state = 2;
resume_2:
+4 -3
View File
@@ -20,7 +20,7 @@ int blockstore_impl_t::continue_sync(blockstore_op_t *op)
bool blockstore_impl_t::submit_fsyncs(int & wait_count)
{
int n = ((unsynced_small_write_count > 0 || unsynced_big_write_count > 0) && !dsk.disable_meta_fsync) +
int n = ((unsynced_small_write_count > 0 || unsynced_big_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) +
(unsynced_big_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 +40,7 @@ bool blockstore_impl_t::submit_fsyncs(int & wait_count)
if (!wait_count)
ringloop->wakeup();
};
if (!dsk.disable_meta_fsync)
if ((unsynced_small_write_count > 0 || unsynced_big_write_count > 0 || unsynced_meta_write_count > 0) && !dsk.disable_meta_fsync)
{
// fsync meta
io_uring_sqe *sqe = get_sqe();
@@ -75,6 +75,7 @@ bool blockstore_impl_t::submit_fsyncs(int & wait_count)
}
unsynced_big_write_count = 0;
unsynced_small_write_count = 0;
unsynced_meta_write_count = 0;
return true;
}
@@ -92,7 +93,7 @@ int blockstore_impl_t::do_sync(blockstore_op_t *op, int base_state)
if (dsk.disable_journal_fsync && dsk.disable_meta_fsync && dsk.disable_data_fsync || !unsynced_big_write_count && !unsynced_small_write_count)
{
// We can return immediately because sync only syncs previous writes
unsynced_big_write_count = unsynced_small_write_count = 0;
unsynced_big_write_count = unsynced_small_write_count = unsynced_meta_write_count = 0;
return 2;
}
PRIV(op)->lsn = heap->get_completed_lsn();