Skip to contentSkip to conversation

mkfs.f2fs: update allocation policy for ro feature

PATCH In review Chao Yu 3 participants 12 messages Sep 25, 2022 – Oct 6, 2022

lore
Share & tools
lore

Chao Yu

author
#0 lore raw

PATCH 1/1 mkfs.f2fs: update allocation policy for ro feature

Update allocation policy for ro feature:
- hot_data: allocating blocks by LBA ascending order
- hot_node: allocating blocks by LBA descending order

---
 mkfs/f2fs_format.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
mkfs/f2fs_format.c +2 -2
index 40ac589..8d0f410 100644
@@ -544,10 +544,10 @@ static int f2fs_prepare_super_block(void)
 	}
 
 	if (c.feature & cpu_to_le32(F2FS_FEATURE_RO)) {
-		c.cur_seg[CURSEG_HOT_NODE] = 0;
+		c.cur_seg[CURSEG_HOT_NODE] = last_section(last_zone(total_zones));
 		c.cur_seg[CURSEG_WARM_NODE] = 0;
 		c.cur_seg[CURSEG_COLD_NODE] = 0;
-		c.cur_seg[CURSEG_HOT_DATA] = 1;
+		c.cur_seg[CURSEG_HOT_DATA] = 0;
 		c.cur_seg[CURSEG_COLD_DATA] = 0;
 		c.cur_seg[CURSEG_WARM_DATA] = 0;
 	} else if (c.heap) {
Signature · 8 lines
2.36.1



_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
#1 lore raw
Quoted 3 lines · Chao Yu

Update allocation policy for ro feature:
- hot_data: allocating blocks by LBA ascending order
- hot_node: allocating blocks by LBA descending order

This will increase the RO image size.

Quoted 25 lines
---
 mkfs/f2fs_format.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
mkfs/f2fs_format.c +2 -2
index 40ac589..8d0f410 100644
@@ -544,10 +544,10 @@ static int f2fs_prepare_super_block(void)
 	}
 
 	if (c.feature & cpu_to_le32(F2FS_FEATURE_RO)) {
-		c.cur_seg[CURSEG_HOT_NODE] = 0;
+		c.cur_seg[CURSEG_HOT_NODE] = last_section(last_zone(total_zones));
 		c.cur_seg[CURSEG_WARM_NODE] = 0;
 		c.cur_seg[CURSEG_COLD_NODE] = 0;
-		c.cur_seg[CURSEG_HOT_DATA] = 1;
+		c.cur_seg[CURSEG_HOT_DATA] = 0;
 		c.cur_seg[CURSEG_COLD_DATA] = 0;
 		c.cur_seg[CURSEG_WARM_DATA] = 0;
 	} else if (c.heap) {
Signature · 1 line
2.36.1

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

author
#2 lore raw
Quoted 6 lines · Jaegeuk Kim
Quoted 3 lines · Chao Yu

Update allocation policy for ro feature:
- hot_data: allocating blocks by LBA ascending order
- hot_node: allocating blocks by LBA descending order

This will increase the RO image size.

Shouldn't RO image has fixed-size during mkfs?

Quoted 14 lines
Quoted 14 lines
---
  mkfs/f2fs_format.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
mkfs/f2fs_format.c +0 -0
index 40ac589..8d0f410 100644
@@ -544,10 +544,10 @@ static int f2fs_prepare_super_block(void)
  	}
 
