public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jaegeuk Kim <jaegeuk@kernel.org>
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
Date: Mon, 26 Feb 2024 15:14:26 -0800	[thread overview]
Message-ID: <Zd0bUnFCWmPtwK2u@google.com> (raw)
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 <jaegeuk@kernel.org>
---

 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


  parent reply	other threads:[~2024-02-26 23:14 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-23 20:55 [PATCH 1/5] f2fs: check number of blocks in a current section Jaegeuk Kim
2024-02-23 20:55 ` [PATCH 2/5] f2fs: fix write pointers all the time Jaegeuk Kim
2024-02-26  2:48   ` [f2fs-dev] " Chao Yu
2024-02-26 17:33     ` Daeho Jeong
2024-02-27  1:00     ` Jaegeuk Kim
2024-02-27  0:59   ` [PATCH 2/5 v2] " Jaegeuk Kim
2024-02-27  6:19     ` [f2fs-dev] " Chao Yu
2024-02-23 20:55 ` [PATCH 3/5] f2fs: print zone status in string and some log Jaegeuk Kim
2024-02-26  2:54   ` [f2fs-dev] " Chao Yu
2024-02-26 19:03   ` Daeho Jeong
2024-02-26 22:52   ` [PATCH 3/5 v2] " Jaegeuk Kim
2024-02-27  6:26     ` [f2fs-dev] " Chao Yu
2024-03-04 17:47   ` [PATCH 3/5] " Jaegeuk Kim
2024-02-23 20:55 ` [PATCH 4/5] f2fs: prevent an f2fs_gc loop during disable_checkpoint Jaegeuk Kim
2024-02-26  2:58   ` [f2fs-dev] " Chao Yu
2024-02-26 19:14     ` Daeho Jeong
2024-02-23 20:55 ` [PATCH 5/5] f2fs: allow to mount if cap is 100 Jaegeuk Kim
2024-02-26  2:59   ` [f2fs-dev] " Chao Yu
2024-02-26 19:34   ` Daeho Jeong
2024-02-26 22:47     ` Jaegeuk Kim
2024-02-28  3:47       ` Daeho Jeong
2024-02-26  2:40 ` [f2fs-dev] [PATCH 1/5] f2fs: check number of blocks in a current section Chao Yu
2024-02-26 17:17   ` Daeho Jeong
2024-02-26 23:14 ` Jaegeuk Kim [this message]
2024-02-27  6:08   ` [f2fs-dev] [PATCH 1/5 v2] " Chao Yu
2024-02-28 22:50 ` [f2fs-dev] [PATCH 1/5] " patchwork-bot+f2fs

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Zd0bUnFCWmPtwK2u@google.com \
    --to=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox