Skip to content

Commit 59c1c89

Browse files
chaseyuJaegeuk Kim
authored andcommitted
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. Signed-off-by: Chao Yu <[email protected]> Reviewed-by: wangzijie <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent 90d5c9b commit 59c1c89

File tree

5 files changed

+27
-3
lines changed

5 files changed

+27
-3
lines changed

Documentation/ABI/testing/sysfs-fs-f2fs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,3 +861,12 @@ Description: This is a read-only entry to show the value of sb.s_encoding_flags,
861861
SB_ENC_STRICT_MODE_FL 0x00000001
862862
SB_ENC_NO_COMPAT_FALLBACK_FL 0x00000002
863863
============================ ==========
864+
865+
What: /sys/fs/f2fs/<disk>/reserved_pin_section
866+
Date: June 2025
867+
Contact: "Chao Yu" <[email protected]>
868+
Description: This threshold is used to control triggering garbage collection while
869+
fallocating on pinned file, so, it can guarantee there is enough free
870+
reserved section before preallocating on pinned file.
871+
By default, the value is ovp_sections, especially, for zoned ufs, the
872+
value is 1.

fs/f2fs/f2fs.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1724,6 +1724,9 @@ struct f2fs_sb_info {
17241724
/* for skip statistic */
17251725
unsigned long long skipped_gc_rwsem; /* FG_GC only */
17261726

1727+
/* free sections reserved for pinned file */
1728+
unsigned int reserved_pin_section;
1729+
17271730
/* threshold for gc trials on pinned files */
17281731
unsigned short gc_pin_file_threshold;
17291732
struct f2fs_rwsem pin_sem;

fs/f2fs/file.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1887,9 +1887,8 @@ static int f2fs_expand_inode_data(struct inode *inode, loff_t offset,
18871887
}
18881888
}
18891889

1890-
if (has_not_enough_free_secs(sbi, 0, f2fs_sb_has_blkzoned(sbi) ?
1891-
ZONED_PIN_SEC_REQUIRED_COUNT :
1892-
GET_SEC_FROM_SEG(sbi, overprovision_segments(sbi)))) {
1890+
if (has_not_enough_free_secs(sbi, 0,
1891+
sbi->reserved_pin_section)) {
18931892
f2fs_down_write(&sbi->gc_lock);
18941893
stat_inc_gc_call_count(sbi, FOREGROUND);
18951894
err = f2fs_gc(sbi, &gc_control);

fs/f2fs/super.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4771,6 +4771,10 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
47714771
/* get segno of first zoned block device */
47724772
sbi->first_seq_zone_segno = get_first_seq_zone_segno(sbi);
47734773

4774+
sbi->reserved_pin_section = f2fs_sb_has_blkzoned(sbi) ?
4775+
ZONED_PIN_SEC_REQUIRED_COUNT :
4776+
GET_SEC_FROM_SEG(sbi, overprovision_segments(sbi));
4777+
47744778
/* Read accumulated write IO statistics if exists */
47754779
seg_i = CURSEG_I(sbi, CURSEG_HOT_NODE);
47764780
if (__exist_node_summaries(sbi))

fs/f2fs/sysfs.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,13 @@ static ssize_t __sbi_store(struct f2fs_attr *a,
824824
return count;
825825
}
826826

827+
if (!strcmp(a->attr.name, "reserved_pin_section")) {
828+
if (t > GET_SEC_FROM_SEG(sbi, overprovision_segments(sbi)))
829+
return -EINVAL;
830+
*ui = (unsigned int)t;
831+
return count;
832+
}
833+
827834
*ui = (unsigned int)t;
828835

829836
return count;
@@ -1130,6 +1137,7 @@ F2FS_SBI_GENERAL_RO_ATTR(unusable_blocks_per_sec);
11301137
F2FS_SBI_GENERAL_RW_ATTR(blkzone_alloc_policy);
11311138
#endif
11321139
F2FS_SBI_GENERAL_RW_ATTR(carve_out);
1140+
F2FS_SBI_GENERAL_RW_ATTR(reserved_pin_section);
11331141

11341142
/* STAT_INFO ATTR */
11351143
#ifdef CONFIG_F2FS_STAT_FS
@@ -1323,6 +1331,7 @@ static struct attribute *f2fs_attrs[] = {
13231331
ATTR_LIST(last_age_weight),
13241332
ATTR_LIST(max_read_extent_count),
13251333
ATTR_LIST(carve_out),
1334+
ATTR_LIST(reserved_pin_section),
13261335
NULL,
13271336
};
13281337
ATTRIBUTE_GROUPS(f2fs);

0 commit comments

Comments
 (0)