Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp4918182rwl; Mon, 3 Apr 2023 11:27:28 -0700 (PDT) X-Google-Smtp-Source: AKy350ZHhKVWZzk1Hv/dRm9knxn2vek7gM9RuSfAqvcf7sxxfqkGPpO+KeQuxMS5YP+s4mhVoPVd X-Received: by 2002:a17:906:44b:b0:931:624b:680c with SMTP id e11-20020a170906044b00b00931624b680cmr37641115eja.29.1680546448263; Mon, 03 Apr 2023 11:27:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680546448; cv=none; d=google.com; s=arc-20160816; b=CmZchNz92b8S/cd8lWsrwkV0cGkRuv6z10/9Xwn9aqnR9q+qxHyx0CaPzuzWKgDmjV JarJ23MW5jaVdTwZEdGujtE3IbRsnnnrQQdX6pzM9X+MUq6mQxceu12Dbw41njhP2kk2 kfG3OeEu5eqfyXX8634Lel4wbhdVsb9RzpNvzCzmCTbKs5uXFvE8NVWiWSfnyYxQvuiD 25myVzU1ynfbKj6dgompcVgN09KJfdJZvXN3hB3kagdbj4JFRBv8Ic1ikNsFS6vNP47G 1adEIQ6S1s+Oq56z4aaJ5BeHIPl42WX87Gy9LRhxddHSqnBLMP+SxuNJkRGd46EHo4RB /q9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=tQswSwVCWniOgNfIDmiNt8PfiWjlZwgX6Y9/dEscvJA=; b=glB0BWLSmcJNqLm0hG/4iWNbkuMBqGHNe4XNlHpp4NS8Lf4GfDyLAkOa14cXcF6NgG LAzrUR2HgKTc164rpSRBTrssTKBrS0MwCzLJ3Y4zMd9UyyfqIBwC3sbTtudNbylACefs UZODR1lBL3WEnLs/HrC48heRoXanrTreN+SDS2aSBdxMW6nF7kC2h2NJwlJtjIOJu75E Vgf98+TQ6voglsamT3LhrYoUmJTd5vkpUGrqSB52ZuK1sdYEIfQhdNRCy77JgqsvzfpJ odRciscYhPNUqzNnW2aQQG0ufqNYYsE3nogwjhqot/NAMTb9EZlE+XYNLTTtQV1zblnB 4lYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KHmWyod6; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id by17-20020a0564021b1100b005021f0d576dsi4181243edb.692.2023.04.03.11.27.03; Mon, 03 Apr 2023 11:27:28 -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=@kernel.org header.s=k20201202 header.b=KHmWyod6; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232921AbjDCSNb (ORCPT + 99 others); Mon, 3 Apr 2023 14:13:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232191AbjDCSNa (ORCPT ); Mon, 3 Apr 2023 14:13:30 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 535BB1BC1 for ; Mon, 3 Apr 2023 11:13:29 -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 dfw.source.kernel.org (Postfix) with ESMTPS id E3D3962474 for ; Mon, 3 Apr 2023 18:13:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3C59AC4339B; Mon, 3 Apr 2023 18:13:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680545608; bh=k9UIDDogZc/t03m0KagHDvNc4egLIHvQ4Q7UQzVp8s4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=KHmWyod6H+DC5CakKf8PnWaJKQzHAudnn6MCqiAo2bnHdwbkIZy8Gvfnu1h79y3w6 jz4GTodQpFR5RJMogzpPC3cHFYbYCF3b12EaHyqAOHmNIYVg1Kj3vAsINEgYUsycvY nqvZWDUCgVHCHl8HVHVW6yj3W2p0nn2HF6WD5kiDDspZE1pBydrvTXLdrZBLG9ZWwT vz13zToyR0xjOZ3rr1cVSKQPd/pyMTml7gctBY/QLsLJ7cJU6c6d6l2xpk2ynMjAwy qiRQKwsrBpbW0uDk5e/rAXiOW2/hyJLbHNxyz+l6ubYk6rzm+hP6qECfUC0AOu0aRU VSqBeYhHTk9CQ== Date: Mon, 3 Apr 2023 11:13:26 -0700 From: Jaegeuk Kim To: Chao Yu Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: Re: [PATCH] f2fs: fix to trigger a checkpoint in the end of foreground garbage collection Message-ID: References: <20230324071028.336982-1-chao@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230324071028.336982-1-chao@kernel.org> X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=unavailable 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 On 03/24, Chao Yu wrote: > In order to reclaim free blocks in prefree sections before latter use. We were supposed to do checkpoint as is? > > Fixes: 6f8d4455060d ("f2fs: avoid fi->i_gc_rwsem[WRITE] lock in f2fs_gc") > Signed-off-by: Chao Yu > --- > fs/f2fs/f2fs.h | 1 + > fs/f2fs/gc.c | 8 ++++++++ > fs/f2fs/segment.c | 1 + > 3 files changed, 10 insertions(+) > > diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h > index 53a005b420cf..b1515375cb4c 100644 > --- a/fs/f2fs/f2fs.h > +++ b/fs/f2fs/f2fs.h > @@ -1269,6 +1269,7 @@ struct f2fs_gc_control { > unsigned int victim_segno; /* target victim segment number */ > int init_gc_type; /* FG_GC or BG_GC */ > bool no_bg_gc; /* check the space and stop bg_gc */ > + bool reclaim_space; /* trigger checkpoint to reclaim space */ > bool should_migrate_blocks; /* should migrate blocks */ > bool err_gc_skipped; /* return EAGAIN if GC skipped */ > unsigned int nr_free_secs; /* # of free sections to do GC */ > diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c > index 2996d38aa89c..5a451d3d512d 100644 > --- a/fs/f2fs/gc.c > +++ b/fs/f2fs/gc.c > @@ -132,6 +132,7 @@ static int gc_thread_func(void *data) > > gc_control.init_gc_type = sync_mode ? FG_GC : BG_GC; > gc_control.no_bg_gc = foreground; > + gc_control.reclaim_space = foreground; > gc_control.nr_free_secs = foreground ? 1 : 0; > > /* if return value is not zero, no victim was selected */ > @@ -1880,6 +1881,13 @@ 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; > + > + /* > + * trigger a checkpoint in the end of foreground garbage > + * collection. > + */ > + if (gc_control->reclaim_space) > + ret = f2fs_write_checkpoint(sbi, &cpc); > goto stop; > } > > diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c > index 6c11789da884..b62af2ae1685 100644 > --- a/fs/f2fs/segment.c > +++ b/fs/f2fs/segment.c > @@ -421,6 +421,7 @@ void f2fs_balance_fs(struct f2fs_sb_info *sbi, bool need) > .victim_segno = NULL_SEGNO, > .init_gc_type = BG_GC, > .no_bg_gc = true, > + .reclaim_space = true, > .should_migrate_blocks = false, > .err_gc_skipped = false, > .nr_free_secs = 1 }; > -- > 2.25.1