From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 761DFC3601E for ; Thu, 10 Apr 2025 03:53:41 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1u2iyx-00047B-DZ; Thu, 10 Apr 2025 03:53:39 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1u2iyp-00046x-6A for linux-f2fs-devel@lists.sourceforge.net; Thu, 10 Apr 2025 03:53:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=In-Reply-To:Content-Type:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=ki/xvAQMjp5c5OA4NmrKd8EHYoH1iFKfp/eYnLhNDpQ=; b=DRUMqdQzaeUN6r1nOqFrZh0tiS tBO5x4clWkF3gjMS62MMMOYuDaSLnAn4qcKp9tMCDsqN7TBLSANucK4+eiXPL4g74YGLgS9ug5uFl fgs+CSiLNxAtGtIoMNylxUBVUCWvGpMf8CxPetMgO6kDlj5nMggR8cPc92qgHN3+rhJo=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To :From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=ki/xvAQMjp5c5OA4NmrKd8EHYoH1iFKfp/eYnLhNDpQ=; b=luDHGdVt3rabNak2S3VpmO2hq8 vetLlW2cUCGU+WDUJCr49jeooRAO6dLSv7YqrvYcg9Rq8dKG9Qz6jA4uVEfEv2Z/FkR1v+KaDMhxR 9shxkmJZnLnOGcqNh+yj6DoXKoeEeFZxhPDHLjYu5DmkNBi5K3SvI1j5oRTz22FyiB0U=; Received: from sea.source.kernel.org ([172.234.252.31]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1u2iyZ-0000Dc-Cc for linux-f2fs-devel@lists.sourceforge.net; Thu, 10 Apr 2025 03:53:31 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sea.source.kernel.org (Postfix) with ESMTP id 08B3544147; Thu, 10 Apr 2025 03:53:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7CCAAC4CEDD; Thu, 10 Apr 2025 03:53:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1744257189; bh=xZRnulTgJaXmjhTZz+dTF52Wj71JRTbBd/c0uCNWeCw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=iGyJvDEhmxUcgsH5hD1OIkht6AdvSEq4Opdr/nJ899yCLbAnN2i4PuW0Q9WyZ1IBH AIa1iE9cmvdGggoWuXSmc+oY8uQiLgB0seqH8cy7lT0qv/35WclMEgB0jlk6VDv4JF /AtGPbzYU9ZJFLKP2FdIqjZL1MfeOFdZ9YK45jvsowNYPrDROYltXMOUqeUBdkrLEA IvDIWASAe1nJ3+Q5+JXXpffMC/w4VoRX4Td5AVxELoHGQBaKjnpkY5TIHLD2APQU90 vi73bz+CXCcjrZaF4+X6ssJzSEyfzHoShgERdefO+gMC/R0t8B7rArFlYiiLlVu5mf z3wKMfxwX2+mQ== Date: Thu, 10 Apr 2025 03:53:07 +0000 To: Chao Yu Message-ID: References: <20250403232107.2960-1-yohan.joung@sk.com> <7059eada-a51d-4f68-b62a-0f2c89c9b01c@kernel.org> <87056483-6cf8-4b2e-82f1-dcda31a28afd@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <87056483-6cf8-4b2e-82f1-dcda31a28afd@kernel.org> X-Headers-End: 1u2iyZ-0000Dc-Cc Subject: Re: [f2fs-dev] [PATCH v5] f2fs: prevent the current section from being selected as a victim during GC X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Jaegeuk Kim via Linux-f2fs-devel Reply-To: Jaegeuk Kim Cc: pilhyun.kim@sk.com, linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net On 04/07, Chao Yu wrote: > On 4/7/25 10:08, Chao Yu wrote: > > On 4/5/25 03:55, Jaegeuk Kim wrote: > >> Hi Yohan, > >> > >> I modified this patch after applying the clean up by > >> > >> https://lore.kernel.org/linux-f2fs-devel/20250404195442.413945-1-jaegeuk@kernel.org/T/#u > >> > >> --- a/fs/f2fs/segment.h > >> +++ b/fs/f2fs/segment.h > >> @@ -486,6 +486,11 @@ static inline void __set_test_and_free(struct f2fs_sb_info *sbi, > >> > >> free_i->free_sections++; > >> > >> + if (GET_SEC_FROM_SEG(sbi, sbi->next_victim_seg[BG_GC]) == secno) > >> + sbi->next_victim_seg[BG_GC] = NULL_SEGNO; > >> + if (GET_SEC_FROM_SEG(sbi, sbi->next_victim_seg[FG_GC]) == secno) > >> + sbi->next_victim_seg[FG_GC] = NULL_SEGNO; > > > > Reviewed-by: Chao Yu > > Oh, can we add Fixes line to make it to be merged into stable kernel? Which one would be good to add? > > Thanks, > > > > > Thanks, > > > >> + > >> unlock_out: > >> spin_unlock(&free_i->segmap_lock); > >> } > >> > >> On 04/04, yohan.joung wrote: > >>> When selecting a victim using next_victim_seg in a large section, the > >>> selected section might already have been cleared and designated as the > >>> new current section, making it actively in use. > >>> This behavior causes inconsistency between the SIT and SSA. > >>> > >>> F2FS-fs (dm-54): Inconsistent segment (70961) type [0, 1] in SSA and SIT > >>> Call trace: > >>> dump_backtrace+0xe8/0x10c > >>> show_stack+0x18/0x28 > >>> dump_stack_lvl+0x50/0x6c > >>> dump_stack+0x18/0x28 > >>> f2fs_stop_checkpoint+0x1c/0x3c > >>> do_garbage_collect+0x41c/0x271c > >>> f2fs_gc+0x27c/0x828 > >>> gc_thread_func+0x290/0x88c > >>> kthread+0x11c/0x164 > >>> ret_from_fork+0x10/0x20 > >>> > >>> issue scenario > >>> segs_per_sec=2 > >>> - seg#0 and seg#1 are all dirty > >>> - all valid blocks are removed in seg#1 > >>> - gc select this sec and next_victim_seg=seg#0 > >>> - migrate seg#0, next_victim_seg=seg#1 > >>> - checkpoint -> sec(seg#0, seg#1) becomes free > >>> - allocator assigns sec(seg#0, seg#1) to curseg > >>> - gc tries to migrate seg#1 > >>> > >>> Signed-off-by: yohan.joung > >>> Signed-off-by: Chao Yu > >>> --- > >>> fs/f2fs/segment.h | 9 ++++++++- > >>> 1 file changed, 8 insertions(+), 1 deletion(-) > >>> > >>> diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h > >>> index 0465dc00b349..0773283babfa 100644 > >>> --- a/fs/f2fs/segment.h > >>> +++ b/fs/f2fs/segment.h > >>> @@ -474,8 +474,15 @@ static inline void __set_test_and_free(struct f2fs_sb_info *sbi, > >>> next = find_next_bit(free_i->free_segmap, > >>> start_segno + SEGS_PER_SEC(sbi), start_segno); > >>> if (next >= start_segno + usable_segs) { > >>> - if (test_and_clear_bit(secno, free_i->free_secmap)) > >>> + if (test_and_clear_bit(secno, free_i->free_secmap)) { > >>> free_i->free_sections++; > >>> + > >>> + if (GET_SEC_FROM_SEG(sbi, sbi->next_victim_seg[BG_GC]) == secno) > >>> + sbi->next_victim_seg[BG_GC] = NULL_SEGNO; > >>> + > >>> + if (GET_SEC_FROM_SEG(sbi, sbi->next_victim_seg[FG_GC]) == secno) > >>> + sbi->next_victim_seg[FG_GC] = NULL_SEGNO; > >>> + } > >>> } > >>> } > >>> skip_free: > >>> -- > >>> 2.33.0 > > _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel