From 73a1f622bb1134b29ff2a419ddc2c0fd4f6624ee Mon Sep 17 00:00:00 2001 From: Changwei Ye Date: Mon, 14 Sep 2026 17:18:30 +0800 Subject: [PATCH] Store v2: decouple trim_lsn from force_fsync Commit df9a2850 introduced force_fsync to resolve the placement contract conflict (EAGAIN) when a new metadata entry depends on a previous unsynced entry that is already in-flight. However, it mistakenly grouped the 'force_fsync > 0' condition together with the Superblock Checkpoint logic. As a result, every time the internal torn-write prevention mechanism requested a force_fsync, the system inadvertently executed an expensive trim_lsn() (updating the Superblock with RWF_DSYNC), causing unnecessary write latency and I/O amplification during congested object updates. This change minimally refactors the state machine to ensure trim_lsn() is strictly bound to the intended journal_trim_interval, while force_fsync only triggers the necessary fsync_buffer(). --- src/blockstore/blockstore_flush.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/blockstore/blockstore_flush.cpp b/src/blockstore/blockstore_flush.cpp index 1acd399e..1e398cfd 100644 --- a/src/blockstore/blockstore_flush.cpp +++ b/src/blockstore/blockstore_flush.cpp @@ -213,18 +213,25 @@ resume_0: res = bs->heap->get_next_compact(cur_oid); if ((bs->intent_write_counter >= bs->journal_trim_interval || flusher->force_fsync > 0) && co_id == 0) { - // Advance fsynced_lsn every intent writes - bs->intent_write_counter = 0; resume_17: resume_18: resume_19: if (!fsync_buffer(17)) + { return false; + } + if (bs->intent_write_counter >= bs->journal_trim_interval) + { + // Advance fsynced_lsn every intent writes + bs->intent_write_counter = 0; resume_29: resume_30: resume_31: - if (!trim_lsn(29)) - return false; + if (!trim_lsn(29)) + { + return false; + } + } } if (res == ENOENT && flusher->force_start > 0 && co_id == 0 && (!bs->dsk.disable_journal_fsync || !bs->dsk.disable_meta_fsync || !bs->dsk.disable_data_fsync)) -- 2.47.3