From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796111917; b=rS4zidUliuN1/chbvDQV0y+d0Q14paJh5ViCakFMHO7eK8OnH+Rmrmt9pByat+Dok+H/ Pob6iOD2Wfs75MMM1pADftSyUkAQ6JII7LKXJftVr++iooGf3cCSM4gBe5sMKgmUuv4B6 tvtC8rTZba1b/8gQWXmllDnUFv82SpQBgbOYOzAEA4jnvZWZm74VbRNNzjZYJXzASqG42 qf/n9SMJkR86qxvQs7tQw7uJdCPuVgyPH6H+l+zLn1wlk2WZRq5zJKveUQn/NgGsc+w65 pB3u6hrb9Fc27In0urLvKJP9zGkJf5Kul9b4HkHJHFwXcziYiPOq+KgS3t6FtmNmsiA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796111917; h=Received:DKIM-Signature:Message-ID:Date:MIME-Version:User-Agent:Cc: Subject:To:References:Content-Language:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; bh=bDfbO0yFrt/gKeCMNSSDHLEi9GhZXGRaS+QGPjolMT0=; b=SyJ0+vUliGb53IBF8ZgSC5M+USYOlBFvlSBknEg4cMov1MLZ4WPxpaYhVtOhBCyigp5C XdbeRuRamT2rK5fZkRO4SWpwVsDDHeNQHM+qEHDj5ueSFgwB1DtM0ptKXRSn1FAnlg9XF I2yLXxHWIq7DXRmC8E8lQqN32a2HpBKSjH8FSQIgsoHDkHmiYTEFoZlR6muxiLJHhV5Di uEh9HBzFr4NC0CPDaiH5B9AeFyR8t7zI2Taw81irxncqvDwdydxfVxKBs+PnHfbLL5WkV XNGZs4Erpn9mRBG9J2lwkxXyZJmfz/bQBreMWiklmlA2GQYnbv0yg6P5XJxhzr5boQA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=M0rQ0529; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BE267606A33A; Tue, 1 Dec 2026 07:58:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=M0rQ0529 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1B1771F00929; Tue, 1 Dec 2026 07:58:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796111917; bh=bDfbO0yFrt/gKeCMNSSDHLEi9GhZXGRaS+QGPjolMT0=; h=Date:Cc:Subject:To:References:From:In-Reply-To; b=M0rQ0529nHXInmgUMX9k8dddgvRETGkLLVK1+V09hPuNxDq071ZTG32Sdo+XeXN3a v/GwM0XAMJU5lfJS73bjToUcjyClER8jGIXfB5VRuxjguJvWygapMWTNAAAh81/jkd KMkKbjLkj96rL25e5zWP6ROfKuETBEgqhApjnQfItIRu+b5WD9+5ZGvV0yl/SeqbfU vXL6dwd2PPTzMc1vbDD+fV+Mt9jwxdPae6uHDf2WPKOCOPICEBvuFPpYzgtMqdmTVK tv7qaT8bPBfJ2h7hYRSvO0vzhdF/C0ppY4I7Mvv4xZ4rD/quFYolqCx537ZZbSecvA gmb0e1KH86Ong== Message-ID: Date: Tue, 1 Dec 2026 15:58:34 +0800 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 User-Agent: Mozilla Thunderbird Cc: chao@kernel.org, Daeho Jeong , stable@vger.kernel.org Subject: Re: [f2fs-dev] [PATCH] f2fs: write a checkpoint in fsync after the warm node log is moved To: Daeho Jeong , linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, kernel-team@android.com References: <20261115213540.2100311-1-daeho43@gmail.com> Content-Language: en-US From: Chao Yu In-Reply-To: <20261115213540.2100311-1-daeho43@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 11/16/26 05:35, Daeho Jeong wrote: > From: Daeho Jeong > > Roll-forward recovery finds fsynced node blocks by following the chain in > the warm node log. It starts from the next free block of the log recorded > in the last checkpoint, and each node block has the address of the next > one in its footer. f2fs_allocate_data_block() fills the footer after it > moves the log to a new segment, so the chain is kept when a segment is > full. > > f2fs_allocate_segment_for_resize() moves the log out of the range to be > removed in the middle of a segment. No node block is allocated there, so > the last node block in the old segment still points to the next block of > the old segment, and nothing points to the new one. The node blocks > written after that cannot be found by recovery until the next checkpoint. > > For example, with F2FS_IOC_RESIZE_FS: > > - fsync(A) writes a node block to segment X, which is in the range. > - resize moves the warm node log from segment X to segment Y. > - fsync(B) writes a node block to segment Y and returns 0. > - after a sudden power-off, recovery follows the chain in segment X, > recovers A and stops there. B is lost. > > Checkpoint is blocked during the first GC pass of resize, so this lasts > until the pass is done. f2fs_ioc_reserve_dev_alias() moves the logs in > the same way. > > Set SBI_NEED_CP when the warm node log is moved, so that fsync writes a > checkpoint instead of relying on the chain. The next checkpoint clears > the flag and starts a new chain from the new segment. Such an fsync waits > for the first GC pass of resize, since checkpoint is blocked until then. > > An fsync which has already passed need_do_checkpoint() can still write > its node blocks after the log is moved. So check the flag again after > the node blocks are written, and write a checkpoint in that case, too. > > Test: four tasks create and fsync files while F2FS_IOC_RESIZE_FS shrinks > the filesystem, and the machine is rebooted by sysrq-b 1.5 seconds after > the log is moved. Without this patch, all the files whose fsync returned > after the move were lost (454 and 437 files in two runs). With this > patch, no fsync returned in that window and no file with a returned > fsync was lost. The second check was tested with a debug patch which > delays an fsync between need_do_checkpoint() and its node writes. > > Fixes: b4b10061ef98 ("f2fs: refactor resize_fs to avoid meta updates in progress") > Cc: stable@vger.kernel.org > Signed-off-by: Daeho Jeong Reviewed-by: Chao Yu Thanks,