From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 15D2C331EBB for ; Wed, 12 Aug 2026 08:59:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786525157; cv=none; b=MUF3P3robTKmImxjOb8ifWj72tsEM5ozoFb9Ox8tSZlpmGzvuyBuqVQnksE2xztfne+tfBLWgmXRRR5fVHWCKXgvtlX2SJoOJj/p4GChxCwqUuPohrNKD4aSPBJ2oLrxBWt+Z1bZ7mQUzUhvxJysE52LnOfu3GEXEQ+1IFIgKjM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786525157; c=relaxed/simple; bh=mDU0d56q65OrXTWZF504LvcIyKjvclaBtvI41qlrmq8=; h=Message-ID:Date:MIME-Version:Cc:Subject:To:References:From: In-Reply-To:Content-Type; b=K/2kOssVATOTal9LiT/oUtaymr8+GUy0QPvkamjkwuikddovVys8xmRafYLDXi9jYSpNwLW0sQG0DOeHrQMNQouJGDbEhCfbyphnClXviVU/GLYJTRbm5VhUPvbX7kVetYiZyzY6Fusms1B5ltgOy5x+BSbqSXN1gQmdeBR7Oxo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=R9HmW+eF; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="R9HmW+eF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 407111F000E9; Wed, 12 Aug 2026 08:59:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1786525155; bh=+sXSWsDHiGJ/oqKpPmE3usoB20L3uj2n6Y1Q/dywr44=; h=Date:Cc:Subject:To:References:From:In-Reply-To; b=R9HmW+eFR5PvIAJfrs1UPVEPr83axuziR2Sndt6ibGVRubkp94sCD1CyyUmL0Jr0k ZvDZ2bPSuwqwGG1XH0JUjN3tPUhL+NeBgjBhkJ5wvzGqY2fLhEV81kvx/sGbFa9j+K TNT6ptG7m2k/2j4kBiI5ITRkhHGH97Y8FluPFncfvXmCJwOdCkzcCRbsqeg9EGBeX2 NUqLV4MT3mTu3zSqNpavZxBZm1/eJ+tlQui5bsMDTqjIXOf+2qorTpKrLWXsr0Q3Mw elGq395mufPOy3dwjvP9J38wp0UKG1DcQWaRdYWH0vFh0dfl9b1ECnnP9twXPzaNf/ z3mOuXoFufYlQ== Message-ID: <5e5aa114-3425-4d26-a9c4-c21922eb67be@kernel.org> Date: Wed, 12 Aug 2026 16:59:12 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Cc: chao@kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, qiwenjie@xiaomi.com, stable@kernel.org Subject: Re: [PATCH] f2fs: check cp_error before committing atomic writes To: Wenjie Qi , jaegeuk@kernel.org References: <20260806061807.3267392-1-qiwenjie@xiaomi.com> Content-Language: en-US From: Chao Yu In-Reply-To: <20260806061807.3267392-1-qiwenjie@xiaomi.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 8/6/26 14:18, Wenjie Qi wrote: > F2FS checks cp_error before entering the ioctl path, but cp_error can be > set after that and before atomic commit starts replacing blocks. > > In that case, F2FS_IOC_COMMIT_ATOMIC_WRITE returns -EIO, but the current > mount can still expose the new data before remount. > > Check cp_error again in f2fs_commit_atomic_write() after > filemap_write_and_wait_range() and before block replacement starts. > > Fixes: 3db1de0e582c ("f2fs: change the current atomic write way") > Cc: stable@kernel.org > Signed-off-by: Wenjie Qi > --- > fs/f2fs/segment.c | 3 +++ > 1 file changed, 3 insertions(+) > > QEMU validation: > - before fix, FAULT_CHECKPOINT made COMMIT_ATOMIC_WRITE fail with -EIO, > while the current mount still exposed the new data; after remount, the > file reverted to the old data. > - after fix, the same fault still failed with -EIO, and both the current > mount and the remounted filesystem kept the old data. > - no-fault smoke still committed the new data successfully and preserved it > across remount. > > diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c > index 0b706568b034..e6384dd2e916 100644 > --- a/fs/f2fs/segment.c > +++ b/fs/f2fs/segment.c > @@ -408,6 +408,9 @@ int f2fs_commit_atomic_write(struct inode *inode) > if (err) > return err; > > + if (unlikely(f2fs_cp_error(sbi))) > + return -EIO; I suspect even we add cp_error in more places, we may suffer both conditions: 1) expose new data to userspace if cp_error occurs before f2fs_do_sync_file() after f2fs_commit_atomic_write(). 2) not expose new data to userspace if we cp_error occurs before or during __f2fs_commit_atomic_write(). Thanks, > + > f2fs_down_write(&fi->i_gc_rwsem[WRITE]); > f2fs_lock_op(sbi, &lc); >