Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1877466rwb; Fri, 19 Aug 2022 10:55:25 -0700 (PDT) X-Google-Smtp-Source: AA6agR5gW5TtbecXV/B4/YCtScO2kYRU1/OAawTdNBoYzFpOrTY63NzuM0VPbdkFDAIfoGtR1Wgn X-Received: by 2002:a17:907:1c8a:b0:6e9:2a0d:d7b7 with SMTP id nb10-20020a1709071c8a00b006e92a0dd7b7mr5405465ejc.572.1660931724876; Fri, 19 Aug 2022 10:55:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660931724; cv=none; d=google.com; s=arc-20160816; b=vqU1T6gEwHlXJ0yltrl913O+q98W+s5WZUDByNMD16nQgUVjAfnRScfx26YozbCwdp kydgUREqptNupXOahMzhygt8+/SLygynuM19rRh1zAi6Nx8poP2W//7J0+u8deYnXBLC UFAB7BkdT7p9BKqGRdYtxd1+ztKL+r8GxGmS/26ypJj5xibJNyuRw/YVlhozlaon0eSs +Ca5eCXnU5FkXGT4CO0GcTwyYJA/a7/jWrOgX+uF7SLYdZWoryoIIhUZz8wDA6+8LhE6 AASRDWlocDTQp1CfFlYfAaqPtB1MkZg2LzxO2Mgaz27CrEormdzEELPk3J3g+xwuEkhS HG0g== 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=Qmop6tFRmh6wI9wDduQXA53k+wR4enwJuC2Gb4HxIVs=; b=VIqJvyve0AzEXwVIvezFeYV9eFBBukn+qQk70ruZzmEvD1hK/onE4YxEpWHDmB+Qdo QwCwCJIvxn+crKWabCkLqzsBqwultDdBWzlCn62gfnTd6z/m6Xz4CeOR9Yn6MlNgAGc4 lyaKntuWm/0JhnuHZXt4GBhEk6wXNDZAbZ39nNm5T1Z2sOoqpctOuFcUTWzNWMWppF2/ eEpgRUZq4MJEEXVug6p9TVYmnHDZ41Kr3yyOx0xoGviGnF79nJnYiuRjhxuk8sNL+ACR 5jnI71cmxOJFWz+95WBjHUwVasOQhp5bOcMuRZ2axE4F7iL4RESEKs5dRIuFIHzR32mI UGYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IqDD7l65; 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 e12-20020a056402190c00b0043c19cd608dsi4126483edz.33.2022.08.19.10.54.58; Fri, 19 Aug 2022 10:55:24 -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=IqDD7l65; 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 S1353447AbiHSQhn (ORCPT + 99 others); Fri, 19 Aug 2022 12:37:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353760AbiHSQce (ORCPT ); Fri, 19 Aug 2022 12:32:34 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0334410DCD4; Fri, 19 Aug 2022 09:06:52 -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 AC3A8B8281F; Fri, 19 Aug 2022 16:06:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0BA02C43140; Fri, 19 Aug 2022 16:06:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660925209; bh=/deEQ7RT5Ri/0KjhQfwEy88BiGV/RDtZZ7zEgzL9xZg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IqDD7l653YesaSIv+UeeDzCsbDOBzwYNjpFLecXWCqCK1qkXg5PhjixKrq/Yy7yzK cJSD4UR3w1Gx9SyHLS4rcM8pDr32x3YgLRIQ2P/b/kU6oj3xAwPgcmc9nKcv7sS06Y bZlC+059jJmI3iyhBpJNJgBK3+Qhk3XmNTLn+724= 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.10 419/545] f2fs: write checkpoint during FG_GC Date: Fri, 19 Aug 2022 17:43:09 +0200 Message-Id: <20220819153848.171639158@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220819153829.135562864@linuxfoundation.org> References: <20220819153829.135562864@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 22bb5e07f656..3b53fdebf03d 100644 --- a/fs/f2fs/gc.c +++ b/fs/f2fs/gc.c @@ -1741,23 +1741,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