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 D5B83C77B6E for ; Thu, 13 Apr 2023 15:59:04 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1pmzLj-00088o-QG; Thu, 13 Apr 2023 15:59:04 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pmzLi-00088h-0h for linux-f2fs-devel@lists.sourceforge.net; Thu, 13 Apr 2023 15:59:02 +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=sGLhJXGHpinEmNvjaSHw3hxDjFMzROViMiN0ZS0fcCM=; b=bi10/pxBthNnkb2JTRY7zDPEUj b2yNu5/VedHEK9ApsliLn7CeN2VpHPIOo7L7WuKmEWYdxKDePYlsFPn9FZTMrzausDvF0x7DVHjHq bV0PMR9F5GtvuEGrlxwifV2wZ7AR4IMDwnaUWi+RI6nM4AIsFX2UroW1fG4HXeCIBvto=; 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=sGLhJXGHpinEmNvjaSHw3hxDjFMzROViMiN0ZS0fcCM=; b=RVwr9dSfVDntuPXBs14htGumsQ 6A3DaX755I1d8G66PG5CkfaUpPBqXXT58dsl7/n4UEkhXqgY03JYauEgyVDhgQ1NUcsRcd5F5dbgA u14oq/RyudLQff2H5l+PrJBW8tyyzecOMBI2polMbXiZATEGO/STH94igGkrcT2rTdm8=; Received: from dfw.source.kernel.org ([139.178.84.217]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1pmzLh-006gUx-CZ for linux-f2fs-devel@lists.sourceforge.net; Thu, 13 Apr 2023 15:59:02 +0000 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 B4E516175F for ; Thu, 13 Apr 2023 15:58:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 11F0CC433EF; Thu, 13 Apr 2023 15:58:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681401535; bh=H+22CkDBG9LlYhXtHCRwNNtowDnsKH9u9jFFCt14njI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=TXZmH2/F2X9ebDlHcs2pN48yM+fxhzCDStlv1bHOXcfXTkF5fV1763OWySIzW4mRW Ela6Z4EoGLlHFCO+8jZFtgsSvU1QqfIo/rr6kcBcqJEjA56ZJqJtkwusRxP4hIpe+P p8N5x1rrPd/OvjiRjiTJa2vf8zIlc/xNiJ91UHLPeLVTrfBUAJyJsrDpX+0sYVRsVg 1NK0fEeZQa+73sagy1QGGaydK2zra86FO2+V4Qc9pbqq5fXgg0ykh0v+7HZAPI8Kbu 4/2/bb6qbM8Ncba1DE5fqn2EmeNGklEB08kOkgrFXcR0o9nrhXBvOEMaV351tztbPI cm1su4dNUBKCw== Date: Thu, 13 Apr 2023 08:58:53 -0700 From: Jaegeuk Kim To: Chao Yu Message-ID: References: <20230324071028.336982-1-chao@kernel.org> <6c9abd05-297a-ea4f-fd5c-9f4d9fb488ab@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Headers-End: 1pmzLh-006gUx-CZ Subject: Re: [f2fs-dev] [PATCH] f2fs: fix to trigger a checkpoint in the end of foreground garbage collection 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: , Cc: 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/13, Jaegeuk Kim wrote: > On 04/13, Chao Yu wrote: > > On 2023/4/11 7:21, Jaegeuk Kim wrote: > > > On 04/10, Chao Yu wrote: > > > > On 2023/4/5 23:55, Jaegeuk Kim wrote: > > > > > On 04/05, Chao Yu wrote: > > > > > > On 2023/4/5 5:39, Jaegeuk Kim wrote: > > > > > > > Can we do like this? > > > > > > > > > > > > > > From 9a58f0e59364241aa31b555cfe793d278e39b0dc Mon Sep 17 00:00:00 2001 > > > > > > > From: Jaegeuk Kim > > > > > > > Date: Tue, 4 Apr 2023 14:36:00 -0700 > > > > > > > Subject: [PATCH] f2fs: do checkpoint when there's not enough free sections > > > > > > > > > > > > > > We didn't do checkpoint in FG_GC case, which may cause losing to reclaim prefree > > > > > > > sctions in time. > > > > > > > > > > > > > > Fixes: 6f8d4455060d ("f2fs: avoid fi->i_gc_rwsem[WRITE] lock in f2fs_gc") > > > > > > > Signed-off-by: Chao Yu > > > > > > > Signed-off-by: Jaegeuk Kim > > > > > > > --- > > > > > > > fs/f2fs/gc.c | 24 +++++++++++------------- > > > > > > > 1 file changed, 11 insertions(+), 13 deletions(-) > > > > > > > > > > > > > > diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c > > > > > > > index 56c53dbe05c9..f1d0dd9c5a6c 100644 > > > > > > > --- a/fs/f2fs/gc.c > > > > > > > +++ b/fs/f2fs/gc.c > > > > > > > @@ -1806,6 +1806,7 @@ int f2fs_gc(struct f2fs_sb_info *sbi, struct f2fs_gc_control *gc_control) > > > > > > > }; > > > > > > > unsigned int skipped_round = 0, round = 0; > > > > > > > unsigned int upper_secs; > > > > > > > + bool stop_gc = false; > > > > > > > trace_f2fs_gc_begin(sbi->sb, gc_type, gc_control->no_bg_gc, > > > > > > > gc_control->nr_free_secs, > > > > > > > @@ -1876,19 +1877,15 @@ int f2fs_gc(struct f2fs_sb_info *sbi, struct f2fs_gc_control *gc_control) > > > > > > > (gc_type == FG_GC) ? sec_freed : 0, 0)) { > > > > > > > if (gc_type == FG_GC && sec_freed < gc_control->nr_free_secs) > > > > > > > goto go_gc_more; > > > > > > > - goto stop; > > > > > > > - } > > > > > > > - > > > > > > > - /* FG_GC stops GC by skip_count */ > > > > > > > - if (gc_type == FG_GC) { > > > > > > > + stop_gc = true; > > > > > > > > > > > > I guess below condition is for emergency recycle of prefree segments during > > > > > > foreground GC, in order to avoid exhausting free sections due to to many > > > > > > metadata allocation during CP. > > > > > > > > > > > > if (free_sections(sbi) <= upper_secs + NR_GC_CHECKPOINT_SECS && > > > > > > prefree_segments(sbi)) { > > > > > > > > > > > > But for common case, free_sections() is close to reserved_segments(), and > > > > > > upper_secs + NR_GC_CHECKPOINT_SECS value may be far smaller than free_sections(), > > > > > > so checkpoint may not be trggered as expected, IIUC. > > > > > > > > > > > > So it's fine to just trigger CP in the end of foreground garbage collection? > > > > > > > > > > My major concern is to avoid unnecessary checkpointing given multiple FG_GC > > > > > requests were pending in parallel. And, I don't want to add so many combination > > > > > which gives so many corner cases, and feel f2fs_gc() needs to call checkpoint > > > > > automatically in the worst case scenario only. > > > > > > > > Alright. > > > > > > > > > > > > > > By the way, do we just need to call checkpoint here including FG_GC as well? > > > > > > > > I didn't get it, do you mean? > > > > > > > > - f2fs_balance_fs() > > > > - f2fs_gc() creates prefree segments but not call checkpoint to reclaim > > > > > > > > - f2fs_balance_fs() > > > > - f2fs_gc() > > > > - detect prefree segments created by last f2fs_balance_fs, then call > > > > f2fs_write_checkpoint to reclaim > > > > > > > > Or could you please provide a draft patch? :-P > > > > > > Testing this. > > > > > > From ec5f37bbe33110257c04e0ec97a80b0111465b52 Mon Sep 17 00:00:00 2001 > > > From: Jaegeuk Kim > > > Date: Mon, 10 Apr 2023 14:48:50 -0700 > > > Subject: [PATCH] f2fs: refactor f2fs_gc to call checkpoint in urgent condition > > > > > > The major change is to call checkpoint, if there's not enough space while having > > > some prefree segments in FG_GC case. > > > > I found generic/269 will hang w/ this patch. > > Yeah, I got 270 as well. I removed it in the tree first, and will check it out > later. And, I figured out somehow this patch falls in a loop: - get_victim(FG_GC) returns a same segno - do nothing when migrating blocks due to i_gc_rwsem[WRITE] - !has_not_enough_free_secs() is true, so goto gc_more loop > > > > > Thanks, > > > > > > > > Signed-off-by: Jaegeuk Kim > > > --- > > > fs/f2fs/gc.c | 26 ++++++++++++-------------- > > > 1 file changed, 12 insertions(+), 14 deletions(-) > > > > > > diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c > > > index c748cdfb0501..0a823d2e8b9d 100644 > > > --- a/fs/f2fs/gc.c > > > +++ b/fs/f2fs/gc.c > > > @@ -1829,7 +1829,10 @@ int f2fs_gc(struct f2fs_sb_info *sbi, struct f2fs_gc_control *gc_control) > > > goto stop; > > > } > > > - if (gc_type == BG_GC && has_not_enough_free_secs(sbi, 0, 0)) { > > > + /* Let's run FG_GC, if we don't have enough space. */ > > > + if (has_not_enough_free_secs(sbi, 0, 0)) { > > > + gc_type = FG_GC; > > > + > > > /* > > > * For example, if there are many prefree_segments below given > > > * threshold, we can make them free by checkpoint. Then, we > > > @@ -1840,8 +1843,6 @@ int f2fs_gc(struct f2fs_sb_info *sbi, struct f2fs_gc_control *gc_control) > > > if (ret) > > > goto stop; > > > } > > > - if (has_not_enough_free_secs(sbi, 0, 0)) > > > - gc_type = FG_GC; > > > } > > > /* f2fs_balance_fs doesn't need to do BG_GC in critical path. */ > > > @@ -1868,19 +1869,14 @@ int f2fs_gc(struct f2fs_sb_info *sbi, struct f2fs_gc_control *gc_control) > > > if (seg_freed == f2fs_usable_segs_in_sec(sbi, segno)) > > > sec_freed++; > > > - if (gc_type == FG_GC) > > > + if (gc_type == FG_GC) { > > > sbi->cur_victim_sec = NULL_SEGNO; > > > - if (gc_control->init_gc_type == FG_GC || > > > - !has_not_enough_free_secs(sbi, > > > - (gc_type == FG_GC) ? sec_freed : 0, 0)) { > > > - if (gc_type == FG_GC && sec_freed < gc_control->nr_free_secs) > > > - goto go_gc_more; > > > - goto stop; > > > - } > > > - > > > - /* FG_GC stops GC by skip_count */ > > > - if (gc_type == FG_GC) { > > > + if (!has_not_enough_free_secs(sbi, sec_freed, 0)) { > > > + if (sec_freed < gc_control->nr_free_secs) > > > + goto go_gc_more; > > > + goto stop; > > > + } > > > if (sbi->skipped_gc_rwsem) > > > skipped_round++; > > > round++; > > > @@ -1889,6 +1885,8 @@ int f2fs_gc(struct f2fs_sb_info *sbi, struct f2fs_gc_control *gc_control) > > > ret = f2fs_write_checkpoint(sbi, &cpc); > > > goto stop; > > > } > > > + } else if (!has_not_enough_free_secs(sbi, 0, 0)) { > > > + goto stop; > > > } > > > __get_secs_required(sbi, NULL, &upper_secs, NULL); > > > _______________________________________________ > Linux-f2fs-devel mailing list > Linux-f2fs-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel