From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.127.231.112 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796060302; b=rSwFYzGprDx/NgLVHTZVfBOUf7HUuX2wVcN2KVpSkt5z2OjuYYxVq9LebervfpXwFKsB LqlQ5hutq9F6ellZ6dC1ZPkZQvOZusz5EFdmD5ieAUsNC+pf00r4e8AqGEQOhbs1wMXYJ Vnyy/BCOMvK0pEfyPx2IZuZtV/XPw6UL+w+u4z4+nx75ZjqhUxb066mbnjw8jsdjvSpvF kieUu106VtSLoyC559oYCsg4PsfOemepR6hclSEhBKVnNvkFUMWH78vQBrv4Na1nhLxv6 /5ZOPz054xwVbvrQq3q1MHP1NNjr04FFqKN4Env2UxX/hwBK5kS2XDL6ydue3y9wfPQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796060302; h=DMARC-Filter:DKIM-Signature:Cc:X-Lms-Return-Path:Message-Id: Mime-Version:Content-Type:To:From:Subject:Date: Content-Transfer-Encoding:X-Original-From; bh=1jCTl2Kx3DE3oBLZzPWWUhHn3dX+K7cKtcXJr+EL1Rg=; b=wsjWq8fDUbVmDDf2tjUhPHLFKQVBxqBHUNGsWLsaCJOsrR/lS17tHl2NmI21uhgnyfhc V2RCGHwQ7u9G4ZGjVF9oAJqu0oDm64PiMhcxMlDqTv3hNFi2U5TufHDUNp31hcRyjdxp7 CU8kQBQh+uJT2WMdJvxTXcUC9Q7cAYR+AIBHkmzghO3CeC88WWmS9weh5EdjGVENxREnT oCVFUB8bCPj7uR5Z6+q9GYIWHQcqWgHXrchXxsmKuEIZCZa+P8xT7vUJaGtOHNi7yQi+O ZUKnMzAxAjLfrkCLXTe7MoC9Yrzf9JmWgqGGqN5IZQdMmbhlj46+H7Do8q815yVbbCA== 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=Eektxzqh; arc=none smtp.remote-ip=209.127.231.112 Received: from va-2-112.ptr.blmpb.com (va-2-112.ptr.blmpb.com [209.127.231.112]) (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 E5B9C606A31C for ; Mon, 30 Nov 2026 17:38:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E5B9C606A31C 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, unprotected) header.d=bytedance.com header.i=@bytedance.com header.a=rsa-sha256 header.s=2212171451 header.b=Eektxzqh DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=2212171451; d=bytedance.com; t=1796060296; h=from:subject: mime-version:from:date:message-id:subject:to:cc:reply-to:content-type: mime-version:in-reply-to:message-id; bh=1jCTl2Kx3DE3oBLZzPWWUhHn3dX+K7cKtcXJr+EL1Rg=; b=EektxzqhCcik1V4YMfJJGV8iWduTLzqaRAZ8MkBpOsjW3gqaS9ElmViE/vMlEdWQB1VHYw 4wotMC/fegrFvCpbc4WJtgQ7KRJPRYiJvJpYzMA5rgOLCbSxylJZ6EWqbVN+UKejOgUXRv IDgNUL87LKJJLJN+hc67543TV0xirOus0zE22BuYnSEnpELF5HsIkNx3LGGXEsGPJ/STC+ xMrWhFiJTZW4AFrFkFC13ExQ9/TQtdtMRfykMnHLX6xiiiS5wf++A8kVACKHUb9D3MuLWa M5NTWJms7SHy9BSA/D++Rf2dts6fdGW3danps/WfCIbH9P+40V08UiHej3M3YA== Cc: "Theodore Ts'o" , "Andreas Dilger" , "Jan Kara" , "Baokun Li" , "Ojaswin Mujoo" , "Ritesh Harjani (IBM)" , "Zhang Yi" , "Harshad Shirwadkar" , "Xin Yin" X-Lms-Return-Path: Message-Id: <20261201013742.1562967-1-maxing.lan@bytedance.com> 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 Content-Type: text/plain; charset=UTF-8 To: From: "Xing Ma" Subject: [PATCH v2 0/3] ext4: fix concurrent fast commit durability and tracking races Date: Tue, 01 Dec 2026 01:37:42 +0800 Content-Transfer-Encoding: 7bit X-Original-From: Xing Ma Under concurrent writers and fsync() workloads (reproducible with xfstests generic/455 and MKFS_OPTIONS="-O fast_commit"), ext4 fast commit has three concurrency races that lose fsync()'d updates or leave extents inconsistent after crash recovery: 1. __jbd2_fc_end_commit() and jbd2_journal_commit_transaction() invoke ext4_fc_cleanup() before clearing JBD2_FAST_COMMIT_ONGOING / JBD2_FULL_COMMIT_ONGOING, letting concurrent updates land on FC_Q_STAGING after cleanup drains it and remain stranded during the next fast commit. 2. ext4_fc_commit() skips committing when an already-ongoing fast commit increments s_fc_subtid, even though the waiting caller's updates were queued on FC_Q_STAGING or marked EXT4_STATE_FC_REQUEUE and were not included in that commit. 3. ext4_fc_track_{inode,range,create,link,unlink}() and ext4_rename() skip tracking whenever EXT4_MF_FC_INELIGIBLE is set without comparing handle->h_transaction->t_tid against s_fc_ineligible_tid, dropping tracking for transaction T + 1 while transaction T finishes its full commit; ext4_fc_cleanup() also cleared EXT4_MF_FC_INELIGIBLE when full == 0. Changes since v1 (addressing Sashiko AI review): - Patch 1 (was Patch 2 in v1): Instead of splicing FC_Q_STAGING in ext4_fc_perform_commit() Step 1 (which could invert dentry order or split concurrent handles), fix the root window directly by clearing JBD2_FULL_COMMIT_ONGOING / JBD2_FAST_COMMIT_ONGOING inside ext4_fc_cleanup() while still holding s_fc_lock (and reading j_flags under j_state_lock in ext4_fc_track_template() / __track_dentry_update()). Fix Fixes: tag to bdc8a53a6f2f. - Patch 2 (was Patch 1 in v1): Increment s_fc_subtid inside ext4_fc_cleanup() under the same write_lock(&journal->j_state_lock) that clears JBD2_FAST_COMMIT_ONGOING so ext4_fc_commit() never double-counts target_subtid during cleanup. - Patch 3: Export ext4_fc_handle_eligible() and use it in ext4_rename() to avoid torn rename tracking; serialize the slow-path check under s_fc_lock so a cleared s_fc_ineligible_tid == 0 is never passed to tid_gt(); inline ext4_fc_eligible() into ext4_fc_eligible_test() to avoid -Wunused-function when CONFIG_EXT4_KUNIT_TESTS=n. Testing on tytso/ext4.git dev (aceadbccd428f): - W=1 build clean with both CONFIG_EXT4_KUNIT_TESTS=y and =n. - KUnit ext4_fast_commit_test: 11/11 PASS, 0 lockdep warnings. - xfstests generic/455 (-O fast_commit): 7/26 FAIL (~27%) before; PASS after (0 dmesg / lockdep / e2fsck errors). Xing Ma (3): jbd2, ext4: clear commit ongoing flags under s_fc_lock in ext4_fc_cleanup() ext4: do not skip fast commit for updates queued during ongoing commit ext4: keep tracking newer transactions while older tid is fc-ineligible fs/ext4/ext4.h | 2 ++ fs/ext4/fast_commit.c | 95 +++++++++++++++++++++++++++++++++++++++---- fs/ext4/namei.c | 4 +- fs/jbd2/commit.c | 15 ++++--- fs/jbd2/journal.c | 17 +++++--- include/linux/jbd2.h | 5 ++- 6 files changed, 115 insertions(+), 23 deletions(-) base-commit: aceadbccd428fb8e6593b27a3091d961f80225d1 -- 2.39.5