Quoted 12 lines
Quoted 12 lines
mkfs/f2fs_format.c +2 -2
  	if (c.feature & cpu_to_le32(F2FS_FEATURE_RO)) {
-		c.cur_seg[CURSEG_HOT_NODE] = 0;
+		c.cur_seg[CURSEG_HOT_NODE] = last_section(last_zone(total_zones));
  		c.cur_seg[CURSEG_WARM_NODE] = 0;
  		c.cur_seg[CURSEG_COLD_NODE] = 0;
-		c.cur_seg[CURSEG_HOT_DATA] = 1;
+		c.cur_seg[CURSEG_HOT_DATA] = 0;
  		c.cur_seg[CURSEG_COLD_DATA] = 0;
  		c.cur_seg[CURSEG_WARM_DATA] = 0;
  	} else if (c.heap) {
Signature · 1 line
2.36.1

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

#3 lore raw
Quoted 9 lines · Chao Yu
Quoted 6 lines · Jaegeuk Kim
Quoted 3 lines · Chao Yu

Update allocation policy for ro feature:
- hot_data: allocating blocks by LBA ascending order
- hot_node: allocating blocks by LBA descending order

This will increase the RO image size.

Shouldn't RO image has fixed-size during mkfs?

First run gives the reduced size information, and second round makes the image with the required size.

Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
---
  mkfs/f2fs_format.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
mkfs/f2fs_format.c +1 -1
index 40ac589..8d0f410 100644
@@ -544,10 +544,10 @@ static int f2fs_prepare_super_block(void)
  	}
  	if (c.feature & cpu_to_le32(F2FS_FEATURE_RO)) {
-		c.cur_seg[CURSEG_HOT_NODE] = 0;
+		c.cur_seg[CURSEG_HOT_NODE] = last_section(last_zone(total_zones));
  		c.cur_seg[CURSEG_WARM_NODE] = 0;
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
mkfs/f2fs_format.c +1 -1
  		c.cur_seg[CURSEG_COLD_NODE] = 0;
-		c.cur_seg[CURSEG_HOT_DATA] = 1;
+		c.cur_seg[CURSEG_HOT_DATA] = 0;
  		c.cur_seg[CURSEG_COLD_DATA] = 0;
  		c.cur_seg[CURSEG_WARM_DATA] = 0;
  	} else if (c.heap) {
Signature · 1 line
2.36.1

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

author
#4 lore raw
Quoted 7 lines · Jaegeuk Kim
Quoted 6 lines · Chao Yu
Quoted 5 lines · Jaegeuk Kim
Quoted 3 lines · Chao Yu

Update allocation policy for ro feature:
- hot_data: allocating blocks by LBA ascending order
- hot_node: allocating blocks by LBA descending order

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

This will increase the RO image size.

Shouldn't RO image has fixed-size during mkfs?

First run gives the reduced size information, and second round makes the image with the required size.

I didn't get it, in which step it may increase the RO image size?

IIUC, after we apply this patch, reduced size information won't change due to that after sload in first run, total used block count should be fixed?

Thanks,

Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
---
   mkfs/f2fs_format.c | 4 ++--
   1 file changed, 2 insertions(+), 2 deletions(-)
mkfs/f2fs_format.c +1 -1
index 40ac589..8d0f410 100644
@@ -544,10 +544,10 @@ static int f2fs_prepare_super_block(void)
   	}
   	if (c.feature & cpu_to_le32(F2FS_FEATURE_RO)) {
-		c.cur_seg[CURSEG_HOT_NODE] = 0;
+		c.cur_seg[CURSEG_HOT_NODE] = last_section(last_zone(total_zones));
   		c.cur_seg[CURSEG_WARM_NODE] = 0;
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
mkfs/f2fs_format.c +1 -1
   		c.cur_seg[CURSEG_COLD_NODE] = 0;
-		c.cur_seg[CURSEG_HOT_DATA] = 1;
+		c.cur_seg[CURSEG_HOT_DATA] = 0;
   		c.cur_seg[CURSEG_COLD_DATA] = 0;
   		c.cur_seg[CURSEG_WARM_DATA] = 0;
   	} else if (c.heap) {
Signature · 1 line
2.36.1

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

#5 lore raw
Quoted 12 lines · Chao Yu
Quoted 11 lines · Jaegeuk Kim
Quoted 9 lines · Chao Yu
Quoted 6 lines · Jaegeuk Kim
Quoted 3 lines · Chao Yu

Update allocation policy for ro feature:
- hot_data: allocating blocks by LBA ascending order
- hot_node: allocating blocks by LBA descending order

This will increase the RO image size.

Shouldn't RO image has fixed-size during mkfs?

Quoted 7 lines
Quoted 2 lines

First run gives the reduced size information, and second round makes the image with the required size.

I didn't get it, in which step it may increase the RO image size?

IIUC, after we apply this patch, reduced size information won't change due to that after sload in first run, total used block count should be fixed?

First run fills the data and leaves the maximum LBA touched in the image. Then, it'll resize the image file and run again with the smallest image.

Quoted 22 lines

Thanks,

Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
---
   mkfs/f2fs_format.c | 4 ++--
   1 file changed, 2 insertions(+), 2 deletions(-)
mkfs/f2fs_format.c +1 -1
index 40ac589..8d0f410 100644
@@ -544,10 +544,10 @@ static int f2fs_prepare_super_block(void)
   	}
   	if (c.feature & cpu_to_le32(F2FS_FEATURE_RO)) {
-		c.cur_seg[CURSEG_HOT_NODE] = 0;
+		c.cur_seg[CURSEG_HOT_NODE] = last_section(last_zone(total_zones));
   		c.cur_seg[CURSEG_WARM_NODE] = 0;
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
mkfs/f2fs_format.c +1 -1
   		c.cur_seg[CURSEG_COLD_NODE] = 0;
-		c.cur_seg[CURSEG_HOT_DATA] = 1;
+		c.cur_seg[CURSEG_HOT_DATA] = 0;
   		c.cur_seg[CURSEG_COLD_DATA] = 0;
   		c.cur_seg[CURSEG_WARM_DATA] = 0;
   	} else if (c.heap) {
Signature · 1 line
2.36.1

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

author
#6 lore raw
Quoted 16 lines · Jaegeuk Kim
Quoted 15 lines · Chao Yu
Quoted 13 lines · Jaegeuk Kim
Quoted 9 lines · Chao Yu
Quoted 6 lines · Jaegeuk Kim
Quoted 3 lines · Chao Yu

Update allocation policy for ro feature:
- hot_data: allocating blocks by LBA ascending order
- hot_node: allocating blocks by LBA descending order

This will increase the RO image size.

Shouldn't RO image has fixed-size during mkfs?

First run gives the reduced size information, and second round makes the image with the required size.

Quoted 6 lines
Quoted 4 lines

I didn't get it, in which step it may increase the RO image size?

IIUC, after we apply this patch, reduced size information won't change due to that after sload in first run, total used block count should be fixed?

First run fills the data and leaves the maximum LBA touched in the image. Then,

How about caclulating required size w/ total used blocks rather than maximum LBA?

Thanks,

Quoted 24 lines

it'll resize the image file and run again with the smallest image.

Quoted 22 lines

Thanks,

Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
---
    mkfs/f2fs_format.c | 4 ++--
    1 file changed, 2 insertions(+), 2 deletions(-)
mkfs/f2fs_format.c +1 -1
index 40ac589..8d0f410 100644
@@ -544,10 +544,10 @@ static int f2fs_prepare_super_block(void)
    	}
    	if (c.feature & cpu_to_le32(F2FS_FEATURE_RO)) {
-		c.cur_seg[CURSEG_HOT_NODE] = 0;
+		c.cur_seg[CURSEG_HOT_NODE] = last_section(last_zone(total_zones));
    		c.cur_seg[CURSEG_WARM_NODE] = 0;
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
mkfs/f2fs_format.c +1 -1
    		c.cur_seg[CURSEG_COLD_NODE] = 0;
-		c.cur_seg[CURSEG_HOT_DATA] = 1;
+		c.cur_seg[CURSEG_HOT_DATA] = 0;
    		c.cur_seg[CURSEG_COLD_DATA] = 0;
    		c.cur_seg[CURSEG_WARM_DATA] = 0;
    	} else if (c.heap) {
Signature · 1 line
2.36.1

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

#7 lore raw
Quoted 17 lines · Chao Yu
Quoted 16 lines · Jaegeuk Kim
Quoted 15 lines · Chao Yu
Quoted 13 lines · Jaegeuk Kim
Quoted 9 lines · Chao Yu
Quoted 6 lines · Jaegeuk Kim
Quoted 3 lines · Chao Yu

Update allocation policy for ro feature:
- hot_data: allocating blocks by LBA ascending order
- hot_node: allocating blocks by LBA descending order

This will increase the RO image size.

Shouldn't RO image has fixed-size during mkfs?

First run gives the reduced size information, and second round makes the image with the required size.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

I didn't get it, in which step it may increase the RO image size?

IIUC, after we apply this patch, reduced size information won't change due to that after sload in first run, total used block count should be fixed?

First run fills the data and leaves the maximum LBA touched in the image. Then,

How about caclulating required size w/ total used blocks rather than maximum LBA?

Do you think that can give the smallest size for the image?

Quoted 27 lines

Thanks,

Quoted 24 lines

it'll resize the image file and run again with the smallest image.

Quoted 22 lines

Thanks,

Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
---
    mkfs/f2fs_format.c | 4 ++--
    1 file changed, 2 insertions(+), 2 deletions(-)
mkfs/f2fs_format.c +1 -1
index 40ac589..8d0f410 100644
@@ -544,10 +544,10 @@ static int f2fs_prepare_super_block(void)
    	}
    	if (c.feature & cpu_to_le32(F2FS_FEATURE_RO)) {
-		c.cur_seg[CURSEG_HOT_NODE] = 0;
+		c.cur_seg[CURSEG_HOT_NODE] = last_section(last_zone(total_zones));
    		c.cur_seg[CURSEG_WARM_NODE] = 0;
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
mkfs/f2fs_format.c +1 -1
    		c.cur_seg[CURSEG_COLD_NODE] = 0;
-		c.cur_seg[CURSEG_HOT_DATA] = 1;
+		c.cur_seg[CURSEG_HOT_DATA] = 0;
    		c.cur_seg[CURSEG_COLD_DATA] = 0;
    		c.cur_seg[CURSEG_WARM_DATA] = 0;
    	} else if (c.heap) {
Signature · 1 line
2.36.1

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

author
#8 lore raw
Quoted 20 lines · Jaegeuk Kim
Quoted 19 lines · Chao Yu
Quoted 18 lines · Jaegeuk Kim
Quoted 17 lines · Chao Yu
Quoted 7 lines · Jaegeuk Kim
Quoted 6 lines · Chao Yu
Quoted 5 lines · Jaegeuk Kim
Quoted 3 lines · Chao Yu

Update allocation policy for ro feature:
- hot_data: allocating blocks by LBA ascending order
- hot_node: allocating blocks by LBA descending order

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

This will increase the RO image size.

Shouldn't RO image has fixed-size during mkfs?

First run gives the reduced size information, and second round makes the image with the required size.

I didn't get it, in which step it may increase the RO image size?

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

IIUC, after we apply this patch, reduced size information won't change due to that after sload in first run, total used block count should be fixed?

First run fills the data and leaves the maximum LBA touched in the image. Then,

How about caclulating required size w/ total used blocks rather than maximum LBA?

Do you think that can give the smallest size for the image?

I guess so, but let me do some tests to check that.

Segments for data block and node block should be calculated separately:
required_blks = roundup(data_blks, blks_per_seg) + roundup(node_blks, blks_per_seg)

Am I missing something?

Thanks,

Quoted 28 lines
Quoted 28 lines

Thanks,

Quoted 24 lines

it'll resize the image file and run again with the smallest image.

Quoted 22 lines

Thanks,

Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
---
     mkfs/f2fs_format.c | 4 ++--
     1 file changed, 2 insertions(+), 2 deletions(-)
mkfs/f2fs_format.c +1 -1
index 40ac589..8d0f410 100644
@@ -544,10 +544,10 @@ static int f2fs_prepare_super_block(void)
     	}
     	if (c.feature & cpu_to_le32(F2FS_FEATURE_RO)) {
-		c.cur_seg[CURSEG_HOT_NODE] = 0;
+		c.cur_seg[CURSEG_HOT_NODE] = last_section(last_zone(total_zones));
     		c.cur_seg[CURSEG_WARM_NODE] = 0;
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
mkfs/f2fs_format.c +1 -1
     		c.cur_seg[CURSEG_COLD_NODE] = 0;
-		c.cur_seg[CURSEG_HOT_DATA] = 1;
+		c.cur_seg[CURSEG_HOT_DATA] = 0;
     		c.cur_seg[CURSEG_COLD_DATA] = 0;
     		c.cur_seg[CURSEG_WARM_DATA] = 0;
     	} else if (c.heap) {
Signature · 1 line
2.36.1

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

#9 lore raw
Quoted 28 lines · Chao Yu
Quoted 27 lines · Jaegeuk Kim
Quoted 25 lines · Chao Yu
Quoted 16 lines · Jaegeuk Kim
Quoted 15 lines · Chao Yu
Quoted 13 lines · Jaegeuk Kim
Quoted 9 lines · Chao Yu
Quoted 6 lines · Jaegeuk Kim
Quoted 3 lines · Chao Yu

Update allocation policy for ro feature:
- hot_data: allocating blocks by LBA ascending order
- hot_node: allocating blocks by LBA descending order

This will increase the RO image size.

Shouldn't RO image has fixed-size during mkfs?

First run gives the reduced size information, and second round makes the image with the required size.

Quoted 6 lines
Quoted 4 lines

I didn't get it, in which step it may increase the RO image size?

IIUC, after we apply this patch, reduced size information won't change due to that after sload in first run, total used block count should be fixed?

First run fills the data and leaves the maximum LBA touched in the image. Then,

How about caclulating required size w/ total used blocks rather than maximum LBA?

Quoted 8 lines
Quoted 1 line

Do you think that can give the smallest size for the image?

I guess so, but let me do some tests to check that.

Segments for data block and node block should be calculated separately:
required_blks = roundup(data_blks, blks_per_seg) + roundup(node_blks, blks_per_seg)

Am I missing something?

I think that'd be fine tho, please test first.

Quoted 31 lines

Thanks,

Quoted 28 lines
Quoted 28 lines

Thanks,

Quoted 24 lines

it'll resize the image file and run again with the smallest image.

Quoted 22 lines

Thanks,

Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
---
     mkfs/f2fs_format.c | 4 ++--
     1 file changed, 2 insertions(+), 2 deletions(-)
mkfs/f2fs_format.c +1 -1
index 40ac589..8d0f410 100644
@@ -544,10 +544,10 @@ static int f2fs_prepare_super_block(void)
     	}
     	if (c.feature & cpu_to_le32(F2FS_FEATURE_RO)) {
-		c.cur_seg[CURSEG_HOT_NODE] = 0;
+		c.cur_seg[CURSEG_HOT_NODE] = last_section(last_zone(total_zones));
     		c.cur_seg[CURSEG_WARM_NODE] = 0;
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
mkfs/f2fs_format.c +1 -1
     		c.cur_seg[CURSEG_COLD_NODE] = 0;
-		c.cur_seg[CURSEG_HOT_DATA] = 1;
+		c.cur_seg[CURSEG_HOT_DATA] = 0;
     		c.cur_seg[CURSEG_COLD_DATA] = 0;
     		c.cur_seg[CURSEG_WARM_DATA] = 0;
     	} else if (c.heap) {
Signature · 1 line
2.36.1

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

author
#10 lore raw
Quoted 31 lines · Jaegeuk Kim
Quoted 30 lines · Chao Yu
Quoted 28 lines · Jaegeuk Kim
Quoted 17 lines · Chao Yu
Quoted 16 lines · Jaegeuk Kim
Quoted 15 lines · Chao Yu
Quoted 13 lines · Jaegeuk Kim
Quoted 9 lines · Chao Yu
Quoted 6 lines · Jaegeuk Kim
Quoted 3 lines · Chao Yu

Update allocation policy for ro feature:
- hot_data: allocating blocks by LBA ascending order
- hot_node: allocating blocks by LBA descending order

This will increase the RO image size.

Shouldn't RO image has fixed-size during mkfs?

First run gives the reduced size information, and second round makes the image with the required size.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

I didn't get it, in which step it may increase the RO image size?

IIUC, after we apply this patch, reduced size information won't change due to that after sload in first run, total used block count should be fixed?

First run fills the data and leaves the maximum LBA touched in the image. Then,

How about caclulating required size w/ total used blocks rather than maximum LBA?

Do you think that can give the smallest size for the image?

Quoted 8 lines
Quoted 6 lines

I guess so, but let me do some tests to check that.

Segments for data block and node block should be calculated separately:
required_blks = roundup(data_blks, blks_per_seg) + roundup(node_blks, blks_per_seg)

Am I missing something?

I think that'd be fine tho, please test first.

I did some tests, seems above method works... but original implementation may have bug, could you please check below patch:

From 757d8f5191e21065f0c914512c17f963e5a17945 Mon Sep 17 00:00:00 2001
From: Chao Yu <[email protected]>
Date: Thu, 6 Oct 2022 22:09:38 +0800
Subject: [PATCH] sload.f2fs: fix to calculate max size correctly

Max image size should be calculated with round_up().

- dd if=/dev/zero of=img bs=1M count=512
- mkfs.f2fs -O ro -f img

a) sload.f2fs -f <kernel_path>/kernel/ img
b) sload.f2fs -f <kernel_path>/mm/ img
c) sload.f2fs -f <kernel_path>/include/ img

