mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 20:51:03 +02:00
f2fs: add has_enough_free_secs()
Replace !has_not_enough_free_secs w/ has_enough_free_secs. BTW avoid nested 'if' statements in f2fs_balance_fs(). Signed-off-by: Yangtao Li <frank.li@vivo.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
@@ -1872,7 +1872,7 @@ retry:
|
|||||||
if (gc_type == FG_GC) {
|
if (gc_type == FG_GC) {
|
||||||
sbi->cur_victim_sec = NULL_SEGNO;
|
sbi->cur_victim_sec = NULL_SEGNO;
|
||||||
|
|
||||||
if (!has_not_enough_free_secs(sbi, sec_freed, 0)) {
|
if (has_enough_free_secs(sbi, sec_freed, 0)) {
|
||||||
if (!gc_control->no_bg_gc &&
|
if (!gc_control->no_bg_gc &&
|
||||||
sec_freed < gc_control->nr_free_secs)
|
sec_freed < gc_control->nr_free_secs)
|
||||||
goto go_gc_more;
|
goto go_gc_more;
|
||||||
@@ -1886,7 +1886,7 @@ retry:
|
|||||||
ret = f2fs_write_checkpoint(sbi, &cpc);
|
ret = f2fs_write_checkpoint(sbi, &cpc);
|
||||||
goto stop;
|
goto stop;
|
||||||
}
|
}
|
||||||
} else if (!has_not_enough_free_secs(sbi, 0, 0)) {
|
} else if (has_enough_free_secs(sbi, 0, 0)) {
|
||||||
goto stop;
|
goto stop;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -412,27 +412,28 @@ void f2fs_balance_fs(struct f2fs_sb_info *sbi, bool need)
|
|||||||
* We should do GC or end up with checkpoint, if there are so many dirty
|
* We should do GC or end up with checkpoint, if there are so many dirty
|
||||||
* dir/node pages without enough free segments.
|
* dir/node pages without enough free segments.
|
||||||
*/
|
*/
|
||||||
if (has_not_enough_free_secs(sbi, 0, 0)) {
|
if (has_enough_free_secs(sbi, 0, 0))
|
||||||
if (test_opt(sbi, GC_MERGE) && sbi->gc_thread &&
|
return;
|
||||||
sbi->gc_thread->f2fs_gc_task) {
|
|
||||||
DEFINE_WAIT(wait);
|
|
||||||
|
|
||||||
prepare_to_wait(&sbi->gc_thread->fggc_wq, &wait,
|
if (test_opt(sbi, GC_MERGE) && sbi->gc_thread &&
|
||||||
TASK_UNINTERRUPTIBLE);
|
sbi->gc_thread->f2fs_gc_task) {
|
||||||
wake_up(&sbi->gc_thread->gc_wait_queue_head);
|
DEFINE_WAIT(wait);
|
||||||
io_schedule();
|
|
||||||
finish_wait(&sbi->gc_thread->fggc_wq, &wait);
|
prepare_to_wait(&sbi->gc_thread->fggc_wq, &wait,
|
||||||
} else {
|
TASK_UNINTERRUPTIBLE);
|
||||||
struct f2fs_gc_control gc_control = {
|
wake_up(&sbi->gc_thread->gc_wait_queue_head);
|
||||||
.victim_segno = NULL_SEGNO,
|
io_schedule();
|
||||||
.init_gc_type = BG_GC,
|
finish_wait(&sbi->gc_thread->fggc_wq, &wait);
|
||||||
.no_bg_gc = true,
|
} else {
|
||||||
.should_migrate_blocks = false,
|
struct f2fs_gc_control gc_control = {
|
||||||
.err_gc_skipped = false,
|
.victim_segno = NULL_SEGNO,
|
||||||
.nr_free_secs = 1 };
|
.init_gc_type = BG_GC,
|
||||||
f2fs_down_write(&sbi->gc_lock);
|
.no_bg_gc = true,
|
||||||
f2fs_gc(sbi, &gc_control);
|
.should_migrate_blocks = false,
|
||||||
}
|
.err_gc_skipped = false,
|
||||||
|
.nr_free_secs = 1 };
|
||||||
|
f2fs_down_write(&sbi->gc_lock);
|
||||||
|
f2fs_gc(sbi, &gc_control);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -643,11 +643,17 @@ static inline bool has_not_enough_free_secs(struct f2fs_sb_info *sbi,
|
|||||||
return !curseg_space;
|
return !curseg_space;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline bool has_enough_free_secs(struct f2fs_sb_info *sbi,
|
||||||
|
int freed, int needed)
|
||||||
|
{
|
||||||
|
return !has_not_enough_free_secs(sbi, freed, needed);
|
||||||
|
}
|
||||||
|
|
||||||
static inline bool f2fs_is_checkpoint_ready(struct f2fs_sb_info *sbi)
|
static inline bool f2fs_is_checkpoint_ready(struct f2fs_sb_info *sbi)
|
||||||
{
|
{
|
||||||
if (likely(!is_sbi_flag_set(sbi, SBI_CP_DISABLED)))
|
if (likely(!is_sbi_flag_set(sbi, SBI_CP_DISABLED)))
|
||||||
return true;
|
return true;
|
||||||
if (likely(!has_not_enough_free_secs(sbi, 0, 0)))
|
if (likely(has_enough_free_secs(sbi, 0, 0)))
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user