Skip to contentSkip to conversation

f2fs: check number of blocks in a current section

PATCH In review Jaegeuk Kim 4 participants 26 messages Feb 23, 2024 – Mar 4, 2024 F2FS file system

lore
Share & tools
lore

Jaegeuk Kim

author maintainer
#0 lore raw

PATCH 1/5 f2fs: check number of blocks in a current section

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")
---
 fs/f2fs/segment.h | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)
fs/f2fs/segment.h +11 -11
index 3edd3809b6b5..15bf5edd9b3c 100644
@@ -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;
 }
Signature · 1 line
2.44.0.rc0.258.g7320e95886-goog
author maintainer
#1 lore raw

PATCH 2/5 f2fs: fix write pointers all the time

Even if the roll forward recovery stopped due to any error, we have to fix the write pointers in order to mount the disk from the previous checkpoint.

---
 fs/f2fs/recovery.c | 2 +-
 fs/f2fs/super.c    | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
fs/f2fs/recovery.c +1 -1
index b3baec666afe..8bbecb5f9323 100644
@@ -913,7 +913,7 @@ int f2fs_recover_fsync_data(struct f2fs_sb_info *sbi, bool check_only)
 	 * and the f2fs is not read only, check and fix zoned block devices'
 	 * write pointer consistency.
 	 */
