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 732B3C46467 for ; Mon, 16 Jan 2023 16:32:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233159AbjAPQcj (ORCPT ); Mon, 16 Jan 2023 11:32:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233039AbjAPQbz (ORCPT ); Mon, 16 Jan 2023 11:31:55 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F48A2FCE3 for ; Mon, 16 Jan 2023 08:20:04 -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 8AA9861049 for ; Mon, 16 Jan 2023 16:20:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9C748C433D2; Mon, 16 Jan 2023 16:20:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1673886004; bh=8vcFxw7LO674nsA+ycMw7cxUJd8+JfdEUukM2cg7exg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F1tEyz+lBuwq2+7EN1ulJJW6I6NnLpiz4ksAsL822eaDC5EE48aJdOc4Lglxe/Pru HWFQb8oeNATLDqT4Hu3NRfD4llgr3FYx98PMPxCD4/09fUy9jaUAnMYA1hF7Nyd0Wu w6UazeX3GZV4h9NV7VyKOOAoB04d3SV5VENOANPo= 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 5.4 266/658] f2fs: avoid victim selection from previous victim section Date: Mon, 16 Jan 2023 16:45:54 +0100 Message-Id: <20230116154921.763032123@linuxfoundation.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230116154909.645460653@linuxfoundation.org> References: <20230116154909.645460653@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 3d3e414e2987..420591654ca0 100644 --- a/fs/f2fs/gc.c +++ b/fs/f2fs/gc.c @@ -1253,8 +1253,9 @@ static int do_garbage_collect(struct f2fs_sb_info *sbi, seg_freed++; migrated++; - 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