Commit 88dd8934 authored by Chao Yu's avatar Chao Yu Committed by Jaegeuk Kim

f2fs: clean up {in,de}create_sleep_time

Use pointer parameter @wait to pass result in {in,de}create_sleep_time for
cleanup.
Signed-off-by: default avatarChao Yu <chao2.yu@samsung.com>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent feeb0deb
...@@ -44,7 +44,7 @@ static int gc_thread_func(void *data) ...@@ -44,7 +44,7 @@ static int gc_thread_func(void *data)
break; break;
if (sbi->sb->s_writers.frozen >= SB_FREEZE_WRITE) { if (sbi->sb->s_writers.frozen >= SB_FREEZE_WRITE) {
wait_ms = increase_sleep_time(gc_th, wait_ms); increase_sleep_time(gc_th, &wait_ms);
continue; continue;
} }
...@@ -65,15 +65,15 @@ static int gc_thread_func(void *data) ...@@ -65,15 +65,15 @@ static int gc_thread_func(void *data)
continue; continue;
if (!is_idle(sbi)) { if (!is_idle(sbi)) {
wait_ms = increase_sleep_time(gc_th, wait_ms); increase_sleep_time(gc_th, &wait_ms);
mutex_unlock(&sbi->gc_mutex); mutex_unlock(&sbi->gc_mutex);
continue; continue;
} }
if (has_enough_invalid_blocks(sbi)) if (has_enough_invalid_blocks(sbi))
wait_ms = decrease_sleep_time(gc_th, wait_ms); decrease_sleep_time(gc_th, &wait_ms);
else else
wait_ms = increase_sleep_time(gc_th, wait_ms); increase_sleep_time(gc_th, &wait_ms);
stat_inc_bggc_count(sbi); stat_inc_bggc_count(sbi);
......
...@@ -66,26 +66,26 @@ static inline block_t limit_free_user_blocks(struct f2fs_sb_info *sbi) ...@@ -66,26 +66,26 @@ static inline block_t limit_free_user_blocks(struct f2fs_sb_info *sbi)
return (long)(reclaimable_user_blocks * LIMIT_FREE_BLOCK) / 100; return (long)(reclaimable_user_blocks * LIMIT_FREE_BLOCK) / 100;
} }
static inline long increase_sleep_time(struct f2fs_gc_kthread *gc_th, long wait) static inline void increase_sleep_time(struct f2fs_gc_kthread *gc_th,
long *wait)
{ {
if (wait == gc_th->no_gc_sleep_time) if (*wait == gc_th->no_gc_sleep_time)
return wait; return;
wait += gc_th->min_sleep_time; *wait += gc_th->min_sleep_time;
if (wait > gc_th->max_sleep_time) if (*wait > gc_th->max_sleep_time)
wait = gc_th->max_sleep_time; *wait = gc_th->max_sleep_time;
return wait;
} }
static inline long decrease_sleep_time(struct f2fs_gc_kthread *gc_th, long wait) static inline void decrease_sleep_time(struct f2fs_gc_kthread *gc_th,
long *wait)
{ {
if (wait == gc_th->no_gc_sleep_time) if (*wait == gc_th->no_gc_sleep_time)
wait = gc_th->max_sleep_time; *wait = gc_th->max_sleep_time;
wait -= gc_th->min_sleep_time; *wait -= gc_th->min_sleep_time;
if (wait <= gc_th->min_sleep_time) if (*wait <= gc_th->min_sleep_time)
wait = gc_th->min_sleep_time; *wait = gc_th->min_sleep_time;
return wait;
} }
static inline bool has_enough_invalid_blocks(struct f2fs_sb_info *sbi) static inline bool has_enough_invalid_blocks(struct f2fs_sb_info *sbi)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment