From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.127.230.112 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796079979; b=tvol3tPe3icXiPukJoJXAitUvyMAxo0vVcDWyazQHYEKyVT9aYyxd6+EpBJo1FE4CDDa 4JO3aU8/PjPkHq0vWvzWAY0DvGkrnNrTJQnDGNaGOrTRrxAJFwA1TST60DB78IMYgiLYf sDDvuKmZveMwBhWbGvujJUxS9QL+FglqSPTin5RJJphBAISxvupACVuMD0LWuu/9SLAWi hFU1gVto2sCy2ROImCvOBZYhRXKK6sn9o23rU2jARhKqIfyv4x1C7PsR+NyImb/jgu4cA xP8ackET3J+iTVAT5xcmuTtzs89TFsBbVMQhxHvxkXeMHYwmMYx5ENOsyIkabhY9aiQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796079979; h=DMARC-Filter:DKIM-Signature:Cc:Subject:X-Original-From: X-Lms-Return-Path:Content-Transfer-Encoding:To:From:Date:Message-Id: Mime-Version:Content-Type; bh=t7VXKgvpCKVe+yCilfiPKsyuWzyAEV251PtfuIWYYnw=; b=tgZpx5GqNkHMgvWkQR7ZHymGmOXOWjUF1KgXbMvjDculZe/l2QG/p0mTNPSQj3HswQuH ZGUPtmC6WqckmJM1QVoSveCngLL9JAoXjEPnuJP1gz6Syze4TUH1ONGf9D1nvtGDfkzmF spCsJ0Bh12PfVgn+KYc1tkL7n6MMjMqf3XHocqgcPS3xVYXvsiD/A+Tf3W5sfHc6WKta3 ako0dtS31ma4T0p1V+SOSePp7PYohK2lIxPimTMN6FHWRZV8Q0VA4/GaCmN/cGFcuW/Qp 3qG00SXGjCVgKVNE8qk1nG9NkBxQdug4lkBcpLYRgrKhaOFRC/ZTIwrGgsIRf+CVYNQ== 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="g76xN/+H"; arc=none smtp.remote-ip=209.127.230.112 Received: from va-1-112.ptr.blmpb.com (va-1-112.ptr.blmpb.com [209.127.230.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 89155606A31A for ; Mon, 30 Nov 2026 23:06:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 89155606A31A 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=g76xN/+H DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=2212171451; d=bytedance.com; t=1796079972; h=from:subject: mime-version:from:date:message-id:subject:to:cc:reply-to:content-type: mime-version:in-reply-to:message-id; bh=t7VXKgvpCKVe+yCilfiPKsyuWzyAEV251PtfuIWYYnw=; b=g76xN/+HkrqJ94AxAkvq3x3af+Vg7m1N3+HXH6hgEyEP5Gh5w5NIKh3oiwxQg0afxN9Hn0 SnLN+Tk1nyC+nHEf6o3/d340j/eCi/QBeZuh/XMQsbkh0AWxpSAPrmno1UvHNRvC4qn8Hi oDdQCXcYqJrnddE1Bk/AzqPtkycDtAsQsuYEMC63724Mx6I7UtojPqL0EjWOIDM+Ade+Ph SaiMYYqejBYC8zfkmKgGl/wB2bC2k9mtLoNAtti7hUisawMX31j7Vhqay/FO0zEenwQSpC vjSdFvP8X99hEdxiTdKieq3V9RektENRcl0ZQBokK50OLdIan7/sPO/gZJra6w== Cc: "Theodore Ts'o" , "Andreas Dilger" , "Jan Kara" , "Baokun Li" , "Ojaswin Mujoo" , "Ritesh Harjani (IBM)" , "Zhang Yi" , "Harshad Shirwadkar" Subject: [PATCH v3 0/2] ext4: fix fast commit orphan inode replay and truncate range tracking X-Original-From: Xing Ma X-Lms-Return-Path: Content-Transfer-Encoding: 7bit To: From: "Xing Ma" Date: Tue, 01 Dec 2026 07:05:58 +0800 Message-Id: <20261201070558.4017023-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 This 2-patch series fixes two crash-recovery bugs in ext4 fast commit on tytso/ext4.git dev (aceadbccd428f): 1. Patch 1 ("ext4: fall back to full commit for unlinked or orphan inodes in fast commit"): Fast commit does not log orphan list updates. Snapshotting an unlinked open inode (i_nlink == 0) emits EXT4_FC_TAG_INODE with i_links_count == 0, which causes ext4_fc_replay_inode() to fail ext4_iget() with -ESTALE -> -EFSCORRUPTED and abort journal recovery. Snapshotting a mid-truncate orphan inode logs shrunk i_size with unfreed extents. Fall back cleanly to a full JBD2 commit via -ECANCELED, and add KUnit coverage in fast_commit-test.c. 2. Patch 2 ("ext4: track truncated block range in ext4_truncate() for fast commit"): ext4_fc_track_range() for truncation is only called in ext4_truncate_down(), missing same-size ftruncate(fd, oldsize) dropping FALLOC_FL_KEEP_SIZE post-EOF blocks, cross-transaction ext4_truncate() handles, and handle restarts in ext4_ext_remove_space() / ext4_ind_truncate(). Insert an EXTENT_STATUS_HOLE entry for [last_block, EXT_MAX_BLOCKS - 1] in ext4_ext_truncate() (when fast commit is enabled and the inode is still linked) and call ext4_fc_track_range() in ext4_truncate(). Changes since v2 (addressing Sashiko AI review): - Patch 1: unchanged (no issues found). - Patch 2: * In ext4_ext_truncate(), insert EXTENT_STATUS_HOLE covering [last_block, EXT_MAX_BLOCKS - 1] after ext4_ext_remove_space() succeeds (when JOURNAL_FAST_COMMIT is enabled and i_nlink != 0), matching ext4_punch_hole(). Without this hole entry, ext4_fc_snapshot_inode_data() hits EXT4_FC_SNAP_ERR_ES_MISS and falls back to a full commit (even on a no-op same-size ftruncate() + fsync()). * Track [last_block, EXT_MAX_BLOCKS - 1] in ext4_truncate() (matching ext4_ext_truncate()'s exact last_block calculation) guarded by last_block < EXT_MAX_BLOCKS. Changes since v1 (addressing Sashiko AI review): - Patch 1: unchanged (no issues found). - Patch 2: * Move ext4_fc_track_range() after `if (err) goto out_stop;` and guard it with `!ext4_handle_is_aborted(handle)`. * Call ext4_fc_track_range() for both extent-based and indirect-mapped inodes; indirect-mapped inodes have no hole entry inserted and continue to fall back safely to a full commit. Testing on tytso/ext4.git dev (aceadbccd428f, -O fast_commit): - Patch 1: xfstests generic/764 fails 100% before ("Structure needs cleaning" / "JBD2: journal recovery failed") and passes after; KUnit ext4_fast_commit_test 11/11 PASS. - Patch 2: verified via /proc/fs/ext4//fc_info that same-size ftruncate() (both dropping 64K FALLOC_FL_KEEP_SIZE post-EOF blocks and no-op same-size ftruncate(), warm and cold cache), truncate-to-0, and shrinking truncate all commit via fast commit (commits++, ineligible unchanged, es_miss == 0) and survive dm-flakey crash recovery with expected block counts and clean e2fsck -fn. Xing Ma (2): ext4: fall back to full commit for unlinked or orphan inodes in fast commit ext4: track truncated block range in ext4_truncate() for fast commit fs/ext4/extents.c | 5 +++++ fs/ext4/fast_commit-test.c | 18 ++++++++++++++++++ fs/ext4/fast_commit.c | 17 +++++++++++++++++ fs/ext4/inode.c | 10 ++++++++++ 4 files changed, 50 insertions(+) base-commit: aceadbccd428fb8e6593b27a3091d961f80225d1 -- 2.39.5