From 15f69719e4cb1affbe39fb204d0ff2de987298fe Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Thu, 11 Jun 2026 01:49:26 +0300 Subject: [PATCH] Not an actual bug, clean up fsync conditions for clarity It could be a bug if data_fd could be equal to journal_fd but not to meta_fd, but it can't. --- src/blockstore/blockstore_sync.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/blockstore/blockstore_sync.cpp b/src/blockstore/blockstore_sync.cpp index 4ec74a8f..0ae284c1 100644 --- a/src/blockstore/blockstore_sync.cpp +++ b/src/blockstore/blockstore_sync.cpp @@ -29,9 +29,12 @@ bool blockstore_impl_t::has_unsynced() bool blockstore_impl_t::submit_fsyncs(int & wait_count) { - 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); + int n = (unsynced_meta_write_count > 0 && !dsk.disable_meta_fsync ? 1 : 0) + + (unsynced_buffer_write_count > 0 && !dsk.disable_journal_fsync && + (!unsynced_meta_write_count || dsk.journal_fd != dsk.meta_fd) ? 1 : 0) + + (unsynced_data_write_count > 0 && !dsk.disable_data_fsync && + (!unsynced_meta_write_count || dsk.data_fd != dsk.meta_fd) && + (!unsynced_buffer_write_count || dsk.data_fd != dsk.journal_fd) ? 1 : 0); if (ringloop->space_left() < n) { return false; @@ -60,7 +63,8 @@ bool blockstore_impl_t::submit_fsyncs(int & wait_count) data->callback = cb; wait_count++; } - if (unsynced_buffer_write_count > 0 && !dsk.disable_journal_fsync && dsk.meta_fd != dsk.journal_fd) + if (unsynced_buffer_write_count > 0 && !dsk.disable_journal_fsync && + (!unsynced_meta_write_count || dsk.journal_fd != dsk.meta_fd)) { // fsync buffer io_uring_sqe *sqe = get_sqe(); @@ -71,7 +75,9 @@ bool blockstore_impl_t::submit_fsyncs(int & wait_count) data->callback = cb; wait_count++; } - if (unsynced_data_write_count > 0 && !dsk.disable_data_fsync && dsk.data_fd != dsk.meta_fd && dsk.data_fd != dsk.journal_fd) + if (unsynced_data_write_count > 0 && !dsk.disable_data_fsync && + (!unsynced_meta_write_count || dsk.data_fd != dsk.meta_fd) && + (!unsynced_buffer_write_count || dsk.data_fd != dsk.journal_fd)) { // fsync data io_uring_sqe *sqe = get_sqe();