f2fs: introduce reserved_pin_section sysfs entry
Chao Yu
maintainerPATCH v2 1/1 f2fs: introduce reserved_pin_section sysfs entry
This patch introduces /sys/fs/f2fs/<dev>/reserved_pin_section for tuning @needed parameter of has_not_enough_free_secs(), if we configure it w/ zero, it can avoid f2fs_gc() as much as possible while fallocating on pinned file.
---
v2:
- assign SM_I(sbi)->ovp_segments after f2fs_build_segment_manager()
Documentation/ABI/testing/sysfs-fs-f2fs | 9 +++++++++ fs/f2fs/f2fs.h | 3 +++ fs/f2fs/file.c | 5 ++--- fs/f2fs/super.c | 4 ++++ fs/f2fs/sysfs.c | 9 +++++++++ 5 files changed, 27 insertions(+), 3 deletions(-)
Documentation/ABI/testing/sysfs-fs-f2fs +9 -0
@@ -861,3 +861,12 @@ Description: This is a read-only entry to show the value of sb.s_encoding_flags, SB_ENC_STRICT_MODE_FL 0x00000001 SB_ENC_NO_COMPAT_FALLBACK_FL 0x00000002 ============================ ========== + +What: /sys/fs/f2fs/<disk>/reserved_pin_section +Date: June 2025 +Contact: "Chao Yu" <[email protected]> +Description: This threshold is used to control triggering garbage collection while + fallocating on pinned file, so, it can guarantee there is enough free + reserved section before preallocating on pinned file. + By default, the value is ovp_sections, especially, for zoned ufs, the + value is 1.
fs/f2fs/f2fs.h +3 -0
@@ -1724,6 +1724,9 @@ struct f2fs_sb_info {/* for skip statistic */ unsigned long long skipped_gc_rwsem;/* FG_GC only */ +/* free sections reserved for pinned file */ +unsigned int reserved_pin_section; +/* threshold for gc trials on pinned files */ unsigned short gc_pin_file_threshold;struct f2fs_rwsem pin_sem;
fs/f2fs/file.c +2 -3
@@ -1887,9 +1887,8 @@ static int f2fs_expand_inode_data(struct inode *inode, loff_t offset, } } -if (has_not_enough_free_secs (sbi,0 ,f2fs_sb_has_blkzoned (sbi) ? -ZONED_PIN_SEC_REQUIRED_COUNT : -GET_SEC_FROM_SEG (sbi,overprovision_segments (sbi)))) { +if (has_not_enough_free_secs (sbi,0 , + sbi->reserved_pin_section)) {f2fs_down_write (&sbi->gc_lock);stat_inc_gc_call_count (sbi,FOREGROUND ); err =f2fs_gc (sbi, &gc_control);
fs/f2fs/super.c +4 -0
@@ -5017,6 +5017,10 @@ static int f2fs_fill_super(struct super_block *sb, struct fs_context *fc)/* get segno of first zoned block device */ sbi->first_seq_zone_segno =get_first_seq_zone_segno (sbi); + sbi->reserved_pin_section =f2fs_sb_has_blkzoned (sbi) ? +ZONED_PIN_SEC_REQUIRED_COUNT : +GET_SEC_FROM_SEG (sbi,overprovision_segments (sbi)); +/* Read accumulated write IO statistics if exists */ seg_i =CURSEG_I (sbi,CURSEG_HOT_NODE );if (__exist_node_summaries (sbi))
fs/f2fs/sysfs.c +9 -0
@@ -824,6 +824,13 @@ static ssize_t __sbi_store(struct f2fs_attr *a,return count; } +if (!strcmp (a->attr.name,"reserved_pin_section" )) { +if (t >GET_SEC_FROM_SEG (sbi,overprovision_segments (sbi))) +return -EINVAL ; + *ui = (unsigned int )t; +return count; + } + *ui = (unsigned int )t;return count;
@@ -1130,6 +1137,7 @@ F2FS_SBI_GENERAL_RO_ATTR(unusable_blocks_per_sec);F2FS_SBI_GENERAL_RW_ATTR (blkzone_alloc_policy);#endif F2FS_SBI_GENERAL_RW_ATTR (carve_out); +F2FS_SBI_GENERAL_RW_ATTR (reserved_pin_section);/* STAT_INFO ATTR */ #ifdef CONFIG_F2FS_STAT_FS
@@ -1323,6 +1331,7 @@ static struct attribute *f2fs_attrs[] = {ATTR_LIST (last_age_weight),ATTR_LIST (max_read_extent_count),ATTR_LIST (carve_out), +ATTR_LIST (reserved_pin_section),NULL , };ATTRIBUTE_GROUPS (f2fs);
Signature · 1 line
2.40.1
Quoted 6 lines
This patch introduces /sys/fs/f2fs/<dev>/reserved_pin_section for tuning @needed parameter of
has_not_enough_free_secs(), if we configure it w/ zero, it can avoidf2fs_gc()as much as possible while fallocating on pinned file.Signed-off-by Chao Yu <[email protected]>
Thanks for helping to introduce this sysfs entry.
Quoted 108 lines
---
v2:
- assign SM_I(sbi)->ovp_segments afterf2fs_build_segment_manager()Documentation/ABI/testing/sysfs-fs-f2fs | 9 +++++++++ fs/f2fs/f2fs.h | 3 +++ fs/f2fs/file.c | 5 ++--- fs/f2fs/super.c | 4 ++++ fs/f2fs/sysfs.c | 9 +++++++++ 5 files changed, 27 insertions(+), 3 deletions(-)Documentation/ABI/testing/sysfs-fs-f2fs +9
-0@@ -861,3 +861,12 @@ Description: This is a read-only entry to show the value of sb.s_encoding_flags, SB_ENC_STRICT_MODE_FL 0x00000001 SB_ENC_NO_COMPAT_FALLBACK_FL 0x00000002 ============================ ========== + +What: /sys/fs/f2fs/<disk>/reserved_pin_section +Date: June 2025 +Contact: "Chao Yu" <[email protected]> +Description: This threshold is used to control triggering garbage collection while + fallocating on pinned file, so, it can guarantee there is enough free + reserved section before preallocating on pinned file. + By default, the value is ovp_sections, especially, for zoned ufs, the + value is 1.fs/f2fs/f2fs.h +3
-0@@ -1724,6 +1724,9 @@ struct f2fs_sb_info {/* for skip statistic */ unsigned long long skipped_gc_rwsem;/* FG_GC only */ +/* free sections reserved for pinned file */ +unsigned int reserved_pin_section; +/* threshold for gc trials on pinned files */ unsigned short gc_pin_file_threshold;struct f2fs_rwsem pin_sem;fs/f2fs/file.c +2
-3@@ -1887,9 +1887,8 @@ static int f2fs_expand_inode_data(struct inode *inode, loff_t offset, } } -if (has_not_enough_free_secs (sbi,0 ,f2fs_sb_has_blkzoned (sbi) ? -ZONED_PIN_SEC_REQUIRED_COUNT : -GET_SEC_FROM_SEG (sbi,overprovision_segments (sbi)))) { +if (has_not_enough_free_secs (sbi,0 , + sbi->reserved_pin_section)) {f2fs_down_write (&sbi->gc_lock);stat_inc_gc_call_count (sbi,FOREGROUND ); err =f2fs_gc (sbi, &gc_control);fs/f2fs/super.c +4
-0@@ -5017,6 +5017,10 @@ static int f2fs_fill_super(struct super_block *sb, struct fs_context *fc)/* get segno of first zoned block device */ sbi->first_seq_zone_segno =get_first_seq_zone_segno (sbi); + sbi->reserved_pin_section =f2fs_sb_has_blkzoned (sbi) ? +ZONED_PIN_SEC_REQUIRED_COUNT : +GET_SEC_FROM_SEG (sbi,overprovision_segments (sbi)); +/* Read accumulated write IO statistics if exists */ seg_i =CURSEG_I (sbi,CURSEG_HOT_NODE );if (__exist_node_summaries (sbi))fs/f2fs/sysfs.c +9
-0@@ -824,6 +824,13 @@ static ssize_t __sbi_store(struct f2fs_attr *a,return count; } +if (!strcmp (a->attr.name,"reserved_pin_section" )) { +if (t >GET_SEC_FROM_SEG (sbi,overprovision_segments (sbi))) +return -EINVAL ; + *ui = (unsigned int )t; +return count; + } + *ui = (unsigned int )t;return count;@@ -1130,6 +1137,7 @@ F2FS_SBI_GENERAL_RO_ATTR(unusable_blocks_per_sec);F2FS_SBI_GENERAL_RW_ATTR (blkzone_alloc_policy);#endif F2FS_SBI_GENERAL_RW_ATTR (carve_out); +F2FS_SBI_GENERAL_RW_ATTR (reserved_pin_section);/* STAT_INFO ATTR */ #ifdef CONFIG_F2FS_STAT_FS @@ -1323,6 +1331,7 @@ static struct attribute *f2fs_attrs[] = {ATTR_LIST (last_age_weight),ATTR_LIST (max_read_extent_count),ATTR_LIST (carve_out), +ATTR_LIST (reserved_pin_section),NULL , };ATTRIBUTE_GROUPS (f2fs);Signature · 1 line
2.40.1
This patch was applied to jaegeuk/f2fs.git (dev) by Jaegeuk Kim <[email protected]>:
Hello:
This patch was applied to jaegeuk/f2fs.git (dev)
by Jaegeuk Kim <[email protected]>:
Quoted 8 lines · On Fri, 13 Jun 2025 13:51:09 +0800 you wrote:
This patch introduces /sys/fs/f2fs/<dev>/reserved_pin_section for tuning @needed parameter of
has_not_enough_free_secs(), if we configure it w/ zero, it can avoidf2fs_gc()as much as possible while fallocating on pinned file.Signed-off-by Chao Yu <[email protected]>[...]
Here is the summary with links:
- [f2fs-dev,v2] f2fs: introduce reserved_pin_section sysfs entry
https://git.kernel.org/jaegeuk/f2fs/c/59c1c89e9ba8
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html