From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.127.231.114 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796056754; b=g/6ahhuOVLE3ZyJUzWwMAATXQGztkpqhObmWN+3PZs6/UlpVzuNWyOj++w91jqxM2oUd ipCmmh3pFLgx24imGkHcI3LWccSIL9VZBF7FYajv0XBFNA/BG1z9+0VkB7V49kBPdnFKO Q5tIl0CfmMn/9RWga3vIyCU/E//x2Rzdh2ahXBg+svN5iD62LpHAnoGBaZcFFladQe38B SCQAGcHobD7+v3VtApj3A9pZkFjfhyTEKQyUGCcENCPjkG0cEuvIaLqMRDzwBvcfU7QCc woIzh8fdtQ9bH4F2HPvpqrIcuNa9qIxG0C0hCUJSuxO1JbluZxeAvXy//mnJfCLE8vA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796056754; h=DMARC-Filter:DKIM-Signature:From:Content-Type:To:Subject: Mime-Version:X-Lms-Return-Path:Cc:Date:X-Original-From: Content-Transfer-Encoding:References:Message-Id:In-Reply-To:X-Mailer; bh=vh0q4TNp3SCDCWFX9hWpHLXTonsf7E6wNDGy/K0+Ohw=; b=lroDsGQJO8cu0VQm+Cjnf3ucaPIgczZXoD5KGtzylhujoi07O0qZBGmV2JM81kLcGtin 0RLZ1VPqIfLr3t0BTQ9cTXL6e+gd0QxT3xHBL7K9zoq2qYumma4vKuclkgi/0HP7BLQiZ mNPwcQ71L+fuJyy7XV3szOVdBNBmxcHC5tkcYFUXSJ8dU7NTI5S2nFWKUK3vOhrASgEC/ ICRFjIh4Hs77SeoC+OSVTsc9bk2H44AZclUxbANC1xa0rKH+/tngXRQ7dH1icjZ11M5rX cB6s7S7EiwZ5vn3VkEWALIWtOMSsYkgw6u2ukdG2DWdXsRXrq4PKV+E+zBCcCiDcHhw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=bytedance.com; spf=pass smtp.mailfrom=bytedance.com; dkim=pass header.d=bytedance.com header.i=@bytedance.com header.a=rsa-sha256 header.s=2212171451 header.b=BL1ZAl++; arc=none smtp.remote-ip=209.127.231.114 Received: from va-2-114.ptr.blmpb.com (va-2-114.ptr.blmpb.com [209.127.231.114]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 392CB606A31C for ; Mon, 30 Nov 2026 16:39:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 392CB606A31C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bytedance.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.a=rsa-sha256 header.s=2212171451 header.b=BL1ZAl++ DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=2212171451; d=bytedance.com; t=1796056748; h=from:subject: mime-version:from:date:message-id:subject:to:cc:reply-to:content-type: mime-version:in-reply-to:message-id; bh=vh0q4TNp3SCDCWFX9hWpHLXTonsf7E6wNDGy/K0+Ohw=; b=BL1ZAl++Dmi4lqbD8nNWd4YgiaBouR14Zg9jJisjrA6M4DGAsfArjlp78QAvthcIolEsB4 FWPrsghk9YY+N8HaNCYcgxfWepQJ2xqtgJ8IqBemztdRLfY9Rp15PyyRprfRkPAzvHSHGW fiw4elIdxBaJocNss5W4WIIf5YuiC8GlcRkNd5ja1kvo0NVpFGndoQLsoNq1n+hnI8S8CI QhBWJPTSTWTEYRcbh6kTBSWKTzxD2HgJFIqCr7U8tnMaWUYbVdDQmK2BDXsD8Z7myb3HCr 4Dg7nXG1P8VmW+Qu1+9HIX7Jxwun4gwIEBzUE+oxWahy/1ng81Wn88xgTF+cuA== From: "Xing Ma" Content-Type: text/plain; charset=UTF-8 To: Subject: [PATCH 2/3] ext4: splice stranded fast commit staging queues before starting commit X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 X-Lms-Return-Path: Cc: "Theodore Ts'o" , "Andreas Dilger" , "Jan Kara" , "Baokun Li" , "Ojaswin Mujoo" , "Ritesh Harjani" , "Zhang Yi" , "Harshad Shirwadkar" , "Xin Yin" , "Xing Ma" , Date: Tue, 1 Dec 2026 00:38:18 +0800 X-Original-From: Xing Ma Content-Transfer-Encoding: 7bit References: <20261130163819.13819-1-maxing.lan@bytedance.com> Message-Id: <20261130163819.13819-3-maxing.lan@bytedance.com> In-Reply-To: <20261130163819.13819-1-maxing.lan@bytedance.com> X-Mailer: git-send-email 2.54.0 In both __jbd2_fc_end_commit() and jbd2_journal_commit_transaction(), j_fc_cleanup_callback (ext4_fc_cleanup()) splices FC_Q_STAGING into FC_Q_MAIN and releases s_fc_lock BEFORE JBD2_FAST_COMMIT_ONGOING / JBD2_FULL_COMMIT_ONGOING is cleared under j_state_lock. If a concurrent writer calls ext4_fc_track_template() or __track_dentry_update() in that window, it still observes the ONGOING flag set and inserts its inode or dentry update onto FC_Q_STAGING after ext4_fc_cleanup() has already drained it. When that writer then calls fsync() after the flag clears, ext4_fc_perform_commit() only processes FC_Q_MAIN and writes an empty fast commit while the update remains stranded on FC_Q_STAGING. Splice s_fc_dentry_q[FC_Q_STAGING] and s_fc_q[FC_Q_STAGING] onto the tail of FC_Q_MAIN under s_fc_lock at Step 1 of ext4_fc_perform_commit() so any stranded updates are included in chronological order. Fixes: aa75f4d3daae ("ext4: main fast-commit commit path") Cc: stable@vger.kernel.org Signed-off-by: Xing Ma --- fs/ext4/fast_commit.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/fs/ext4/fast_commit.c b/fs/ext4/fast_commit.c index 03ab9b8a2d983..e03a829e2a10a 100644 --- a/fs/ext4/fast_commit.c +++ b/fs/ext4/fast_commit.c @@ -1353,11 +1353,17 @@ static int ext4_fc_perform_commit(journal_t *journal, tid_t commit_tid) u64 locked_ns; /* - * Step 1: Mark all inodes on s_fc_q[MAIN] with - * EXT4_STATE_FC_FLUSHING_DATA. This prevents these inodes from being - * freed until the data flush is over. + * Step 1: Splice any entries that landed on STAGING while the + * previous commit was clearing its ONGOING flag, then mark all + * inodes on s_fc_q[MAIN] with EXT4_STATE_FC_FLUSHING_DATA. This + * prevents these inodes from being freed until the data flush is + * over. */ alloc_ctx = ext4_fc_lock(sb); + list_splice_tail_init(&sbi->s_fc_dentry_q[FC_Q_STAGING], + &sbi->s_fc_dentry_q[FC_Q_MAIN]); + list_splice_tail_init(&sbi->s_fc_q[FC_Q_STAGING], + &sbi->s_fc_q[FC_Q_MAIN]); list_for_each_entry(iter, &sbi->s_fc_q[FC_Q_MAIN], i_fc_list) { ext4_set_inode_state(&iter->vfs_inode, EXT4_STATE_FC_FLUSHING_DATA); -- 2.39.5