mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 03:01:39 -04:00
f2fs: add sysfs entries to select the gc policy
Add sysfs entry gc_idle to control the gc policy. Where gc_idle = 1 corresponds to selecting a cost benefit approach, while gc_idle = 2 corresponds to selecting a greedy approach to garbage collection. The selection is mutually exclusive one approach will work at any point. If gc_idle = 0, then this option is disabled. Cc: Gu Zheng <[email protected]> Signed-off-by: Namjae Jeon <[email protected]> Signed-off-by: Pankaj Kumar <[email protected]> Reviewed-by: Gu Zheng <[email protected]> [Jaegeuk Kim: change the select_gc_type() flow slightly] Signed-off-by: Jaegeuk Kim <[email protected]>
This commit is contained in:
parent
b59d0bae6c
commit
d2dc095f42
5 changed files with 30 additions and 3 deletions
16
fs/f2fs/gc.c
16
fs/f2fs/gc.c
|
|
@ -106,6 +106,8 @@ int start_gc_thread(struct f2fs_sb_info *sbi)
|
|||
gc_th->max_sleep_time = DEF_GC_THREAD_MAX_SLEEP_TIME;
|
||||
gc_th->no_gc_sleep_time = DEF_GC_THREAD_NOGC_SLEEP_TIME;
|
||||
|
||||
gc_th->gc_idle = 0;
|
||||
|
||||
sbi->gc_thread = gc_th;
|
||||
init_waitqueue_head(&sbi->gc_thread->gc_wait_queue_head);
|
||||
sbi->gc_thread->f2fs_gc_task = kthread_run(gc_thread_func, sbi,
|
||||
|
|
@ -130,9 +132,17 @@ void stop_gc_thread(struct f2fs_sb_info *sbi)
|
|||
sbi->gc_thread = NULL;
|
||||
}
|
||||
|
||||
static int select_gc_type(int gc_type)
|
||||
static int select_gc_type(struct f2fs_gc_kthread *gc_th, int gc_type)
|
||||
{
|
||||
return (gc_type == BG_GC) ? GC_CB : GC_GREEDY;
|
||||
int gc_mode = (gc_type == BG_GC) ? GC_CB : GC_GREEDY;
|
||||
|
||||
if (gc_th && gc_th->gc_idle) {
|
||||
if (gc_th->gc_idle == 1)
|
||||
gc_mode = GC_CB;
|
||||
else if (gc_th->gc_idle == 2)
|
||||
gc_mode = GC_GREEDY;
|
||||
}
|
||||
return gc_mode;
|
||||
}
|
||||
|
||||
static void select_policy(struct f2fs_sb_info *sbi, int gc_type,
|
||||
|
|
@ -145,7 +155,7 @@ static void select_policy(struct f2fs_sb_info *sbi, int gc_type,
|
|||
p->dirty_segmap = dirty_i->dirty_segmap[type];
|
||||
p->ofs_unit = 1;
|
||||
} else {
|
||||
p->gc_mode = select_gc_type(gc_type);
|
||||
p->gc_mode = select_gc_type(sbi->gc_thread, gc_type);
|
||||
p->dirty_segmap = dirty_i->dirty_segmap[DIRTY];
|
||||
p->ofs_unit = sbi->segs_per_sec;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,9 @@ struct f2fs_gc_kthread {
|
|||
unsigned int min_sleep_time;
|
||||
unsigned int max_sleep_time;
|
||||
unsigned int no_gc_sleep_time;
|
||||
|
||||
/* for changing gc mode */
|
||||
unsigned int gc_idle;
|
||||
};
|
||||
|
||||
struct inode_entry {
|
||||
|
|
|
|||
|
|
@ -148,12 +148,14 @@ static struct f2fs_attr f2fs_attr_##_name = { \
|
|||
F2FS_RW_ATTR(gc_min_sleep_time, min_sleep_time);
|
||||
F2FS_RW_ATTR(gc_max_sleep_time, max_sleep_time);
|
||||
F2FS_RW_ATTR(gc_no_gc_sleep_time, no_gc_sleep_time);
|
||||
F2FS_RW_ATTR(gc_idle, gc_idle);
|
||||
|
||||
#define ATTR_LIST(name) (&f2fs_attr_##name.attr)
|
||||
static struct attribute *f2fs_attrs[] = {
|
||||
ATTR_LIST(gc_min_sleep_time),
|
||||
ATTR_LIST(gc_max_sleep_time),
|
||||
ATTR_LIST(gc_no_gc_sleep_time),
|
||||
ATTR_LIST(gc_idle),
|
||||
NULL,
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue