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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9A6CCC4167B for ; Wed, 28 Dec 2022 16:23:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234598AbiL1QXH (ORCPT ); Wed, 28 Dec 2022 11:23:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234764AbiL1QVr (ORCPT ); Wed, 28 Dec 2022 11:21:47 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B26A81B9E3 for ; Wed, 28 Dec 2022 08:19:41 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 39E6961578 for ; Wed, 28 Dec 2022 16:19:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 49925C433D2; Wed, 28 Dec 2022 16:19:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1672244380; bh=5xChHFZqD6jafH1OxTDw6wWh52vgE++QSXQzEfMCeX0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0o45W6Q82B+J8ArqfPqCmGA4UcUd+kxkdfz313bH8OSzXwH7jj+G2vsDGCCuy+bQK CPvCBxXRqwJk9kB/lGx91nnTK6KwgnNWPKRjwNooT0SqxAlJA33LHsxMTHLqTI3N4J ZPBdcIrcWO888Vt40+FzUDcjorXeWzcrCQwcNYxs= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Yonggil Song , Chao Yu , Jaegeuk Kim , Sasha Levin Subject: [PATCH 6.1 0660/1146] f2fs: avoid victim selection from previous victim section Date: Wed, 28 Dec 2022 15:36:39 +0100 Message-Id: <20221228144348.082225663@linuxfoundation.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20221228144330.180012208@linuxfoundation.org> References: <20221228144330.180012208@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Yonggil Song [ Upstream commit e219aecfd4b766c4e878a3769057e9809f7fcadc ] When f2fs chooses GC victim in large section & LFS mode, next_victim_seg[gc_type] is referenced first. After segment is freed, next_victim_seg[gc_type] has the next segment number. However, next_victim_seg[gc_type] still has the last segment number even after the last segment of section is freed. In this case, when f2fs chooses a victim for the next GC round, the last segment of previous victim section is chosen as a victim. Initialize next_victim_seg[gc_type] to NULL_SEGNO for the last segment in large section. Fixes: e3080b0120a1 ("f2fs: support subsectional garbage collection") Signed-off-by: Yonggil Song Reviewed-by: Chao Yu Signed-off-by: Jaegeuk Kim Signed-off-by: Sasha Levin --- fs/f2fs/gc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c index f46e4dcaa252..22c1f876e8c5 100644 --- a/fs/f2fs/gc.c +++ b/fs/f2fs/gc.c @@ -1743,8 +1743,9 @@ static int do_garbage_collect(struct f2fs_sb_info *sbi, get_valid_blocks(sbi, segno, false) == 0) seg_freed++; - if (__is_large_section(sbi) && segno + 1 < end_segno) - sbi->next_victim_seg[gc_type] = segno + 1; + if (__is_large_section(sbi)) + sbi->next_victim_seg[gc_type] = + (segno + 1 < end_segno) ? segno + 1 : NULL_SEGNO; skip: f2fs_put_page(sum_page, 0); } -- 2.35.1