Actually fsync after stabilize

This commit is contained in:
Vitaliy Filippov
2025-11-23 19:08:24 +03:00
parent f45c88d38c
commit bbf5063b25
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* meta_superblock = NULL;
uint8_t *buffer_area = NULL; uint8_t *buffer_area = NULL;
std::vector<blockstore_op_t*> submit_queue; 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; int unsynced_queued_ops = 0;
uint8_t *zero_object = NULL; uint8_t *zero_object = NULL;
+1
View File
@@ -73,6 +73,7 @@ resume_1:
{ {
heap->mark_lsn_completed(lsn); heap->mark_lsn_completed(lsn);
} }
unsynced_meta_write_count++;
// Fsync, just because our semantics imply that commit (stabilize) is immediately fsynced // Fsync, just because our semantics imply that commit (stabilize) is immediately fsynced
priv->op_state = 2; priv->op_state = 2;
resume_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) 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_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); (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) if (ringloop->space_left() < n)
@@ -40,7 +40,7 @@ bool blockstore_impl_t::submit_fsyncs(int & wait_count)
if (!wait_count) if (!wait_count)
ringloop->wakeup(); 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 // fsync meta
io_uring_sqe *sqe = get_sqe(); 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_big_write_count = 0;
unsynced_small_write_count = 0; unsynced_small_write_count = 0;
unsynced_meta_write_count = 0;
return true; 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) 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 // 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; return 2;
} }
PRIV(op)->lsn = heap->get_completed_lsn(); PRIV(op)->lsn = heap->get_completed_lsn();