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, From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E7DDB606A31A for ; Tue, 1 Dec 2026 07:58:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=lists.sourceforge.net header.i=@lists.sourceforge.net header.a=rsa-sha256 header.s=beta header.b=chPg2lGS; dkim=fail reason="signature verification failed" (1024-bit key, unprotected) header.d=sourceforge.net header.i=@sourceforge.net header.a=rsa-sha256 header.s=x header.b=Sh8eeGWD; dkim=fail reason="signature verification failed" (1024-bit key) header.d=sf.net header.i=@sf.net header.a=rsa-sha256 header.s=x header.b=DNvdlhVj; dkim=neutral header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=M0rQ0529 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.sourceforge.net; s=beta; h=Content-Transfer-Encoding:Content-Type:Cc: Reply-To:From:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Subject:In-Reply-To:References:To:MIME-Version:Date: Message-ID:Sender:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Unsubscribe-Post: List-Owner; bh=+Q4Cbnl+nZifEMhDf6l1ZqQso09DpHtp0tLU35UV4hk=; b=chPg2lGS1H3ifH rwmsqssEBs2/dUe5VbwtCZYBsOzfDV9QeLIVraMddBcAEM2SfmWzkdn5H+Dozz4YimCInh8EzeXXj /sdkQcDmrqs1ELly5/VfOtHFX5rjVDvGeVIKPoKAHfs3kfLoDwId4Ims8n+UtVORjVg0zrutq8Bfo KU8=; Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.100.1) (envelope-from ) id 1xYIlA-000000004rW-3bzT; Tue, 01 Dec 2026 07:58:44 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.100.1) (envelope-from ) id 1xYIl9-000000004rO-2Kwe for linux-f2fs-devel@lists.sourceforge.net; Tue, 01 Dec 2026 07:58:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:Content-Type:In-Reply-To: From:References:To:Subject:Cc:MIME-Version:Date:Message-ID:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Unsubscribe-Post:List-Subscribe:List-Post:List-Owner:List-Archive; bh=bDfbO0yFrt/gKeCMNSSDHLEi9GhZXGRaS+QGPjolMT0=; b=Sh8eeGWDsrEsPu4/B3v0d7C8hq +ftBUl8K0tGHdkTif6gZOW3Xg1rTglYrkLr4XT81h9rvxnBM0SynQG98JUV5A/Bzn1xRcVrmnLqLD 6+5aJN4H9VDBItyQvQNVdB7dbZHtP3FRAjQ0P3uVb9+XfKlFHeazc9SDvDI4TqXegI5g=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:From:References:To: Subject:Cc:MIME-Version:Date:Message-ID:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Unsubscribe-Post: List-Subscribe:List-Post:List-Owner:List-Archive; bh=bDfbO0yFrt/gKeCMNSSDHLEi9GhZXGRaS+QGPjolMT0=; b=DNvdlhVjV5mqZbYIn8kldl8xWi 4ZwKsmFQU0BX+i14FaUfJ+11RaCikgir5aQ9cAt+TIEddeP9H3BpMMTSmAqDN8hVzcXouuiC7M6iW B+uesoK8nbMEPAnM5MPyEHGnT/549mvVQvE5qaisooUhK33zJ5kUyL5lnWhp1hyDIU50=; Received: from sea.source.kernel.org ([172.234.252.31]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.100.1) id 1xYIl8-000000003Gj-41DR for linux-f2fs-devel@lists.sourceforge.net; Tue, 01 Dec 2026 07:58:43 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 7DAA641A3E; Tue, 1 Dec 2026 07:58:37 +0000 (UTC) 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-Archived-By: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird 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 In-Reply-To: <20261115213540.2100311-1-daeho43@gmail.com> X-Spam-Score: 0.8 (/) X-Headers-End: 1xYIl8-000000003Gj-41DR Subject: Re: [f2fs-dev] [PATCH] f2fs: write a checkpoint in fsync after the warm node log is moved X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , From: Chao Yu via Linux-f2fs-devel Reply-To: Chao Yu Cc: Daeho Jeong , stable@vger.kernel.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,INCLUDES_CR_TRAILER, MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 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, _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel