Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1602082rbb; Mon, 26 Feb 2024 15:15:32 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW9RdvJbZqemeQTthnmqnPtBZ2AeaJSRJHBbm/ZFH4T2dgP5WxNtkE28LwOB5DSlW0Ua+NG3ZKuTEGe4ewsaoGaywOqugncQcGvask9Cg== X-Google-Smtp-Source: AGHT+IE8J4Rijk1LpW23oQReDf2FZsrB1RUKHYrx/xL4hMVd7j2WGDqAYpaftUsLyn0GgRvp6KxX X-Received: by 2002:a17:903:1ca:b0:1dc:afd1:a85a with SMTP id e10-20020a17090301ca00b001dcafd1a85amr2712946plh.2.1708989332011; Mon, 26 Feb 2024 15:15:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708989331; cv=pass; d=google.com; s=arc-20160816; b=WtoBCehQshKc9PEEAcnDqqmig36z7t3v0hxV6pB0shYk62hxrZq/u8RrViwBrAxmM5 wXJUo6Tf1C0wWUtOy/wUcBoeESssom2p2x74TFm0hq65b11isdS3ZlYpDKKMmh3x6W8M NuhscnO4U2wG62JHepaVuJoMi8oMy1MZgFJZ223ltSiDVxxWcKg3Wd1opXg8KtPGatqX EydkpylbwnQF9b9USciYJHsCoUNsa0FZ0uXiVCKUGgzy+q0VXcbpYEyq9ABCN0o45xv2 AkO8cGfhyS/25Xksz2e5lliTuovFaiXmfeOco7YqV3xvEazONSZ14bnFzBFWAr6K9r49 GKwA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:to :from:date:dkim-signature; bh=aamj8ctSz1OFnKSnlFsCtXZ1B9hJrIyHzwm8GGhvKHg=; fh=YrirFCflo0HC1j049mfXEQ1jukbakoASvSGieiclzfE=; b=pj5B1AuNEmzVd78Fn0pZlE6bNfxJYKTC+MffH8kSKjtToI41ONABx60SGBRRBIFXHB QwP/Lal9YAFLZUP3NUjqjeoBb+H+gGbj48P8BMnxxuHm9Gdd7cB+xg85EETSbvJlNXzQ cGvRJSun5vvct2bGvFCbL654Sp3A/LKZPz4EK6YMyKO8OKjBER/P7J05JtHAFPE52/0/ j6P/p1x+2QaB5C8+c8RScZDZlOTLPTKyFRQZ4w30Ipq+8a44b14AwSVAtj8DlAtqIBKZ nDHn7unB0Pm2JgLRMjGMoXIw3W2uYeDdArm+fqLEBMwoL6teDwBWH6VdROF4IeW0tcUo Ecbw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FDaQrFRr; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-82435-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82435-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id h9-20020a170902680900b001dc11f149d1si310566plk.248.2024.02.26.15.15.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 15:15:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-82435-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FDaQrFRr; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-82435-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82435-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 445E6B20C7C for ; Mon, 26 Feb 2024 23:14:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D1E33135A47; Mon, 26 Feb 2024 23:14:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="FDaQrFRr" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 04C3B133285 for ; Mon, 26 Feb 2024 23:14:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708989269; cv=none; b=Bap0HjEmHzurEtvFgWjDI4ydz/OhecRYMKSGNQbyZnSJKggL4VhuJ7FTaGMd6np7yARZyct4I3CYddF/jW3PIeeWWsx6IGq3r0fWZBQMpwWOicZw4wFUqQzu29XTYFRiLIVWXoLHyunAG1Rg2ELcQyKQuLzGypCs0onbnjOb9tA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708989269; c=relaxed/simple; bh=O2m22R0yZCGVUk6cDrklmfyRKcLTlO8eSyTHoowZsEA=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=PUPOnKyGCQUP04tYYg+yoq4K/cvzIgM0GpBIA0Upl9FbIo2PtH82L37DOgKAQS4a/0ysaz7NAHQFnMNiYoZSBvoJMiCCeSkUQSdrqczOANYxJ4kW8LUxRsrjqxafge96N9YPXEkD30KWUhHSK7yrEJLwJLoY6bTNFIGYuATFCTE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FDaQrFRr; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 74CFEC433C7; Mon, 26 Feb 2024 23:14:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708989268; bh=O2m22R0yZCGVUk6cDrklmfyRKcLTlO8eSyTHoowZsEA=; h=Date:From:To:Subject:References:In-Reply-To:From; b=FDaQrFRrmymL+JYoAdRI13bV7T8F3WAJ2guVlW5g1VaWiWm34V7JVBM2RkJIUoRlb D2DqI89d/OcyH04NS0dbUQsfQ/Yu8e5e0gi5SmVH48vQNItQtDQ4UDprXuW7oiMr9R WdG6HCdA7CgIdOy8GMkEB0an5bBFAX+AIJij5pjmwCgenVeLmaSZ4x87686VCLvyzB 30xoADnGNJZKRdQXQrWn5Zg2tknISMO2IqhcvZS2iNO8HrAoZ4CSRtycFKwV8pp/tu emD7F5qixKWTCBp2U3W8uE2F+WXn4B5m+Yyp52DS8L/LwbinKgIVAxHbLpxhuqHvfo fTzv21yohbATg== Date: Mon, 26 Feb 2024 15:14:26 -0800 From: Jaegeuk Kim To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Subject: Re: [PATCH 1/5 v2] f2fs: check number of blocks in a current section Message-ID: References: <20240223205535.307307-1-jaegeuk@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240223205535.307307-1-jaegeuk@kernel.org> In cfd66bb715fd ("f2fs: fix deadloop in foreground GC"), we needed to check the number of blocks in a section instead of the segment. Fixes: cfd66bb715fd ("f2fs: fix deadloop in foreground GC") Signed-off-by: Jaegeuk Kim --- from v1: - check current node block space to deal with the worst case - TODO: need to fine tuning on node temperature fs/f2fs/segment.h | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h index 3edd3809b6b5..335fc6285fa5 100644 --- a/fs/f2fs/segment.h +++ b/fs/f2fs/segment.h @@ -561,23 +561,22 @@ 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 in the worst case. */ 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; - + 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 +625,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; } -- 2.44.0.rc1.240.g4c46232300-goog