FROMGIT: 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 <chao@kernel.org> Reviewed-by: wangzijie <wangzijie1@honor.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org> Bug: 428889879 (cherry picked from commit 59c1c89e9ba8cefff05aa982dd9e6719f25e8ec5 https: //git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git dev) Link: https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git/commit/?id=59c1c89e9ba8 Change-Id: I07184caa6e5037d45258474dcca8adf1836b0f2d Signed-off-by: Rui Chen <chenrui9@honor.com>
This commit is contained in:
@@ -859,3 +859,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_STRICT_MODE_FL 0x00000001
|
||||||
SB_ENC_NO_COMPAT_FALLBACK_FL 0x00000002
|
SB_ENC_NO_COMPAT_FALLBACK_FL 0x00000002
|
||||||
============================ ==========
|
============================ ==========
|
||||||
|
|
||||||
|
What: /sys/fs/f2fs/<disk>/reserved_pin_section
|
||||||
|
Date: June 2025
|
||||||
|
Contact: "Chao Yu" <chao@kernel.org>
|
||||||
|
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.
|
||||||
|
|||||||
@@ -1713,6 +1713,9 @@ struct f2fs_sb_info {
|
|||||||
/* for skip statistic */
|
/* for skip statistic */
|
||||||
unsigned long long skipped_gc_rwsem; /* FG_GC only */
|
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 */
|
/* threshold for gc trials on pinned files */
|
||||||
unsigned short gc_pin_file_threshold;
|
unsigned short gc_pin_file_threshold;
|
||||||
struct f2fs_rwsem pin_sem;
|
struct f2fs_rwsem pin_sem;
|
||||||
|
|||||||
+2
-3
@@ -1858,9 +1858,8 @@ next_alloc:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (has_not_enough_free_secs(sbi, 0, f2fs_sb_has_blkzoned(sbi) ?
|
if (has_not_enough_free_secs(sbi, 0,
|
||||||
ZONED_PIN_SEC_REQUIRED_COUNT :
|
sbi->reserved_pin_section)) {
|
||||||
GET_SEC_FROM_SEG(sbi, overprovision_segments(sbi)))) {
|
|
||||||
f2fs_down_write(&sbi->gc_lock);
|
f2fs_down_write(&sbi->gc_lock);
|
||||||
stat_inc_gc_call_count(sbi, FOREGROUND);
|
stat_inc_gc_call_count(sbi, FOREGROUND);
|
||||||
err = f2fs_gc(sbi, &gc_control);
|
err = f2fs_gc(sbi, &gc_control);
|
||||||
|
|||||||
@@ -4780,6 +4780,10 @@ try_onemore:
|
|||||||
/* get segno of first zoned block device */
|
/* get segno of first zoned block device */
|
||||||
sbi->first_zoned_segno = get_first_seq_zone_segno(sbi);
|
sbi->first_zoned_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 */
|
/* Read accumulated write IO statistics if exists */
|
||||||
seg_i = CURSEG_I(sbi, CURSEG_HOT_NODE);
|
seg_i = CURSEG_I(sbi, CURSEG_HOT_NODE);
|
||||||
if (__exist_node_summaries(sbi))
|
if (__exist_node_summaries(sbi))
|
||||||
|
|||||||
@@ -824,6 +824,13 @@ out:
|
|||||||
return count;
|
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;
|
*ui = (unsigned int)t;
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
@@ -1130,6 +1137,7 @@ F2FS_SBI_GENERAL_RO_ATTR(unusable_blocks_per_sec);
|
|||||||
F2FS_SBI_GENERAL_RW_ATTR(blkzone_alloc_policy);
|
F2FS_SBI_GENERAL_RW_ATTR(blkzone_alloc_policy);
|
||||||
#endif
|
#endif
|
||||||
F2FS_SBI_GENERAL_RW_ATTR(carve_out);
|
F2FS_SBI_GENERAL_RW_ATTR(carve_out);
|
||||||
|
F2FS_SBI_GENERAL_RW_ATTR(reserved_pin_section);
|
||||||
|
|
||||||
/* STAT_INFO ATTR */
|
/* STAT_INFO ATTR */
|
||||||
#ifdef CONFIG_F2FS_STAT_FS
|
#ifdef CONFIG_F2FS_STAT_FS
|
||||||
@@ -1323,6 +1331,7 @@ static struct attribute *f2fs_attrs[] = {
|
|||||||
ATTR_LIST(last_age_weight),
|
ATTR_LIST(last_age_weight),
|
||||||
ATTR_LIST(max_read_extent_count),
|
ATTR_LIST(max_read_extent_count),
|
||||||
ATTR_LIST(carve_out),
|
ATTR_LIST(carve_out),
|
||||||
|
ATTR_LIST(reserved_pin_section),
|
||||||
NULL,
|
NULL,
|
||||||
};
|
};
|
||||||
ATTRIBUTE_GROUPS(f2fs);
|
ATTRIBUTE_GROUPS(f2fs);
|
||||||
|
|||||||
Reference in New Issue
Block a user