From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.161.49 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796162790; b=iv1z2aglfJdyxgtRhbai4H17JZs23X00835gwbEZJAcQIatkgVm7l1+CNCWsa7Q3/ljO DfMd6gsQ5e65MD7/rHLdmq8HD6InMeH+SAoNATpPiLqua31xOtz04iB5nq0L6t8/1i/3o wCfFs2BxRWxThnB8JOAUfgm0vba/I/c+grj8IM7SXM/v/V5+AvLjE4pN0WtI8yQeTP/uh pjEIMlUvph0LdbMl5oBGzCD+hVrUlZxU4n4gE6mJHS61Pa7XAaWLGta565ZOrGNTRcGIp 6C/eBkrKz4Vt4Z2snAR08VSF5GxUg5NXyv2vbIfuAhA6vL+ww5LImgQglXA7rHEU7Gg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796162790; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=L4Aa2dYnVrcytDNX6Vmgq9HLqCrEveSYwbApzC2x56A=; b=hEEpia+vft+19ZinZ5Rz/W9zT/+Lqg0Yc4iBQcJE9oaslLnoX2gMN97FtKGwiota73Ya Tlnbaiyw6G2fZfPsWSKvSPTXkzSEuOmEMhpG8/C705whBB6Z+UU9hA79w6LlOPo3MQKio g/dbmjH7yqRh8aR2ptGUoI7zhAJ1opHGyTisywyCadzNMsWJBl2A37oPL/zCDx68HeOq4 b80MsaT+uO72j6smHYEfFeg4u6d5+fnAeHegTHxIRklAXsJnHMndMGy6bRFxkFBFZRvHO Pqr2EAcO6Usls26z4+qZtK4MZVTaaCDCE6m3haB3QmeqAmdl6tNZR8PoZ2EfioHtO5g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=BQa08FFE; arc=none smtp.remote-ip=209.85.161.49 Received: from mail-oo1-f49.google.com (mail-oo1-f49.google.com [209.85.161.49]) (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 22AE0606A331 for ; Tue, 1 Dec 2026 22:06:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 22AE0606A331 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=BQa08FFE Received: by mail-oo1-f49.google.com with SMTP id 006d021491bc7-703be215729so5482040eaf.1 for ; Tue, 01 Dec 2026 14:06:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796162789; x=1796767589; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=L4Aa2dYnVrcytDNX6Vmgq9HLqCrEveSYwbApzC2x56A=; b=BQa08FFEgk4Js7dA8hPMDAeEO0LjTAZKJ9R8ui5hwPWDs7i6uOG+je6qhKzfKmVBYC 4hi+crPvMKLeqsW5xA3NZ0ic/WHmMncVq/KNDx3XintGHYoG3D+1PkzHQvOvvT7ZmXtf omO+WjAOG1iRds7nvQGw3hd09xMzVp4UsFtyN4R6Yo0T+K10WHcKtxLwhdvGxX9a7G3s WaokaImynwDQNevgOdiz05x/ysxkaf1Q2Li3n0qdyFVFmPgSiGgUl6dPEDIFljw20Sab AFIMyoXpg/CB2rUvf9DeIGC7c7XbcAFwDRSak/PQrTCroD8An1SoXgtx17CIiMC5290H z5bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796162789; x=1796767589; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=L4Aa2dYnVrcytDNX6Vmgq9HLqCrEveSYwbApzC2x56A=; b=gs8ds6yITcT+hWZC0arUwTZJZZvMxEZkpOBfA2obvAJJjjsjD25VWdwhggOcZzKYID vxyENn0RKNCnxu/lIjX17UlO7k33I4MHgWtvVik0bWLbFZjYzxQ6JxoguiGW58tpiREy OdikcddDCT8T/9fvEeiwPd9oJe4VZYse9Ve1vieYYVAjkpKr/vJIv1gRDWN2PCZuElLD jrATyREYYVtZFfu1+P1gR1+yQPPLtDojLYS8dPQnrPv2hIU/3LEXndNTZqLQSJpxCfFo SRql1Y7LqP+M6gN5axCa83wgnzPDfDt1iB1vZC19RX8xFw2TfE5iPRcpx32e4TzuqNr0 NpWA== X-Forwarded-Encrypted: i=1; AL+hErGTmWYwiGMtETBlAQQ4/I9tQeliTF/AGBpnRgVdzF986WD4FxtND4SVEB5p7e6CMTlNB5WBp5+9MbE6+w8=@vger.kernel.org X-Gm-Message-State: APuU4Z8NkAqMLe371MGeXYuqKnhzAkj/XyEYBi+xCRCsuvicJprYJhgy 3NyAF+wPoCMPphAaSrv7AW+lvTWLoPGg8riQ1pJH3CJLfH5ab9fxOGFx X-Gm-Gg: AZFdTZfJsFxw2t8CKk2wInTw7sYuZoVvSJOxZoBuRytKm/zlD/toZFH4LoO16Fp9Qu9 rqACmP0rG9RB7ax5sy7Phc1zCCStyn+PnJqQJSC17JrIO86EuOWEj3Bi+EGF4c2Uw2tHaAsAX2D N5VlEdIxRJR3ZJRpHpqSoO6F6MEMC7k7n+AZePNSNzfYMaOjdpsLBqhcHq0bOIUtqXiXlcnjnnD 6/MX91ZSVBL1yfeWgrdRVbRi4BnOSLjvz7Kbd+2NdlwXxrL08cl2R+fJNvn8/JrlwVzw7MxZYpm 5whNUWtrc+adAQcLZm3+8+vqeyw4c80f3cgVD0z1vaPOGmAiuGnf0qnqo9P67CUgtIYOI7mcuq5 FGT3R1XrIIzxCUXv7LvcbEYL8CFB3LZJOOpNKy4ksM8QDUL9Ae+8j8cB4ET2bW0g4HCB+Gy8NvS N7z/DSTBBEeDTPkQwYuuIe8CKM+IyeVXJr448JSmy7WP5GfM25+BmOJlzKLuobRm56oeEmv5+M1 MVZ0jBnStV2m1GkgtBczUNfl/7prvKNb4WrGo+tnWbU9kfOO0XpMupGMMDWaDyUKpCXWpr2lhdi I/oAI/wKECFlJA519BWGK+Klx1fhp8f6jSW0DGztuNhsv7bvq/GG6TVUfIVBRUCtF+s3T5khKpv 9P22e7WFQfoX/QCLmnD4i8a3N5BZOoFvieqVFpoyyvNdWXe0= X-Received: by 2002:a05:6820:f026:b0:71a:ecfc:4438 with SMTP id 006d021491bc7-71b39438e27mr29191137eaf.24.1796162789079; Tue, 01 Dec 2026 14:06:29 -0800 (PST) Received: from Wes-PC.localdomain (108-212-132-20.lightspeed.irvnca.sbcglobal.net. [108.212.132.20]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-71bbfc14667sm4560280eaf.5.2026.12.01.14.06.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2026 14:06:28 -0800 (PST) From: Wesley Atwell To: Theodore Ts'o Cc: Andreas Dilger , Baokun Li , Jan Kara , Ojaswin Mujoo , "Ritesh Harjani (IBM)" , Zhang Yi , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, Wesley Atwell Subject: [PATCH] ext4: keep internal quota inode growth out of fast commits Date: Tue, 1 Dec 2026 15:06:23 -0700 Message-ID: <20261201.da276679711b4a31aaa4af05bfcbc1be@gmail.com> X-Mailer: git-send-email 2.56.1 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Fast-commit replay loads INODE records as ordinary inodes and rejects internal quota inode 3. On the unmodified ext4 dev tree, growing that inode's quota file followed by a crash made recovery fail to mount. Mark internal quota-inode mapping and logical-size growth ineligible before mutation, including growth within an already mapped block. Recheck ineligibility after active journal handles drain. If another commit was ongoing, complete the ineligible transaction through JBD2 instead of treating that commit as proof of durability. In QEMU, quota-inode mapping and logical-size growth recovered after the full-commit fallback. Ordinary updates to existing quota records remained fast-commit eligible. This does not fix lost quota charges. Xing Ma's separate series addresses the remaining generic fast-commit tracking and waiter races. This contribution was developed with AI assistance. Fixes: 8016e29f4362 ("ext4: fast commit recovery path") Link: https://lore.kernel.org/all/20261201013742.1562967-1-maxing.lan@bytedance.com/ Signed-off-by: Wesley Atwell --- fs/ext4/fast_commit.c | 17 ++++++++++++++++- fs/ext4/fast_commit.h | 1 + fs/ext4/inode.c | 5 +++++ fs/ext4/super.c | 4 ++++ include/trace/events/ext4.h | 4 +++- 5 files changed, 29 insertions(+), 2 deletions(-) diff --git a/fs/ext4/fast_commit.c b/fs/ext4/fast_commit.c index 9beb423b208f8..0c072cf800a4e 100644 --- a/fs/ext4/fast_commit.c +++ b/fs/ext4/fast_commit.c @@ -1414,13 +1414,20 @@ static int ext4_fc_perform_commit(journal_t *journal, tid_t commit_tid) * doing logical-to-physical mapping. */ alloc_ctx = ext4_fc_lock(sb); + /* A drained handle may have made this transaction ineligible. */ + if (ext4_test_mount_flag(sb, EXT4_MF_FC_INELIGIBLE)) { + ret = -EAGAIN; + goto out_unlock_fc; + } 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_COMMITTING); } +out_unlock_fc: ext4_fc_unlock(sb, alloc_ctx); - ret = ext4_fc_snapshot_inodes(journal, inodes, inodes_size, + if (!ret) + ret = ext4_fc_snapshot_inodes(journal, inodes, inodes_size, &snap_inodes, &snap_ranges, &snap_err); jbd2_journal_unlock_updates(journal); locked_ns = ktime_to_ns(ktime_sub(ktime_get(), lock_start)); @@ -1604,6 +1611,13 @@ int ext4_fc_commit(journal_t *journal, tid_t commit_tid) restart_fc: ret = jbd2_fc_begin_commit(journal, commit_tid); if (ret == -EALREADY) { + /* An ongoing commit may not cover this ineligible transaction. */ + if (ext4_test_mount_flag(sb, EXT4_MF_FC_INELIGIBLE) && + !jbd2_transaction_committed(journal, commit_tid)) { + ext4_fc_update_stats(sb, EXT4_FC_STATUS_INELIGIBLE, 0, 0, + commit_tid); + return jbd2_complete_transaction(journal, commit_tid); + } /* There was an ongoing commit, check if we need to restart */ if (atomic_read(&sbi->s_fc_subtid) <= subtid && tid_gt(commit_tid, journal->j_commit_sequence)) @@ -2726,6 +2740,7 @@ static const char * const fc_ineligible_reasons[] = { [EXT4_FC_REASON_MIGRATE] = "Inode format migration", [EXT4_FC_REASON_VERITY] = "fs-verity enable", [EXT4_FC_REASON_MOVE_EXT] = "Move extents", + [EXT4_FC_REASON_QUOTA_INODE] = "Quota inode changed", }; int ext4_fc_info_show(struct seq_file *seq, void *v) diff --git a/fs/ext4/fast_commit.h b/fs/ext4/fast_commit.h index 2f77a37fb1018..6889161dbe0b6 100644 --- a/fs/ext4/fast_commit.h +++ b/fs/ext4/fast_commit.h @@ -100,6 +100,7 @@ enum { EXT4_FC_REASON_MIGRATE, EXT4_FC_REASON_VERITY, EXT4_FC_REASON_MOVE_EXT, + EXT4_FC_REASON_QUOTA_INODE, EXT4_FC_REASON_MAX }; diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 07a62d8569d31..eec8cf33a4e73 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -929,6 +929,11 @@ int ext4_map_blocks(handle_t *handle, struct inode *inode, internal_handle = true; } + /* Internal quota inode mappings cannot be replayed by fast commit. */ + if (ext4_is_quota_file(inode) && + is_special_ino(inode->i_sb, inode->i_ino)) + ext4_fc_mark_ineligible(inode->i_sb, + EXT4_FC_REASON_QUOTA_INODE, handle); ext4_fc_track_inode(handle, inode); /* * New blocks allocate and/or writing to unwritten extent diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 880f664d6c04b..76d617e023d2c 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -7539,6 +7539,10 @@ static ssize_t ext4_quota_write(struct super_block *sb, int type, (unsigned long long)off, (unsigned long long)len); return -EIO; } + /* Size can grow even when the quota inode's last block is mapped. */ + if (inode->i_size < off + len && ext4_is_quota_file(inode) && + is_special_ino(sb, inode->i_ino)) + ext4_fc_mark_ineligible(sb, EXT4_FC_REASON_QUOTA_INODE, handle); do { bh = ext4_bread(handle, inode, blk, diff --git a/include/trace/events/ext4.h b/include/trace/events/ext4.h index 92048da9dae43..f73288d0d6ffe 100644 --- a/include/trace/events/ext4.h +++ b/include/trace/events/ext4.h @@ -105,6 +105,7 @@ TRACE_DEFINE_ENUM(EXT4_FC_REASON_ENCRYPTED_FILENAME); TRACE_DEFINE_ENUM(EXT4_FC_REASON_MIGRATE); TRACE_DEFINE_ENUM(EXT4_FC_REASON_VERITY); TRACE_DEFINE_ENUM(EXT4_FC_REASON_MOVE_EXT); +TRACE_DEFINE_ENUM(EXT4_FC_REASON_QUOTA_INODE); TRACE_DEFINE_ENUM(EXT4_FC_REASON_MAX); #undef EM @@ -141,7 +142,8 @@ TRACE_SNAP_ERR { EXT4_FC_REASON_ENCRYPTED_FILENAME, "ENCRYPTED_FILENAME"}, \ { EXT4_FC_REASON_MIGRATE, "MIGRATE"}, \ { EXT4_FC_REASON_VERITY, "VERITY"}, \ - { EXT4_FC_REASON_MOVE_EXT, "MOVE_EXT"}) + { EXT4_FC_REASON_MOVE_EXT, "MOVE_EXT"}, \ + { EXT4_FC_REASON_QUOTA_INODE, "QUOTA_INODE"}) TRACE_DEFINE_ENUM(CR_POWER2_ALIGNED); TRACE_DEFINE_ENUM(CR_GOAL_LEN_FAST); base-commit: aceadbccd428fb8e6593b27a3091d961f80225d1