From patchwork Fri Feb 23 20:55:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaegeuk Kim X-Patchwork-Id: 13569987 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 23B55C54E4F for ; Fri, 23 Feb 2024 20:55:52 +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 1rdcaF-0005c8-7p; Fri, 23 Feb 2024 20:55:51 +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 1rdcaD-0005bt-Qs for linux-f2fs-devel@lists.sourceforge.net; Fri, 23 Feb 2024 20:55:50 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:Message-ID: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=VEWOc3/qVc2KPcpTDw+ll2WDFuxPJYoyTKvqkHF9X/Q=; b=c4Jbq3G/18LyTNLEMvDckGCo0y xaMTrW28wOkrlMMFbn1YGg8HHYMdXVpR6GiJBTABAnncrv1UrxbWEtUeujtGUc57WvqPQFmA2hAKG nNMqPoFKabUnHHtqw4OqVteYJSeCJmn6tXHJXDAikiCBqsn+pfEs987/Qfe+hHPQuEIA=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:Message-ID:Date:Subject:Cc:To:From :Sender:Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=VEWOc3/qVc2KPcpTDw+ll2WDFuxPJYoyTKvqkHF9X/Q=; b=G A8NfJfRkbMljDzL4faDP/6nEzM3PYGc8NIJIX1gKoHE5+4kuFM1GvoUUV2VW5ZShTq29cNPxNHKMq ozh1mkEAamKPaoApPwsK4MbtM7McboUL8lBrUeBxwb2mNZUxayaWlwgusjFe/9aTIaVDEgl4kWLVj 3ffkyYNnKwoBIOkM=; Received: from dfw.source.kernel.org ([139.178.84.217]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1rdcaD-0002pP-0p for linux-f2fs-devel@lists.sourceforge.net; Fri, 23 Feb 2024 20:55:49 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 6FF336178E for ; Fri, 23 Feb 2024 20:55:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F407EC433F1; Fri, 23 Feb 2024 20:55:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708721737; bh=wi3u34VTGkwAs5nfIRnTyLTx4oN1qD3NGEQPACYbTI8=; h=From:To:Cc:Subject:Date:From; b=aU2nOLhPL/RgRvW9sZrWBoEMGkQMKGW41pCk2KlqkmzUhp/hX99bvOtMW1LhYDrRd UpXbRlEDrnjPSA3Z0KBG+IoFaWzSBmJB5x+OAf7GWurnmoXDD9q/kagKm6IOFreHzz zivFOs6zRM2qczbiEPefUbwQ7scYiP/8CYr1mRvTg+F+cnhc74lt0vVXBOuKVVfEr8 VBkam+Zf9kUUPIV/XoXtvKMjO6CFCv7tkPcou25L5en85RW/vXwcC0McK1fxlaluYF R0/oJ/6kTuYdO9+fGO9js6zx5uU1LlNkAeML4+TgHU7wP4amKPogX86X9vGjFsbnL2 136s3D2xeMrbg== From: Jaegeuk Kim To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Date: Fri, 23 Feb 2024 12:55:31 -0800 Message-ID: <20240223205535.307307-1-jaegeuk@kernel.org> X-Mailer: git-send-email 2.44.0.rc0.258.g7320e95886-goog MIME-Version: 1.0 X-Headers-End: 1rdcaD-0002pP-0p Subject: [f2fs-dev] [PATCH 1/5] f2fs: check number of blocks in a current section 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: Jaegeuk Kim Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net In cfd66bb715fd ("f2fs: fix deadloop in foreground GC"), we needed to check the number of blocks in a section instead of the segment. In addtion, let's check the entire node sections when checking the avaiable node block space. It does not match one to one per temperature, but currently we don't have exact dirty page count per temperature. Hence, use a rough estimation. Fixes: cfd66bb715fd ("f2fs: fix deadloop in foreground GC") Signed-off-by: Jaegeuk Kim Signed-off-by: Jaegeuk Kim Reviewed-by: Chao Yu --- fs/f2fs/segment.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h index 3edd3809b6b5..15bf5edd9b3c 100644 --- a/fs/f2fs/segment.h +++ b/fs/f2fs/segment.h @@ -561,23 +561,23 @@ static inline bool has_curseg_enough_space(struct f2fs_sb_info *sbi, unsigned int node_blocks, unsigned int dent_blocks) { - unsigned int segno, left_blocks; + unsigned segno, left_blocks; int i; - /* check current node segment */ + /* check current node sections, which counts very roughly */ + left_blocks = 0; for (i = CURSEG_HOT_NODE; i <= CURSEG_COLD_NODE; i++) { segno = CURSEG_I(sbi, i)->segno; - left_blocks = f2fs_usable_blks_in_seg(sbi, segno) - - get_seg_entry(sbi, segno)->ckpt_valid_blocks; - - if (node_blocks > left_blocks) - return false; + left_blocks += CAP_BLKS_PER_SEC(sbi) - + get_ckpt_valid_blocks(sbi, segno, true); } + if (node_blocks > left_blocks) + return false; - /* check current data segment */ + /* check current data section for dentry blocks. */ segno = CURSEG_I(sbi, CURSEG_HOT_DATA)->segno; - left_blocks = f2fs_usable_blks_in_seg(sbi, segno) - - get_seg_entry(sbi, segno)->ckpt_valid_blocks; + left_blocks = CAP_BLKS_PER_SEC(sbi) - + get_ckpt_valid_blocks(sbi, segno, true); if (dent_blocks > left_blocks) return false; return true; @@ -626,7 +626,7 @@ static inline bool has_not_enough_free_secs(struct f2fs_sb_info *sbi, if (free_secs > upper_secs) return false; - else if (free_secs <= lower_secs) + if (free_secs <= lower_secs) return true; return !curseg_space; }