Before:
[FSCK] Max image size: 48 MB, Free space: 462 MB
[FSCK] Max image size: 25 MB, Free space: 485 MB
[FSCK] Max image size: 112 MB, Free space: 398 MB

After:
[FSCK] Max image size: 50 MB, Free space: 460 MB
[FSCK] Max image size: 26 MB, Free space: 484 MB
[FSCK] Max image size: 114 MB, Free space: 396 MB

---
 fsck/f2fs.h        | 2 ++
 fsck/fsck.c        | 9 ++++++---
 include/f2fs_fs.h  | 6 ++++--
 mkfs/f2fs_format.c | 3 ++-
 4 files changed, 14 insertions(+), 6 deletions(-)
fsck/f2fs.h +2 -0
index 030d750..88b98f9 100644
@@ -420,6 +420,8 @@ static inline block_t __end_block_addr(struct f2fs_sb_info *sbi)
 	return end + le64_to_cpu(F2FS_RAW_SUPER(sbi)->block_count);
 }
 
+#define BLKS_PER_SEC(sbi)						\
+		((sbi)->segs_per_sec * (sbi)->blocks_per_seg)
 #define GET_ZONENO_FROM_SEGNO(sbi, segno)                               \
 	((segno / sbi->segs_per_sec) / sbi->secs_per_zone)
 
