Skip to content

Commit 325163e

Browse files
Daeho JeongJaegeuk Kim
authored andcommitted
f2fs: add gc_urgent_high_remaining sysfs node
Added a new sysfs node called gc_urgent_high_remaining. The user can set the trial count limit for GC urgent high mode with this value. If GC thread gets to the limit, the mode will turn back to GC normal mode. By default, the value is zero, which means there is no limit like before. Signed-off-by: Daeho Jeong <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent 77900c4 commit 325163e

File tree

5 files changed

+34
-0
lines changed

5 files changed

+34
-0
lines changed

Documentation/ABI/testing/sysfs-fs-f2fs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,3 +533,10 @@ Description: With "mode=fragment:block" mount options, we can scatter block allo
533533
f2fs will allocate 1..<max_fragment_chunk> blocks in a chunk and make a hole
534534
in the length of 1..<max_fragment_hole> by turns. This value can be set
535535
between 1..512 and the default value is 4.
536+
537+
What: /sys/fs/f2fs/<disk>/gc_urgent_high_remaining
538+
Date: December 2021
539+
Contact: "Daeho Jeong" <[email protected]>
540+
Description: You can set the trial count limit for GC urgent high mode with this value.
541+
If GC thread gets to the limit, the mode will turn back to GC normal mode.
542+
By default, the value is zero, which means there is no limit like before.

fs/f2fs/f2fs.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1683,6 +1683,9 @@ struct f2fs_sb_info {
16831683
unsigned int cur_victim_sec; /* current victim section num */
16841684
unsigned int gc_mode; /* current GC state */
16851685
unsigned int next_victim_seg[2]; /* next segment in victim section */
1686+
spinlock_t gc_urgent_high_lock;
1687+
bool gc_urgent_high_limited; /* indicates having limited trial count */
1688+
unsigned int gc_urgent_high_remaining; /* remaining trial count for GC_URGENT_HIGH */
16861689

16871690
/* for skip statistic */
16881691
unsigned int atomic_files; /* # of opened atomic file */

fs/f2fs/gc.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,18 @@ static int gc_thread_func(void *data)
9292
* So, I'd like to wait some time to collect dirty segments.
9393
*/
9494
if (sbi->gc_mode == GC_URGENT_HIGH) {
95+
spin_lock(&sbi->gc_urgent_high_lock);
96+
if (sbi->gc_urgent_high_limited) {
97+
if (!sbi->gc_urgent_high_remaining) {
98+
sbi->gc_urgent_high_limited = false;
99+
spin_unlock(&sbi->gc_urgent_high_lock);
100+
sbi->gc_mode = GC_NORMAL;
101+
continue;
102+
}
103+
sbi->gc_urgent_high_remaining--;
104+
}
105+
spin_unlock(&sbi->gc_urgent_high_lock);
106+
95107
wait_ms = gc_th->urgent_sleep_time;
96108
down_write(&sbi->gc_lock);
97109
goto do_gc;

fs/f2fs/super.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3548,6 +3548,7 @@ static void init_sb_info(struct f2fs_sb_info *sbi)
35483548
sbi->seq_file_ra_mul = MIN_RA_MUL;
35493549
sbi->max_fragment_chunk = DEF_FRAGMENT_SIZE;
35503550
sbi->max_fragment_hole = DEF_FRAGMENT_SIZE;
3551+
spin_lock_init(&sbi->gc_urgent_high_lock);
35513552

35523553
sbi->dir_level = DEF_DIR_LEVEL;
35533554
sbi->interval_time[CP_TIME] = DEF_CP_INTERVAL;

fs/f2fs/sysfs.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,15 @@ static ssize_t __sbi_store(struct f2fs_attr *a,
487487
return count;
488488
}
489489

490+
if (!strcmp(a->attr.name, "gc_urgent_high_remaining")) {
491+
spin_lock(&sbi->gc_urgent_high_lock);
492+
sbi->gc_urgent_high_limited = t == 0 ? false : true;
493+
sbi->gc_urgent_high_remaining = t;
494+
spin_unlock(&sbi->gc_urgent_high_lock);
495+
496+
return count;
497+
}
498+
490499
#ifdef CONFIG_F2FS_IOSTAT
491500
if (!strcmp(a->attr.name, "iostat_enable")) {
492501
sbi->iostat_enable = !!t;
@@ -742,6 +751,7 @@ F2FS_RW_ATTR(FAULT_INFO_TYPE, f2fs_fault_info, inject_type, inject_type);
742751
#endif
743752
F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, data_io_flag, data_io_flag);
744753
F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, node_io_flag, node_io_flag);
754+
F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, gc_urgent_high_remaining, gc_urgent_high_remaining);
745755
F2FS_RW_ATTR(CPRC_INFO, ckpt_req_control, ckpt_thread_ioprio, ckpt_thread_ioprio);
746756
F2FS_GENERAL_RO_ATTR(dirty_segments);
747757
F2FS_GENERAL_RO_ATTR(free_segments);
@@ -855,6 +865,7 @@ static struct attribute *f2fs_attrs[] = {
855865
#endif
856866
ATTR_LIST(data_io_flag),
857867
ATTR_LIST(node_io_flag),
868+
ATTR_LIST(gc_urgent_high_remaining),
858869
ATTR_LIST(ckpt_thread_ioprio),
859870
ATTR_LIST(dirty_segments),
860871
ATTR_LIST(free_segments),

0 commit comments

Comments
 (0)