Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3030725rwb; Mon, 15 Aug 2022 16:29:56 -0700 (PDT) X-Google-Smtp-Source: AA6agR54IWOUD37tyD4D2XJsx+vEm6MOnLIK61FCJs7c1/pJCxipUjBMO77wIkkC2InQ91Bq71dw X-Received: by 2002:a05:6402:524c:b0:43e:aba4:a42d with SMTP id t12-20020a056402524c00b0043eaba4a42dmr16570529edd.328.1660606196471; Mon, 15 Aug 2022 16:29:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660606196; cv=none; d=google.com; s=arc-20160816; b=YotMK4pE3ZPgTvkSK+SHA2N5pT6fNOCakiz8b05i4f72tTsWpyiNfDyfAhqb1zY3f5 9LTVm7TbCKPDU6zV9/7mHtqdO6WYyFWwgGQlj0RaD59Z7t1MPlp8lmPP1AhDGOcLpQl4 nl3R+lDHB/VQk4pldZRtd4ft8Q0oCOd5ghKGHsmXlYBYCXotcuNnqFSq4CPDUHRBCMAi TaXpvcWXJK6cJBHhPZZp/fxV0him7JwMiiwKQKLIEtoRtnTkt3PgKHw3V2JfHYUT7kKy PeA6rOYY2St9Bf77WAN302svMuReQAkz4qlpDRGBlggULMkZx9uIXYro00FNeh23Y/52 uaOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=MO3Fz6qEcyn//oFUkBtf3VQ9xTUB2Liq37pZi3z3Zmg=; b=EXgigz3x3EEcFEUb5QAkzNpA4hKR7vQuPf/8hrWlGRrdjL8z4mf19UrKnFtlgSmuiS jnJlc3yJJw4Ldl29f3fPgpaQS1VE/kWAph7iE09wHyHuIpyRS2pkm1S06SjF5M7VZVCk 1Zzk5KBqSK+fjwe5s3dS70wDLPV68vjzU/BmEJuKcc0CiW/4dlZYxBYV2HbneOuyr/oI wZEj6NpNYslR7QQsFpbZZKfjHLU21Ujkdluo+kcWgS7WeeprbmtWsq6oK/o9ve2FsfP2 +7JTZFlhinYi8a4YkwExStozCaGxTTPky9JnL3GqZmf0JxrOx4nlNNlCm5p/1RXcCHeI IC3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=haPRck2y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sd31-20020a1709076e1f00b0073075197e3bsi9802972ejc.755.2022.08.15.16.29.15; Mon, 15 Aug 2022 16:29:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=haPRck2y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352391AbiHOW5m (ORCPT + 99 others); Mon, 15 Aug 2022 18:57:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352458AbiHOWzt (ORCPT ); Mon, 15 Aug 2022 18:55:49 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5A2B3C17B; Mon, 15 Aug 2022 12:55:24 -0700 (PDT) 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 ams.source.kernel.org (Postfix) with ESMTPS id 34ABCB81136; Mon, 15 Aug 2022 19:55:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 52EB6C433D6; Mon, 15 Aug 2022 19:55:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660593321; bh=2zp/vsUDwQiyqPlsyHNvN09ZapKjPGhKIbd11SKCAQA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=haPRck2yE/BvlRNPuHh5Gv963SrsLC2G+DP/lvT/09BNvi7VWkHehHP2mcnmWKTKB HJeKAJJBn4dR9npJ4yrdFOp63dsmFpFwPvMTBSl4viyeRlCVdbEAeEWferjvzt/LeM Kuw+8tQbYBP2qr4QQ7rQJIcxBy0qjZvFN7l0a8FY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Byungki Lee , Chao Yu , Jaegeuk Kim , Sasha Levin Subject: [PATCH 5.18 0929/1095] f2fs: write checkpoint during FG_GC Date: Mon, 15 Aug 2022 20:05:28 +0200 Message-Id: <20220815180507.671856275@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Byungki Lee [ Upstream commit a9163b947ae8f7af7cb8d63606cd87b9facbfe74 ] If there's not enough free sections each of which consistis of large segments, we can hit no free section for upcoming section allocation. Let's reclaim some prefree segments by writing checkpoints. Signed-off-by: Byungki Lee Reviewed-by: Chao Yu Signed-off-by: Jaegeuk Kim Signed-off-by: Sasha Levin --- fs/f2fs/gc.c | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c index 6a7e4148ff9d..a193862ad8a5 100644 --- a/fs/f2fs/gc.c +++ b/fs/f2fs/gc.c @@ -1790,23 +1790,31 @@ int f2fs_gc(struct f2fs_sb_info *sbi, bool sync, if (sync) goto stop; - if (has_not_enough_free_secs(sbi, sec_freed, 0)) { - if (skipped_round <= MAX_SKIP_GC_COUNT || - skipped_round * 2 < round) { - segno = NULL_SEGNO; - goto gc_more; - } + if (!has_not_enough_free_secs(sbi, sec_freed, 0)) + goto stop; - if (first_skipped < last_skipped && - (last_skipped - first_skipped) > - sbi->skipped_gc_rwsem) { - f2fs_drop_inmem_pages_all(sbi, true); - segno = NULL_SEGNO; - goto gc_more; - } - if (gc_type == FG_GC && !is_sbi_flag_set(sbi, SBI_CP_DISABLED)) + if (skipped_round <= MAX_SKIP_GC_COUNT || skipped_round * 2 < round) { + + /* Write checkpoint to reclaim prefree segments */ + if (free_sections(sbi) < NR_CURSEG_PERSIST_TYPE && + prefree_segments(sbi) && + !is_sbi_flag_set(sbi, SBI_CP_DISABLED)) { ret = f2fs_write_checkpoint(sbi, &cpc); - } + if (ret) + goto stop; + } + segno = NULL_SEGNO; + goto gc_more; + } + if (first_skipped < last_skipped && + (last_skipped - first_skipped) > + sbi->skipped_gc_rwsem) { + f2fs_drop_inmem_pages_all(sbi, true); + segno = NULL_SEGNO; + goto gc_more; + } + if (gc_type == FG_GC && !is_sbi_flag_set(sbi, SBI_CP_DISABLED)) + ret = f2fs_write_checkpoint(sbi, &cpc); stop: SIT_I(sbi)->last_victim[ALLOC_NEXT] = 0; SIT_I(sbi)->last_victim[FLUSH_DEVICE] = init_segno; -- 2.35.1