From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7AD521A680E for ; Wed, 26 Aug 2026 08:54:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787734496; cv=none; b=Sj0CQx2i5IHuq0/C4PG7aiDdKa2ZVjgD/PHTA9iSJwAZGj60bNVFm92Ap9M1sYyzzQwF3Vlg3OFYM+TgX5TPXRPXMrnxu40clE5DiYbBwTEQiy0K7YaiuTgC6bn7Wn3Vk0H++jVYqRl+cw8Ryxi1ntmuxZGUmwvrrRVSE11ff5E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787734496; c=relaxed/simple; bh=wt9A9vWjLIILGZ5qSUcJ7E2N0gZywAFxPO5dawQ/2AY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:Cc; b=aKcQ/jygSONnRnzcR6DpXmAxOgHfI0m7RdLN7AXD/Y0L/LYOZ0Qssg8rWYlCSBL7OUKluvnx35frknpHzEswdz5l/CMAAjzfqF2uWYC/06L6Qj6gyhvLyNtl7niiOiXMC6muLJDBwegYcGcrxzumds7pJhlFZzStEFeiX8mppy0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=A6XRvIzi; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="A6XRvIzi" Received: by smtp.kernel.org (Postfix) with ESMTPS id 148E4C2BCC7; Wed, 26 Aug 2026 08:54:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1787734496; bh=wt9A9vWjLIILGZ5qSUcJ7E2N0gZywAFxPO5dawQ/2AY=; h=From:Date:Subject:To:Cc:Reply-To:From; b=A6XRvIzib3dgyzzkwzYD/NiSlYPL+NwRzrC2U2+2ff2KSm15MRKWPBjrVW+cK9BzK 64yuz4EyUIw0H+DhB5ylsO6blHcB81SFPHu7fmKUB4LcZDEgp47Sj6u92e38aR6yb/ djCEsFpZCRhbUIxBxX6qk/+9qbAW8TCxPsf+JQgt1bxA5itsVgmnUv/1/aZxTy+Qf5 DN5Q4pRmUHElWBcuLqsAZSAmoKfBfee0X/5Gl4/8EODMp+LBsiKBtJ4vu6xLBvhiyY z+9DU2NZZDCq2E5iJs2565dZWMRQY6OHe0gfrM2lG/FKFPcYOvgpUVZJ3DR3ALLoZB ipRKhvjb4BVYw== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5C38C5DF97; Wed, 26 Aug 2026 08:54:55 +0000 (UTC) From: Jiucheng Xu via B4 Relay Date: Wed, 26 Aug 2026 16:48:56 +0800 Subject: [PATCH] f2fs: force out-place update for all writes on compressed file Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20260826-origin-dev-v1-1-c21271a82100@amlogic.com> X-B4-Tracking: v=1; b=H4sIAHiojmoC/x3MQQqAIBBA0avIrBPUSqSrRAvRyWajMUIE4t2Tl m/xf4OKTFhhEw0YH6pU8oCeBITL54SS4jAYZaxy2snClCjLiI9U6IKd0ehl9TCCm/Gk95/tR+8 faHtsv1wAAAA= X-Change-ID: 20260818-origin-dev-0e8c63e2145a To: Jaegeuk Kim , Chao Yu Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, jianxin.pan@amlogic.com, tao.zeng@amlogic.com, tuan.zhang@amlogic.com, Jiucheng Xu X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1787734494; l=1790; i=jiucheng.xu@amlogic.com; s=20250821; h=from:subject:message-id; bh=Ub+8UxlQLsITTLZwPi9aaEIQqjRvJlIkm0jc93D0BgM=; b=WVt1NdpjMr8BiV8T38rO0RQGvDFlt9pBD5Ay2UhllXIRdYb4A5QNZ62vQKh+XTb4M9i7zOKpa gOLLWnnR+4VA0HGNGZ7L10B/+KNRjPDiDlFEtI/Ul6GRoHthvS5Hfn8 X-Developer-Key: i=jiucheng.xu@amlogic.com; a=ed25519; pk=Q18IjkdWCCuncSplyu+dYqIrm+n42glvoLFJTQqpb2o= X-Endpoint-Received: by B4 Relay for jiucheng.xu@amlogic.com/20250821 with auth_id=498 X-Original-From: Jiucheng Xu Reply-To: jiucheng.xu@amlogic.com From: Jiucheng Xu For compressed file, compressed write may fail and fall back to raw write. If in-place update(IPU) is allowed, raw data could be written into disk before cluster metadata is updated from compressed state to raw state. Sudden power-cut during this window will result in inconsistency: raw data on disk but metadata still expects compressed content, which causes decompression failure when reading the file later. To eliminate this risk completely, force out-place update for all write operations on compressed file, so IPU will never be used. Signed-off-by: Jiucheng Xu --- fs/f2fs/data.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 6ae0eb37d20f96ed51a8124f59ba90dabf632fb5..aaeea561dcd30681b9b37f2f6f0493ed58ec2fe0 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -2973,10 +2973,12 @@ bool f2fs_should_update_outplace(struct inode *inode, struct f2fs_io_info *fio) return true; if (f2fs_used_in_atomic_write(inode)) return true; - /* rewrite low ratio compress data w/ OPU mode to avoid fragmentation */ - if (f2fs_compressed_file(inode) && - F2FS_OPTION(sbi).compress_mode == COMPR_MODE_USER && - is_inode_flag_set(inode, FI_ENABLE_COMPRESS)) + /* + * rewrite low ratio compress data w/ OPU mode to avoid fragmentation. + * If IO comes from compressed write path and fallback to raw write, + * force out‑place to prevent metadata‑data inconsistency. + */ + if (f2fs_compressed_file(inode)) return true; /* swap file is migrating in aligned write mode */ --- base-commit: 0a1703eba23707e3b2edfa2a2329352e7abc0ffa change-id: 20260818-origin-dev-0e8c63e2145a Best regards, -- Jiucheng Xu