fsck/fsck.c +6 -3
index b1b6722..f6ff986 100644
@@ -3179,6 +3179,7 @@ int fsck_verify(struct f2fs_sb_info *sbi)
 	struct f2fs_fsck *fsck = F2FS_FSCK(sbi);
 	struct hard_link_node *node = NULL;
 	bool verify_failed = false;
+	uint64_t max_size, free_size;
 
 	if (c.show_file_map)
 		return 0;
@@ -3229,10 +3230,12 @@ int fsck_verify(struct f2fs_sb_info *sbi)
 		}
 		c.bug_on = 1;
 	}
+
+	max_size = round_up(c.max_size, sbi->blocksize * BLKS_PER_SEC(sbi));
+	free_size = SM_I(sbi)->segment_count * sbi->blocks_per_seg *
+				sbi->blocksize - max_size;
 	printf("[FSCK] Max image size: %"PRIu64" MB, Free space: %u MB\n",
-		c.max_size >> 20,
-		(sbi->user_block_count - sbi->total_valid_block_count) >>
-		(20 - F2FS_BLKSIZE_BITS));
+					max_size >> 20, free_size >> 20);
 	printf("[FSCK] Unreachable nat entries                       ");
 	if (nr_unref_nid == 0x0) {
 		printf(" [Ok..] [0x%x]\n", nr_unref_nid);
include/f2fs_fs.h +4 -2
index 509d75a..0a99717 100644
@@ -663,7 +663,8 @@ struct f2fs_configuration {
 	(void) (&_max1 == &_max2);		\
 	_max1 > _max2 ? _max1 : _max2; })
 
