diff --git a/src/blockstore/blockstore_impl.h b/src/blockstore/blockstore_impl.h index c032c179..db7bd698 100644 --- a/src/blockstore/blockstore_impl.h +++ b/src/blockstore/blockstore_impl.h @@ -115,7 +115,7 @@ public: uint8_t* meta_superblock = NULL; uint8_t *buffer_area = NULL; std::vector 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; diff --git a/src/blockstore/blockstore_stable.cpp b/src/blockstore/blockstore_stable.cpp index a0a8a710..010d7360 100644 --- a/src/blockstore/blockstore_stable.cpp +++ b/src/blockstore/blockstore_stable.cpp @@ -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: diff --git a/src/blockstore/blockstore_sync.cpp b/src/blockstore/blockstore_sync.cpp index 91a809b1..fc136d5b 100644 --- a/src/blockstore/blockstore_sync.cpp +++ b/src/blockstore/blockstore_sync.cpp @@ -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();