-	if (!err && fix_curseg_write_pointer && !f2fs_readonly(sbi->sb) &&
+	if (fix_curseg_write_pointer && !f2fs_readonly(sbi->sb) &&
 			f2fs_sb_has_blkzoned(sbi)) {
 		err = f2fs_fix_curseg_write_pointer(sbi);
 		if (!err)
fs/f2fs/super.c +1 -1
index 2e41142d07c0..4d03ce1109ad 100644
@@ -4673,7 +4673,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
 	 * If the f2fs is not readonly and fsync data recovery succeeds,
 	 * check zoned block devices' write pointer consistency.
 	 */
-	if (!err && !f2fs_readonly(sb) && f2fs_sb_has_blkzoned(sbi)) {
+	if (!f2fs_readonly(sb) && f2fs_sb_has_blkzoned(sbi)) {
 		err = f2fs_check_write_pointer(sbi);
 		if (err)
 			goto free_meta;
Signature · 1 line
2.44.0.rc0.258.g7320e95886-goog
maintainer
#2 lore raw

Re: [f2fs-dev] [PATCH 2/5] f2fs: fix write pointers all the time

Quoted 2 lines · Jaegeuk Kim

Even if the roll forward recovery stopped due to any error, we have to fix the write pointers in order to mount the disk from the previous checkpoint.

Jaegeuk,

IIUC, we may lost warm node chain once we allocate new section for all logs, should we give some notification in log to indicate such condition that filesystem doesn't process a full recovery flow?

Thanks,

Quoted 33 lines
---
  fs/f2fs/recovery.c | 2 +-
  fs/f2fs/super.c    | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)
fs/f2fs/recovery.c +1 -1
index b3baec666afe..8bbecb5f9323 100644
@@ -913,7 +913,7 @@ int f2fs_recover_fsync_data(struct f2fs_sb_info *sbi, bool check_only)
  	 * and the f2fs is not read only, check and fix zoned block devices'
  	 * write pointer consistency.
  	 */
-	if (!err && fix_curseg_write_pointer && !f2fs_readonly(sbi->sb) &&
+	if (fix_curseg_write_pointer && !f2fs_readonly(sbi->sb) &&
  			f2fs_sb_has_blkzoned(sbi)) {
  		err = f2fs_fix_curseg_write_pointer(sbi);
  		if (!err)
fs/f2fs/super.c +1 -1
index 2e41142d07c0..4d03ce1109ad 100644
@@ -4673,7 +4673,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
  	 * If the f2fs is not readonly and fsync data recovery succeeds,
  	 * check zoned block devices' write pointer consistency.
  	 */
-	if (!err && !f2fs_readonly(sb) && f2fs_sb_has_blkzoned(sbi)) {
+	if (!f2fs_readonly(sb) && f2fs_sb_has_blkzoned(sbi)) {
  		err = f2fs_check_write_pointer(sbi);
  		if (err)
  			goto free_meta;
#3 lore raw

Re: [f2fs-dev] [PATCH 2/5] f2fs: fix write pointers all the time

Quoted 20 lines · Chao Yu
Quoted 2 lines · Jaegeuk Kim

Even if the roll forward recovery stopped due to any error, we have to fix the write pointers in order to mount the disk from the previous checkpoint.

Jaegeuk,

IIUC, we may lost warm node chain once we allocate new section for all logs, should we give some notification in log to indicate such condition that filesystem doesn't process a full recovery flow?

Thanks,

Quoted 7 lines
---
  fs/f2fs/recovery.c | 2 +-
  fs/f2fs/super.c    | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)
Quoted 12 lines

fs/f2fs/recovery.c int f2fs_recover_fsync_data(struct f2fs_sb_info *sbi, bool check_only) · line 918

Quoted 12 lines
fs/f2fs/recovery.c +1 -1
index b3baec666afe..8bbecb5f9323 100644
@@ -913,7 +913,7 @@ int f2fs_recover_fsync_data(struct f2fs_sb_info *sbi, bool check_only)
       * and the f2fs is not read only, check and fix zoned block devices'
       * write pointer consistency.
       */
-     if (!err && fix_curseg_write_pointer && !f2fs_readonly(sbi->sb) &&
+     if (fix_curseg_write_pointer && !f2fs_readonly(sbi->sb) &&
                      f2fs_sb_has_blkzoned(sbi)) {
              err = f2fs_fix_curseg_write_pointer(sbi);

We might overwrite the previous err value here with a new err from f2fs_fix_curseg_write_pointer().

Quoted 4 lines
Quoted 4 lines
fs/f2fs/recovery.c +0 -0
              if (!err)
fs/f2fs/super.c +0 -1
index 2e41142d07c0..4d03ce1109ad 100644
--- a/fs/f2fs/super.c
Quoted 8 lines

fs/f2fs/super.c static int f2fs_fill_super(struct super_block *sb, void *data, int silent) · line 4677

Quoted 8 lines

+++ b/fs/f2fs/super.c

fs/f2fs/super.c +1 -1
@@ -4673,7 +4673,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
       * If the f2fs is not readonly and fsync data recovery succeeds,
       * check zoned block devices' write pointer consistency.
       */
-     if (!err && !f2fs_readonly(sb) && f2fs_sb_has_blkzoned(sbi)) {
+     if (!f2fs_readonly(sb) && f2fs_sb_has_blkzoned(sbi)) {
              err = f2fs_check_write_pointer(sbi);

ditto

Quoted 8 lines

fs/f2fs/super.c static int f2fs_fill_super(struct super_block *sb, void *data, int silent) · line 4679

Quoted 2 lines
fs/f2fs/super.c +0 -0
              if (err)
                      goto free_meta;

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

author maintainer
#4 lore raw

Re: [f2fs-dev] [PATCH 2/5] f2fs: fix write pointers all the time

In reply to Chao Yu
Quoted 9 lines · Chao Yu
Quoted 2 lines · Jaegeuk Kim

Even if the roll forward recovery stopped due to any error, we have to fix the write pointers in order to mount the disk from the previous checkpoint.

Jaegeuk,

IIUC, we may lost warm node chain once we allocate new section for all logs, should we give some notification in log to indicate such condition that filesystem doesn't process a full recovery flow?

How about v2 to preserve the error which gives a warnings on roll-forward recovery?

Quoted 36 lines

Thanks,

Quoted 33 lines
---
  fs/f2fs/recovery.c | 2 +-
  fs/f2fs/super.c    | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)
fs/f2fs/recovery.c +1 -1
index b3baec666afe..8bbecb5f9323 100644
@@ -913,7 +913,7 @@ int f2fs_recover_fsync_data(struct f2fs_sb_info *sbi, bool check_only)
  	 * and the f2fs is not read only, check and fix zoned block devices'
  	 * write pointer consistency.
  	 */
-	if (!err && fix_curseg_write_pointer && !f2fs_readonly(sbi->sb) &&
+	if (fix_curseg_write_pointer && !f2fs_readonly(sbi->sb) &&
  			f2fs_sb_has_blkzoned(sbi)) {
  		err = f2fs_fix_curseg_write_pointer(sbi);
  		if (!err)
fs/f2fs/super.c +1 -1
index 2e41142d07c0..4d03ce1109ad 100644
@@ -4673,7 +4673,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
  	 * If the f2fs is not readonly and fsync data recovery succeeds,
  	 * check zoned block devices' write pointer consistency.
  	 */
-	if (!err && !f2fs_readonly(sb) && f2fs_sb_has_blkzoned(sbi)) {
+	if (!f2fs_readonly(sb) && f2fs_sb_has_blkzoned(sbi)) {
  		err = f2fs_check_write_pointer(sbi);
  		if (err)
  			goto free_meta;
author maintainer
#5 lore raw

Re: [PATCH 2/5 v2] f2fs: fix write pointers all the time

In reply to Jaegeuk Kim

Even if the roll forward recovery stopped due to any error, we have to fix the write pointers in order to mount the disk from the previous checkpoint.

---

from v1:
- preserve error

 fs/f2fs/recovery.c | 15 +++++++--------
 fs/f2fs/super.c    | 11 +++++++----
 2 files changed, 14 insertions(+), 12 deletions(-)
fs/f2fs/recovery.c +7 -8
index b3baec666afe..3078d5613748 100644
@@ -863,7 +863,6 @@ int f2fs_recover_fsync_data(struct f2fs_sb_info *sbi, bool check_only)
 	int ret = 0;
 	unsigned long s_flags = sbi->sb->s_flags;
 	bool need_writecp = false;
-	bool fix_curseg_write_pointer = false;
 
 	if (is_sbi_flag_set(sbi, SBI_IS_WRITABLE))
 		f2fs_info(sbi, "recover fsync data on readonly fs");
@@ -894,8 +893,6 @@ int f2fs_recover_fsync_data(struct f2fs_sb_info *sbi, bool check_only)
 	else
 		f2fs_bug_on(sbi, sbi->sb->s_flags & SB_ACTIVE);
 skip:
-	fix_curseg_write_pointer = !check_only || list_empty(&inode_list);
-
 	destroy_fsync_dnodes(&inode_list, err);
 	destroy_fsync_dnodes(&tmp_inode_list, err);
 
@@ -913,11 +910,13 @@ int f2fs_recover_fsync_data(struct f2fs_sb_info *sbi, bool check_only)
 	 * and the f2fs is not read only, check and fix zoned block devices'
 	 * write pointer consistency.
 	 */
-	if (!err && fix_curseg_write_pointer && !f2fs_readonly(sbi->sb) &&
-			f2fs_sb_has_blkzoned(sbi)) {
-		err = f2fs_fix_curseg_write_pointer(sbi);
-		if (!err)
-			err = f2fs_check_write_pointer(sbi);
+	if (f2fs_sb_has_blkzoned(sbi) && !f2fs_readonly(sbi->sb)) {
+		int err2 = f2fs_fix_curseg_write_pointer(sbi);
+
+		if (!err2)
+			err2 = f2fs_check_write_pointer(sbi);
+		if (err2)
+			err = err2;
 		ret = err;
 	}
 
fs/f2fs/super.c +7 -4
index d91e57ca6110..77348fd0a42b 100644
@@ -4674,11 +4674,14 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
 	 * If the f2fs is not readonly and fsync data recovery succeeds,
 	 * check zoned block devices' write pointer consistency.
 	 */
-	if (!err && !f2fs_readonly(sb) && f2fs_sb_has_blkzoned(sbi)) {
-		err = f2fs_check_write_pointer(sbi);
-		if (err)
-			goto free_meta;
+	if (f2fs_sb_has_blkzoned(sbi) && !f2fs_readonly(sb)) {
+		int err2 = f2fs_check_write_pointer(sbi);
+
+		if (err2)
+			err = err2;
 	}
+	if (err)
+		goto free_meta;
 
 	f2fs_init_inmem_curseg(sbi);
 
Signature · 1 line
2.44.0.rc1.240.g4c46232300-goog
maintainer Reviewed-by
#6 lore raw

Re: [f2fs-dev] [PATCH 2/5 v2] f2fs: fix write pointers all the time

Quoted 4 lines · Jaegeuk Kim

Even if the roll forward recovery stopped due to any error, we have to fix the write pointers in order to mount the disk from the previous checkpoint.

Thanks,

author maintainer
#7 lore raw

PATCH 3/5 f2fs: print zone status in string and some log

In reply to Jaegeuk Kim

No functional change, but add some more logs.

---
 fs/f2fs/segment.c | 34 ++++++++++++++++++++++++----------
 fs/f2fs/super.c   |  1 +
 2 files changed, 25 insertions(+), 10 deletions(-)
fs/f2fs/segment.c +24 -10
index d4f228e6f771..6d586ae8b55f 100644
@@ -4912,6 +4912,16 @@ static int sanity_check_curseg(struct f2fs_sb_info *sbi)
 }
 
 #ifdef CONFIG_BLK_DEV_ZONED
+const char *f2fs_zone_status[BLK_ZONE_COND_OFFLINE + 1] = {
+	[BLK_ZONE_COND_NOT_WP]		= "NOT_WP",
+	[BLK_ZONE_COND_EMPTY]		= "EMPTY",
+	[BLK_ZONE_COND_IMP_OPEN]	= "IMPLICITE_OPEN",
+	[BLK_ZONE_COND_EXP_OPEN]	= "EXPLICITE_OPEN",
+	[BLK_ZONE_COND_CLOSED]		= "CLOSED",
+	[BLK_ZONE_COND_READONLY]	= "READONLY",
+	[BLK_ZONE_COND_FULL]		= "FULL",
+	[BLK_ZONE_COND_OFFLINE]		= "OFFLINE",
+};
 
 static int check_zone_write_pointer(struct f2fs_sb_info *sbi,
 				    struct f2fs_dev_info *fdev,
@@ -4928,18 +4938,22 @@ static int check_zone_write_pointer(struct f2fs_sb_info *sbi,
 	zone_block = fdev->start_blk + (zone->start >> log_sectors_per_block);
 	zone_segno = GET_SEGNO(sbi, zone_block);
 
+	/*
+	 * Get # of valid block of the zone.
+	 */
+	valid_block_cnt = get_valid_blocks(sbi, zone_segno, true);
+
 	/*
 	 * Skip check of zones cursegs point to, since
 	 * fix_curseg_write_pointer() checks them.
 	 */
 	if (zone_segno >= MAIN_SEGS(sbi) ||
-	    IS_CURSEC(sbi, GET_SEC_FROM_SEG(sbi, zone_segno)))
+	    IS_CURSEC(sbi, GET_SEC_FROM_SEG(sbi, zone_segno))) {
+		f2fs_notice(sbi, "Open zones: valid block[0x%x,0x%x] cond[%s]",
+				zone_segno, valid_block_cnt,
+				f2fs_zone_status[zone->cond]);
 		return 0;
-
-	/*
-	 * Get # of valid block of the zone.
-	 */
-	valid_block_cnt = get_valid_blocks(sbi, zone_segno, true);
+	}
 
 	if ((!valid_block_cnt && zone->cond == BLK_ZONE_COND_EMPTY) ||
 	    (valid_block_cnt && zone->cond == BLK_ZONE_COND_FULL))
@@ -4947,8 +4961,8 @@ static int check_zone_write_pointer(struct f2fs_sb_info *sbi,
 
 	if (!valid_block_cnt) {
 		f2fs_notice(sbi, "Zone without valid block has non-zero write "
-			    "pointer. Reset the write pointer: cond[0x%x]",
-			    zone->cond);
+			    "pointer. Reset the write pointer: cond[%s]",
+			    f2fs_zone_status[zone->cond]);
 		ret = __f2fs_issue_discard_zone(sbi, fdev->bdev, zone_block,
 					zone->len >> log_sectors_per_block);
 		if (ret)
@@ -4965,8 +4979,8 @@ static int check_zone_write_pointer(struct f2fs_sb_info *sbi,
 	 * selected for write operation until it get discarded.
 	 */
 	f2fs_notice(sbi, "Valid blocks are not aligned with write "
-		    "pointer: valid block[0x%x,0x%x] cond[0x%x]",
-		    zone_segno, valid_block_cnt, zone->cond);
+		    "pointer: valid block[0x%x,0x%x] cond[%s]",
+		    zone_segno, valid_block_cnt, f2fs_zone_status[zone->cond]);
 
 	ret = blkdev_zone_mgmt(fdev->bdev, REQ_OP_ZONE_FINISH,
 				zone->start, zone->len, GFP_NOFS);
fs/f2fs/super.c +1 -0
index 4d03ce1109ad..fc7f1a9fbbda 100644
@@ -4674,6 +4674,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
 	 * check zoned block devices' write pointer consistency.
 	 */
 	if (!f2fs_readonly(sb) && f2fs_sb_has_blkzoned(sbi)) {
+		f2fs_notice(sbi, "Checking entire write pointers");
 		err = f2fs_check_write_pointer(sbi);
 		if (err)
 			goto free_meta;
Signature · 1 line
2.44.0.rc0.258.g7320e95886-goog
#9 lore raw

Re: [f2fs-dev] [PATCH 3/5] f2fs: print zone status in string and some log

In reply to Jaegeuk Kim
Quoted 34 lines · Jaegeuk Kim

No functional change, but add some more logs.

---
 fs/f2fs/segment.c | 34 ++++++++++++++++++++++++----------
 fs/f2fs/super.c   |  1 +
 2 files changed, 25 insertions(+), 10 deletions(-)
fs/f2fs/segment.c +10 -0
index d4f228e6f771..6d586ae8b55f 100644
@@ -4912,6 +4912,16 @@ static int sanity_check_curseg(struct f2fs_sb_info *sbi)
 }
 
 #ifdef CONFIG_BLK_DEV_ZONED
+const char *f2fs_zone_status[BLK_ZONE_COND_OFFLINE + 1] = {
+       [BLK_ZONE_COND_NOT_WP]          = "NOT_WP",
+       [BLK_ZONE_COND_EMPTY]           = "EMPTY",
+       [BLK_ZONE_COND_IMP_OPEN]        = "IMPLICITE_OPEN",
+       [BLK_ZONE_COND_EXP_OPEN]        = "EXPLICITE_OPEN",
+       [BLK_ZONE_COND_CLOSED]          = "CLOSED",
+       [BLK_ZONE_COND_READONLY]        = "READONLY",
+       [BLK_ZONE_COND_FULL]            = "FULL",
+       [BLK_ZONE_COND_OFFLINE]         = "OFFLINE",
+};
 
 static int check_zone_write_pointer(struct f2fs_sb_info *sbi,
                                    struct f2fs_dev_info *fdev,
@@ -4928,18 +4938,22 @@ static int check_zone_write_pointer(struct f2fs_sb_info *sbi,
        zone_block = fdev->start_blk + (zone->start >> log_sectors_per_block);
        zone_segno = GET_SEGNO(sbi, zone_block);
 

fs/f2fs/segment.c static int check_zone_write_pointer(struct f2fs_sb_info *sbi, · line 4950

Quoted 10 lines
fs/f2fs/segment.c +5 -0
+       /*
+        * Get # of valid block of the zone.
+        */
+       valid_block_cnt = get_valid_blocks(sbi, zone_segno, true);
+
        /*
         * Skip check of zones cursegs point to, since
         * fix_curseg_write_pointer() checks them.
         */
        if (zone_segno >= MAIN_SEGS(sbi) ||

How about this not to use a wrong segno value for get_valid_blocks() and not to print a wrong segment info?

    if (zone_segno >= MAIN_SEGS(sbi))
        return 0;

    valid_block_cnt = get_valid_blocks(sbi, zone_segno, true);
Quoted 58 lines
fs/f2fs/segment.c +9 -10
-           IS_CURSEC(sbi, GET_SEC_FROM_SEG(sbi, zone_segno)))
+           IS_CURSEC(sbi, GET_SEC_FROM_SEG(sbi, zone_segno))) {
+               f2fs_notice(sbi, "Open zones: valid block[0x%x,0x%x] cond[%s]",
+                               zone_segno, valid_block_cnt,
+                               f2fs_zone_status[zone->cond]);
                return 0;
-
-       /*
-        * Get # of valid block of the zone.
-        */
-       valid_block_cnt = get_valid_blocks(sbi, zone_segno, true);
+       }
 
        if ((!valid_block_cnt && zone->cond == BLK_ZONE_COND_EMPTY) ||
            (valid_block_cnt && zone->cond == BLK_ZONE_COND_FULL))
@@ -4947,8 +4961,8 @@ static int check_zone_write_pointer(struct f2fs_sb_info *sbi,
 
        if (!valid_block_cnt) {
                f2fs_notice(sbi, "Zone without valid block has non-zero write "
-                           "pointer. Reset the write pointer: cond[0x%x]",
-                           zone->cond);
+                           "pointer. Reset the write pointer: cond[%s]",
+                           f2fs_zone_status[zone->cond]);
                ret = __f2fs_issue_discard_zone(sbi, fdev->bdev, zone_block,
                                        zone->len >> log_sectors_per_block);
                if (ret)
@@ -4965,8 +4979,8 @@ static int check_zone_write_pointer(struct f2fs_sb_info *sbi,
         * selected for write operation until it get discarded.
         */
        f2fs_notice(sbi, "Valid blocks are not aligned with write "
-                   "pointer: valid block[0x%x,0x%x] cond[0x%x]",
-                   zone_segno, valid_block_cnt, zone->cond);
+                   "pointer: valid block[0x%x,0x%x] cond[%s]",
+                   zone_segno, valid_block_cnt, f2fs_zone_status[zone->cond]);
 
        ret = blkdev_zone_mgmt(fdev->bdev, REQ_OP_ZONE_FINISH,
                                zone->start, zone->len, GFP_NOFS);
fs/f2fs/super.c +1 -1
index 4d03ce1109ad..fc7f1a9fbbda 100644
@@ -4674,6 +4674,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
         * check zoned block devices' write pointer consistency.
         */
        if (!f2fs_readonly(sb) && f2fs_sb_has_blkzoned(sbi)) {
+               f2fs_notice(sbi, "Checking entire write pointers");
                err = f2fs_check_write_pointer(sbi);
                if (err)
                        goto free_meta;
--

2.44.0.rc0.258.g7320e95886-goog

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

author maintainer Reviewed-by Chao Yu on v1 3/5
#10 lore raw

Re: [PATCH 3/5 v2] f2fs: print zone status in string and some log

In reply to Jaegeuk Kim

No functional change, but add some more logs.

---

from v1:
- avoid unnecessary log per Daeho's comment

 fs/f2fs/segment.c | 27 +++++++++++++++++++++------
 fs/f2fs/super.c   |  1 +
 2 files changed, 22 insertions(+), 6 deletions(-)
fs/f2fs/segment.c +21 -6
index d4f228e6f771..31a9e7db19e3 100644
@@ -4912,6 +4912,16 @@ static int sanity_check_curseg(struct f2fs_sb_info *sbi)
 }
 
 #ifdef CONFIG_BLK_DEV_ZONED
+const char *f2fs_zone_status[BLK_ZONE_COND_OFFLINE + 1] = {
+	[BLK_ZONE_COND_NOT_WP]		= "NOT_WP",
+	[BLK_ZONE_COND_EMPTY]		= "EMPTY",
+	[BLK_ZONE_COND_IMP_OPEN]	= "IMPLICITE_OPEN",
+	[BLK_ZONE_COND_EXP_OPEN]	= "EXPLICITE_OPEN",
+	[BLK_ZONE_COND_CLOSED]		= "CLOSED",
+	[BLK_ZONE_COND_READONLY]	= "READONLY",
+	[BLK_ZONE_COND_FULL]		= "FULL",
+	[BLK_ZONE_COND_OFFLINE]		= "OFFLINE",
+};
 
 static int check_zone_write_pointer(struct f2fs_sb_info *sbi,
 				    struct f2fs_dev_info *fdev,
@@ -4932,14 +4942,19 @@ static int check_zone_write_pointer(struct f2fs_sb_info *sbi,
 	 * Skip check of zones cursegs point to, since
 	 * fix_curseg_write_pointer() checks them.
 	 */
-	if (zone_segno >= MAIN_SEGS(sbi) ||
-	    IS_CURSEC(sbi, GET_SEC_FROM_SEG(sbi, zone_segno)))
+	if (zone_segno >= MAIN_SEGS(sbi))
 		return 0;
 
 	/*
 	 * Get # of valid block of the zone.
 	 */
 	valid_block_cnt = get_valid_blocks(sbi, zone_segno, true);
+	if (IS_CURSEC(sbi, GET_SEC_FROM_SEG(sbi, zone_segno))) {
+		f2fs_notice(sbi, "Open zones: valid block[0x%x,0x%x] cond[%s]",
+				zone_segno, valid_block_cnt,
+				f2fs_zone_status[zone->cond]);
+		return 0;
+	}
 
 	if ((!valid_block_cnt && zone->cond == BLK_ZONE_COND_EMPTY) ||
 	    (valid_block_cnt && zone->cond == BLK_ZONE_COND_FULL))
@@ -4947,8 +4962,8 @@ static int check_zone_write_pointer(struct f2fs_sb_info *sbi,
 
 	if (!valid_block_cnt) {
 		f2fs_notice(sbi, "Zone without valid block has non-zero write "
-			    "pointer. Reset the write pointer: cond[0x%x]",
-			    zone->cond);
+			    "pointer. Reset the write pointer: cond[%s]",
+			    f2fs_zone_status[zone->cond]);
 		ret = __f2fs_issue_discard_zone(sbi, fdev->bdev, zone_block,
 					zone->len >> log_sectors_per_block);
 		if (ret)
@@ -4965,8 +4980,8 @@ static int check_zone_write_pointer(struct f2fs_sb_info *sbi,
 	 * selected for write operation until it get discarded.
 	 */
 	f2fs_notice(sbi, "Valid blocks are not aligned with write "
-		    "pointer: valid block[0x%x,0x%x] cond[0x%x]",
-		    zone_segno, valid_block_cnt, zone->cond);
+		    "pointer: valid block[0x%x,0x%x] cond[%s]",
+		    zone_segno, valid_block_cnt, f2fs_zone_status[zone->cond]);
 
 	ret = blkdev_zone_mgmt(fdev->bdev, REQ_OP_ZONE_FINISH,
 				zone->start, zone->len, GFP_NOFS);
fs/f2fs/super.c +1 -0
index 4d03ce1109ad..fc7f1a9fbbda 100644
@@ -4674,6 +4674,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
 	 * check zoned block devices' write pointer consistency.
 	 */
 	if (!f2fs_readonly(sb) && f2fs_sb_has_blkzoned(sbi)) {
+		f2fs_notice(sbi, "Checking entire write pointers");
 		err = f2fs_check_write_pointer(sbi);
 		if (err)
 			goto free_meta;
Signature · 1 line
2.44.0.rc1.240.g4c46232300-goog
maintainer
#11 lore raw

Re: [f2fs-dev] [PATCH 3/5 v2] f2fs: print zone status in string and some log

Quoted 3 lines · Jaegeuk Kim

No functional change, but add some more logs.

v2 looks fine to me.

Thanks,

author maintainer
#12 lore raw

Re: [PATCH 3/5] f2fs: print zone status in string and some log

In reply to Jaegeuk Kim
Quoted 13 lines · Jaegeuk Kim

No functional change, but add some more logs.

---
 fs/f2fs/segment.c | 34 ++++++++++++++++++++++++----------
 fs/f2fs/super.c   |  1 +
 2 files changed, 25 insertions(+), 10 deletions(-)
fs/f2fs/segment.c +0 -0
index d4f228e6f771..6d586ae8b55f 100644

fs/f2fs/segment.c static int sanity_check_curseg(struct f2fs_sb_info *sbi) · line 4915

Quoted 4 lines
fs/f2fs/segment.c +1 -0
@@ -4912,6 +4912,16 @@ static int sanity_check_curseg(struct f2fs_sb_info *sbi)
 }
 
 #ifdef CONFIG_BLK_DEV_ZONED
+const char *f2fs_zone_status[BLK_ZONE_COND_OFFLINE + 1] = {

Added static.

Quoted 77 lines
fs/f2fs/segment.c +23 -10
+	[BLK_ZONE_COND_NOT_WP]		= "NOT_WP",
+	[BLK_ZONE_COND_EMPTY]		= "EMPTY",
+	[BLK_ZONE_COND_IMP_OPEN]	= "IMPLICITE_OPEN",
+	[BLK_ZONE_COND_EXP_OPEN]	= "EXPLICITE_OPEN",
+	[BLK_ZONE_COND_CLOSED]		= "CLOSED",
+	[BLK_ZONE_COND_READONLY]	= "READONLY",
+	[BLK_ZONE_COND_FULL]		= "FULL",
+	[BLK_ZONE_COND_OFFLINE]		= "OFFLINE",
+};
 
 static int check_zone_write_pointer(struct f2fs_sb_info *sbi,
 				    struct f2fs_dev_info *fdev,
@@ -4928,18 +4938,22 @@ static int check_zone_write_pointer(struct f2fs_sb_info *sbi,
 	zone_block = fdev->start_blk + (zone->start >> log_sectors_per_block);
 	zone_segno = GET_SEGNO(sbi, zone_block);
 
+	/*
+	 * Get # of valid block of the zone.
+	 */
+	valid_block_cnt = get_valid_blocks(sbi, zone_segno, true);
+
 	/*
 	 * Skip check of zones cursegs point to, since
 	 * fix_curseg_write_pointer() checks them.
 	 */
 	if (zone_segno >= MAIN_SEGS(sbi) ||
-	    IS_CURSEC(sbi, GET_SEC_FROM_SEG(sbi, zone_segno)))
+	    IS_CURSEC(sbi, GET_SEC_FROM_SEG(sbi, zone_segno))) {
+		f2fs_notice(sbi, "Open zones: valid block[0x%x,0x%x] cond[%s]",
+				zone_segno, valid_block_cnt,
+				f2fs_zone_status[zone->cond]);
 		return 0;
-
-	/*
-	 * Get # of valid block of the zone.
-	 */
-	valid_block_cnt = get_valid_blocks(sbi, zone_segno, true);
+	}
 
 	if ((!valid_block_cnt && zone->cond == BLK_ZONE_COND_EMPTY) ||
 	    (valid_block_cnt && zone->cond == BLK_ZONE_COND_FULL))
@@ -4947,8 +4961,8 @@ static int check_zone_write_pointer(struct f2fs_sb_info *sbi,
 
 	if (!valid_block_cnt) {
 		f2fs_notice(sbi, "Zone without valid block has non-zero write "
-			    "pointer. Reset the write pointer: cond[0x%x]",
-			    zone->cond);
+			    "pointer. Reset the write pointer: cond[%s]",
+			    f2fs_zone_status[zone->cond]);
 		ret = __f2fs_issue_discard_zone(sbi, fdev->bdev, zone_block,
 					zone->len >> log_sectors_per_block);
 		if (ret)
@@ -4965,8 +4979,8 @@ static int check_zone_write_pointer(struct f2fs_sb_info *sbi,
 	 * selected for write operation until it get discarded.
 	 */
 	f2fs_notice(sbi, "Valid blocks are not aligned with write "
-		    "pointer: valid block[0x%x,0x%x] cond[0x%x]",
-		    zone_segno, valid_block_cnt, zone->cond);
+		    "pointer: valid block[0x%x,0x%x] cond[%s]",
+		    zone_segno, valid_block_cnt, f2fs_zone_status[zone->cond]);
 
 	ret = blkdev_zone_mgmt(fdev->bdev, REQ_OP_ZONE_FINISH,
 				zone->start, zone->len, GFP_NOFS);
fs/f2fs/super.c +1 -0
index 4d03ce1109ad..fc7f1a9fbbda 100644
@@ -4674,6 +4674,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
 	 * check zoned block devices' write pointer consistency.
 	 */
 	if (!f2fs_readonly(sb) && f2fs_sb_has_blkzoned(sbi)) {
+		f2fs_notice(sbi, "Checking entire write pointers");
 		err = f2fs_check_write_pointer(sbi);
 		if (err)
 			goto free_meta;
Signature · 1 line
2.44.0.rc0.258.g7320e95886-goog
author maintainer
#13 lore raw

PATCH 4/5 f2fs: prevent an f2fs_gc loop during disable_checkpoint

In reply to Jaegeuk Kim

Don't get stuck in the f2fs_gc loop while disabling checkpoint. Instead, we have a time-based management.

---
 fs/f2fs/super.c | 1 +
 1 file changed, 1 insertion(+)
fs/f2fs/super.c +1 -0
index fc7f1a9fbbda..7d9b92978709 100644
@@ -2191,6 +2191,7 @@ static int f2fs_disable_checkpoint(struct f2fs_sb_info *sbi)
 			.init_gc_type = FG_GC,
 			.should_migrate_blocks = false,
 			.err_gc_skipped = true,
+			.no_bg_gc = true,
 			.nr_free_secs = 1 };
 
 		f2fs_down_write(&sbi->gc_lock);
Signature · 1 line
2.44.0.rc0.258.g7320e95886-goog
maintainer Reviewed-by on v1 4/5
#14 lore raw

Re: [f2fs-dev] [PATCH 4/5] f2fs: prevent an f2fs_gc loop during disable_checkpoint

Quoted 4 lines · Jaegeuk Kim

Don't get stuck in the f2fs_gc loop while disabling checkpoint. Instead, we have a time-based management.

Thanks,

Reviewed-by
#15 lore raw

Re: [f2fs-dev] [PATCH 4/5] f2fs: prevent an f2fs_gc loop during disable_checkpoint

Quoted 16 lines · Chao Yu
Quoted 4 lines · Jaegeuk Kim

Don't get stuck in the f2fs_gc loop while disabling checkpoint. Instead, we have a time-based management.

Thanks,

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

author maintainer
#16 lore raw

PATCH 5/5 f2fs: allow to mount if cap is 100

In reply to Jaegeuk Kim

Don't block mounting the partition, if cap is 100%.

---
 fs/f2fs/segment.c | 3 +++
 1 file changed, 3 insertions(+)
fs/f2fs/segment.c +3 -0
index 6d586ae8b55f..f11361152d2a 100644
@@ -904,6 +904,9 @@ int f2fs_disable_cp_again(struct f2fs_sb_info *sbi, block_t unusable)
 {
 	int ovp_hole_segs =
 		(overprovision_segments(sbi) - reserved_segments(sbi));
+
+	if (F2FS_OPTION(sbi).unusable_cap_perc == 100)
+		return 0;
 	if (unusable > F2FS_OPTION(sbi).unusable_cap)
 		return -EAGAIN;
 	if (is_sbi_flag_set(sbi, SBI_CP_DISABLED_QUICK) &&
Signature · 1 line
2.44.0.rc0.258.g7320e95886-goog
#18 lore raw

Re: [f2fs-dev] [PATCH 5/5] f2fs: allow to mount if cap is 100

In reply to Jaegeuk Kim
Quoted 13 lines · Jaegeuk Kim

Don't block mounting the partition, if cap is 100%.

---
 fs/f2fs/segment.c | 3 +++
 1 file changed, 3 insertions(+)
fs/f2fs/segment.c +0 -0
index 6d586ae8b55f..f11361152d2a 100644

fs/f2fs/segment.c int f2fs_disable_cp_again(struct f2fs_sb_info *sbi, block_t unusable) · line 909

Quoted 6 lines
fs/f2fs/segment.c +3 -0
@@ -904,6 +904,9 @@ int f2fs_disable_cp_again(struct f2fs_sb_info *sbi, block_t unusable)
 {
        int ovp_hole_segs =
                (overprovision_segments(sbi) - reserved_segments(sbi));
+
+       if (F2FS_OPTION(sbi).unusable_cap_perc == 100)
+               return 0;

With this, f2fs will not execute GC. What is this 100 unusable_cap_perc used for?

Quoted 12 lines
fs/f2fs/segment.c +0 -1
        if (unusable > F2FS_OPTION(sbi).unusable_cap)
                return -EAGAIN;
        if (is_sbi_flag_set(sbi, SBI_CP_DISABLED_QUICK) &&
--

2.44.0.rc0.258.g7320e95886-goog

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

author maintainer
#19 lore raw

Re: [f2fs-dev] [PATCH 5/5] f2fs: allow to mount if cap is 100

Quoted 9 lines · Daeho Jeong
Quoted 8 lines · Jaegeuk Kim

Don't block mounting the partition, if cap is 100%.

---
 fs/f2fs/segment.c | 3 +++
 1 file changed, 3 insertions(+)
Quoted 14 lines

fs/f2fs/segment.c int f2fs_disable_cp_again(struct f2fs_sb_info *sbi, block_t unusable) · line 909

Quoted 11 lines
fs/f2fs/segment.c +3 -0
index 6d586ae8b55f..f11361152d2a 100644
@@ -904,6 +904,9 @@ int f2fs_disable_cp_again(struct f2fs_sb_info *sbi, block_t unusable)
 {
        int ovp_hole_segs =
                (overprovision_segments(sbi) - reserved_segments(sbi));
+
+       if (F2FS_OPTION(sbi).unusable_cap_perc == 100)
+               return 0;

With this, f2fs will not execute GC. What is this 100 unusable_cap_perc used for?

Theoritically, it won't, but I was hitting a GC loop, and I suspected a wrong section/segment layout. So, I posted the below, and guess we need this patch as workaround.

https://patchwork.kernel.org/project/f2fs/patch/[email protected]/

Quoted 13 lines
Quoted 13 lines
fs/f2fs/segment.c +0 -1
        if (unusable > F2FS_OPTION(sbi).unusable_cap)
                return -EAGAIN;
        if (is_sbi_flag_set(sbi, SBI_CP_DISABLED_QUICK) &&
--

2.44.0.rc0.258.g7320e95886-goog

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

Reviewed-by
#20 lore raw

Re: [f2fs-dev] [PATCH 5/5] f2fs: allow to mount if cap is 100

Quoted 26 lines · Jaegeuk Kim
Quoted 9 lines · Daeho Jeong
Quoted 8 lines · Jaegeuk Kim

Don't block mounting the partition, if cap is 100%.

---
 fs/f2fs/segment.c | 3 +++
 1 file changed, 3 insertions(+)
Quoted 14 lines

fs/f2fs/segment.c int f2fs_disable_cp_again(struct f2fs_sb_info *sbi, block_t unusable) · line 909

Quoted 11 lines
fs/f2fs/segment.c +3 -0
index 6d586ae8b55f..f11361152d2a 100644
@@ -904,6 +904,9 @@ int f2fs_disable_cp_again(struct f2fs_sb_info *sbi, block_t unusable)
 {
        int ovp_hole_segs =
                (overprovision_segments(sbi) - reserved_segments(sbi));
+
+       if (F2FS_OPTION(sbi).unusable_cap_perc == 100)
+               return 0;

With this, f2fs will not execute GC. What is this 100 unusable_cap_perc used for?

Quoted 5 lines

Theoritically, it won't, but I was hitting a GC loop, and I suspected a wrong section/segment layout. So, I posted the below, and guess we need this patch as workaround.

https://patchwork.kernel.org/project/f2fs/patch/[email protected]/

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
fs/f2fs/segment.c +0 -1
        if (unusable > F2FS_OPTION(sbi).unusable_cap)
                return -EAGAIN;
        if (is_sbi_flag_set(sbi, SBI_CP_DISABLED_QUICK) &&
--

2.44.0.rc0.258.g7320e95886-goog

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

maintainer
#21 lore raw
In reply to Jaegeuk Kim
Quoted 5 lines · Jaegeuk Kim

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

I tested this patch w/ testcase in [1], it doesn't complain.

[1] https://bugzilla.kernel.org/show_bug.cgi?id=215914

Quoted 2 lines

we don't have exact dirty page count per temperature. Hence, use a rough estimation.

Do we need more accurate per-temperature dirty node count for extreme corner case?

e.g. node_blocks is counted from hot dirty nodes, and current hot_node log has no enough free space for it.

Thanks,

Quoted 54 lines
Fixes cfd66bb715fd ("f2fs: fix deadloop in foreground GC")
---
  fs/f2fs/segment.h | 22 +++++++++++-----------
  1 file changed, 11 insertions(+), 11 deletions(-)
fs/f2fs/segment.h +11 -11
index 3edd3809b6b5..15bf5edd9b3c 100644
@@ -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;
  }
#22 lore raw
Quoted 42 lines · Chao Yu
Quoted 5 lines · Jaegeuk Kim

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

I tested this patch w/ testcase in [1], it doesn't complain.

[1] https://bugzilla.kernel.org/show_bug.cgi?id=215914

Quoted 2 lines

we don't have exact dirty page count per temperature. Hence, use a rough estimation.

Do we need more accurate per-temperature dirty node count for extreme corner case?

e.g. node_blocks is counted from hot dirty nodes, and current hot_node log has no enough free space for it.

Thanks,

Quoted 19 lines
Fixes cfd66bb715fd ("f2fs: fix deadloop in foreground GC")
---
  fs/f2fs/segment.h | 22 +++++++++++-----------
  1 file changed, 11 insertions(+), 11 deletions(-)
fs/f2fs/segment.h +1 -1
index 3edd3809b6b5..15bf5edd9b3c 100644
@@ -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;
 
Quoted 15 lines
Quoted 5 lines
fs/f2fs/segment.h +2 -1
-     /* 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;

fs/f2fs/segment.h static inline bool has_curseg_enough_space(struct f2fs_sb_info *sbi, · line 575

Quoted 10 lines
fs/f2fs/segment.h +4 -5
-             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;

I am not sure this is okay. The current implementation of f2fs may not be optimal when the HOT_NODE section's space requirements exceed its current capacity. In such cases, f2fs necessitates the creation of a new free section to accommodate the overflow, even though there might be free space available in other NODE sections. To address this issue, it may be necessary to implement a more accurate accounting system for NODE sections based on their temperature levels.

Quoted 26 lines
Quoted 12 lines
fs/f2fs/segment.h +3 -3
-     /* 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;

fs/f2fs/segment.h static inline bool has_not_enough_free_secs(struct f2fs_sb_info *sbi, · line 632

Quoted 8 lines
fs/f2fs/segment.h +1 -1
@@ -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;
  }

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

author maintainer
#23 lore raw
In reply to Jaegeuk Kim

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")

---

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(-)
fs/f2fs/segment.h +8 -9
index 3edd3809b6b5..335fc6285fa5 100644
@@ -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;
 }
Signature · 1 line
2.44.0.rc1.240.g4c46232300-goog
#25 lore raw
In reply to Jaegeuk Kim
This series was applied to jaegeuk/f2fs.git (dev) by Jaegeuk Kim <[email protected]>:

Hello:

This series was applied to jaegeuk/f2fs.git (dev)
by Jaegeuk Kim <[email protected]>:

Quoted 9 lines · On Fri, 23 Feb 2024 12:55:31 -0800 you wrote:

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.

[...]

Here is the summary with links:
- [f2fs-dev,1/5] f2fs: check number of blocks in a current section (no matching commit)
- [f2fs-dev,2/5] f2fs: fix write pointers all the time
(no matching commit)
- [f2fs-dev,3/5] f2fs: print zone status in string and some log (no matching commit)
- [f2fs-dev,4/5] f2fs: prevent an f2fs_gc loop during disable_checkpoint

    https://git.kernel.org/jaegeuk/f2fs/c/496b655d0460
  - [f2fs-dev,5/5] f2fs: allow to mount if cap is 100
    https://git.kernel.org/jaegeuk/f2fs/c/38fcb47642ae

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html