-#define round_up(x, y)		(((x) + (y) - 1) / (y))
+#define div_round_up(x, y)		(((x) + (y) - 1) / (y))
+#define round_up(x, y)			(div_round_up(x, y) * (y))
 /*
  * Copied from fs/f2fs/f2fs.h
  */
@@ -1592,7 +1593,8 @@ static inline double get_best_overprovision(struct f2fs_super_block *sb)
 
 	for (; candidate <= end; candidate += diff) {
 		reserved = (2 * (100 / candidate + 1) + 6) *
-				round_up(usable_main_segs, get_sb(section_count));
+				div_round_up(usable_main_segs,
+						get_sb(section_count));
 		ovp = (usable_main_segs - reserved) * candidate / 100;
 		space = usable_main_segs - reserved - ovp;
 		if (max_space < space) {
mkfs/f2fs_format.c +2 -1
index 40ac589..14f5534 100644
@@ -485,7 +485,8 @@ static int f2fs_prepare_super_block(void)
 
 	c.reserved_segments =
 			(2 * (100 / c.overprovision + 1) + NR_CURSEG_TYPE) *
-			round_up(f2fs_get_usable_segments(sb), get_sb(section_count));
+			div_round_up(f2fs_get_usable_segments(sb),
+						get_sb(section_count));
 
 	if (c.feature & cpu_to_le32(F2FS_FEATURE_RO)) {
 		c.overprovision = 0;
Signature · 1 line
2.36.1
Quoted 32 lines
Quoted 32 lines

Thanks,

Quoted 28 lines
Quoted 28 lines

Thanks,

Quoted 24 lines

it'll resize the image file and run again with the smallest image.

Quoted 22 lines

Thanks,

Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
---
      mkfs/f2fs_format.c | 4 ++--
      1 file changed, 2 insertions(+), 2 deletions(-)
mkfs/f2fs_format.c +1 -1
index 40ac589..8d0f410 100644
@@ -544,10 +544,10 @@ static int f2fs_prepare_super_block(void)
      	}
      	if (c.feature & cpu_to_le32(F2FS_FEATURE_RO)) {
-		c.cur_seg[CURSEG_HOT_NODE] = 0;
+		c.cur_seg[CURSEG_HOT_NODE] = last_section(last_zone(total_zones));
      		c.cur_seg[CURSEG_WARM_NODE] = 0;
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
mkfs/f2fs_format.c +1 -1
      		c.cur_seg[CURSEG_COLD_NODE] = 0;
-		c.cur_seg[CURSEG_HOT_DATA] = 1;
+		c.cur_seg[CURSEG_HOT_DATA] = 0;
      		c.cur_seg[CURSEG_COLD_DATA] = 0;
      		c.cur_seg[CURSEG_WARM_DATA] = 0;
      	} else if (c.heap) {
Signature · 1 line
2.36.1

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

#11 lore raw
In reply to Jaegeuk Kim
Quoted 20 lines · Chao Yu
Quoted 3 lines

Update allocation policy for ro feature:
- hot_data: allocating blocks by LBA ascending order
- hot_node: allocating blocks by LBA descending order

This will increase the RO image size.

Quoted 13 lines
---
 mkfs/f2fs_format.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
mkfs/f2fs_format.c index renamed from mkfs/f2fs_format.c +0 -0

40ac589..8d0f410 100644

mkfs/f2fs_format.c +0 -0
@@ -544,10 +544,10 @@ static int f2fs_prepare_super_block(void)
 	}
 
Quoted 8 lines

mkfs/f2fs_format.c static int f2fs_prepare_super_block(void)

Quoted 3 lines
mkfs/f2fs_format.c +1 -1
 	if (c.feature & cpu_to_le32(F2FS_FEATURE_RO)) {
-		c.cur_seg[CURSEG_HOT_NODE] = 0;
+		c.cur_seg[CURSEG_HOT_NODE] =

last_section(last_zone(total_zones));

mkfs/f2fs_format.c static int f2fs_prepare_super_block(void) · line 550

Quoted 4 lines
mkfs/f2fs_format.c +1 -1
 		c.cur_seg[CURSEG_WARM_NODE] = 0;
 		c.cur_seg[CURSEG_COLD_NODE] = 0;
-		c.cur_seg[CURSEG_HOT_DATA] = 1;
+		c.cur_seg[CURSEG_HOT_DATA] = 0;

Hi,

I want to know that, does this change try to reduce the possibility of the 3rd situation that previous referred (f2fs: extent cache: support extent for no-compressed file)? The largest extent maybe only cover one part of continuous blocks in f2fs ro-image.

Thanks,

Quoted 11 lines
Quoted 5 lines
mkfs/f2fs_format.c +0 -1
 		c.cur_seg[CURSEG_COLD_DATA] = 0;
 		c.cur_seg[CURSEG_WARM_DATA] = 0;
 	} else if (c.heap) {
--

2.36.1

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

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