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=1796175746; b=zWaL2Ou3QkdY5jCzzgRDrtWcipkSHOk/wnU8pI49v0U45k0iKOtGsYdxheF2GP+x+Wby uySNjlc3s8MaSpE806Ayd0AGU7t9mWljwoPcDOYXi92ToAK1OzPvKgdWt4wXS7Z9hFx+D xbVZVdRUNvu56U32KR9C6r1P8oCbdxpWm1ELjuREFaeN4L5WgeqS4rq2xNOZQxfDOXex+ dTSFjbRMFNXZ1USx6aJ0itKQsstIdOa9T0uZiFeWoRftYhNjbC5iiu+EgZHymunnM8blO 2MG+GTO0JkH6MRC6eBrhbjq+cq9nc8QwyVm5+0JP3Me/ZxY75qByuXANm9INUT9d8gA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796175746; 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=+FxIMvA5FD8x/RtKoQbzf3t47j7s1zGaWjn5YTxfB5Y=; b=3irwG1ZAeNTcqwMf+zy5uOOixOYZcwI6G06/UPJR6BgjsP7ym1PFC70jGOuFej0XjAuV a4K2GoEZwTi/v7Au6PQZernv/OC4Z/0czWklipw//62x2amh+Xp5cYAp0yEDwuyqfwqX/ dvy+mTav8+gTN9QyF8aKwZwX3kp/Lx4c1CdzpZSPlYMRcM9lJ1L67y37E9O+0qjiLXQRP EB1Kc5w2+5XGnmrYJxx7/14Vu+RPfLSqBdFkri++iakfQHEfZZCAr5ul5FX8zVneb6iDW 3f/MO45LSi7AoIgl/3dgQR70HLtSwg69t0gc5SlD75AzOzUSOjcxh+zBuNGJsAF5Crg== 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=kHWozIVl; 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 51D7C606A31A; Wed, 2 Dec 2026 01:42:26 +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=kHWozIVl Received: by smtp.kernel.org (Postfix) with ESMTPSA id E8AB21F000C1; Wed, 2 Dec 2026 01:42:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796175746; bh=+FxIMvA5FD8x/RtKoQbzf3t47j7s1zGaWjn5YTxfB5Y=; h=Date:Cc:Subject:To:References:From:In-Reply-To; b=kHWozIVlvQ+SK5vt7USNckD06fDTQYJrfG0kbU7d3qmRKbTvtEZD4Lo8iH0KQTXLe tZrFIyjBKs3N0Kz5JPpyzCOGmjNQ57pU6wC8ecVFAOdRAjYebIJa5+laMGmrznEVMz sYDoG1Z9VY+5A9mo7wXaQkuHHzk7VO5F3adhy0oX41C/0+TuUzAiYy5AvX/m1wUOIm nmO3dGwO+cwzMfvBlejCeIwa5wTOlmwFPWRSIadJm1uzrjhkwED6Zxsb5551lXSaVV sVI/sNWvWFbCjI8AzlixeCHGsbHzi7o3MnTXIosQVKfUOIJ9xuiNgNzcacd1NHPMDF 4mS2cb1BWoxrw== Message-ID: Date: Wed, 2 Dec 2026 09:42:23 +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 v2] f2fs: don't run out of free sections in the dry run of resize_fs To: Daeho Jeong , linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, kernel-team@android.com References: <20261201183649.4162618-1-daeho43@gmail.com> Content-Language: en-US From: Chao Yu In-Reply-To: <20261201183649.4162618-1-daeho43@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 12/2/26 02:36, Daeho Jeong wrote: > From: Daeho Jeong > > f2fs_resize_fs() migrates the blocks in the range to be shrunk in a dry > run before freeze_super(). Checkpoint is blocked there to protect > MAIN_SECS, so the space freed in the meantime can't be reused, while GC > and other writers keep using free sections in the remaining area. On a > busy filesystem, free sections can run out and we hit the below. > > kernel BUG at fs/f2fs/segment.c:3020! > Call trace: > new_curseg+0x9dc/0xa50 > f2fs_allocate_data_block+0xa2c/0xcb8 > do_write_block+0xd4/0x2b4 > f2fs_outplace_write_data+0x78/0xcc > f2fs_do_write_data_page+0x564/0x69c > do_garbage_collect+0x1668/0x21ec > f2fs_gc_range+0x274/0x41c > free_segment_range+0x290/0x33c > f2fs_resize_fs+0x200/0x530 > > Without CONFIG_F2FS_CHECK_FS, checkpoint is stopped by > STOP_CP_REASON_NO_SEGMENT instead, and writes fail with -EIO. > > Stop the dry run before free sections run out. To migrate as much as > possible before freeze_super(), write a checkpoint before the dry run, > and repeat them as long as the valid blocks in the range decrease. As > gc_lock is held meanwhile and keeps other checkpoints waiting, don't > start another round after 5 seconds. The rest, if any, is migrated after > freeze_super() as before, where no one else allocates blocks. > > Shrinking a 4GB filesystem down to 4MB of free space with two writers > running hit the BUG in 5 of 12 runs on a 4KB page kernel, and in none of > 6 runs with this patch. > > 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,