Skip to content

Commit 94e7eb4

Browse files
haokexinJaegeuk Kim
authored andcommitted
f2fs: Use wait_event_freezable_timeout() for freezable kthread
A freezable kernel thread can enter frozen state during freezing by either calling try_to_freeze() or using wait_event_freezable() and its variants. So for the following snippet of code in a kernel thread loop: wait_event_interruptible_timeout(); try_to_freeze(); We can change it to a simple wait_event_freezable_timeout() and then eliminate the function calls to try_to_freeze() and freezing(). Signed-off-by: Kevin Hao <haokexin@gmail.com> Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
1 parent 86d7d57 commit 94e7eb4

2 files changed

Lines changed: 5 additions & 8 deletions

File tree

fs/f2fs/gc.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ static int gc_thread_func(void *data)
4646
do {
4747
bool sync_mode, foreground = false;
4848

49-
wait_event_interruptible_timeout(*wq,
50-
kthread_should_stop() || freezing(current) ||
49+
wait_event_freezable_timeout(*wq,
50+
kthread_should_stop() ||
5151
waitqueue_active(fggc_wq) ||
5252
gc_th->gc_wake,
5353
msecs_to_jiffies(wait_ms));
@@ -59,7 +59,7 @@ static int gc_thread_func(void *data)
5959
if (gc_th->gc_wake)
6060
gc_th->gc_wake = false;
6161

62-
if (try_to_freeze() || f2fs_readonly(sbi->sb)) {
62+
if (f2fs_readonly(sbi->sb)) {
6363
stat_other_skip_bggc_count(sbi);
6464
continue;
6565
}

fs/f2fs/segment.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1887,9 +1887,8 @@ static int issue_discard_thread(void *data)
18871887
set_freezable();
18881888

18891889
do {
1890-
wait_event_interruptible_timeout(*q,
1891-
kthread_should_stop() || freezing(current) ||
1892-
dcc->discard_wake,
1890+
wait_event_freezable_timeout(*q,
1891+
kthread_should_stop() || dcc->discard_wake,
18931892
msecs_to_jiffies(wait_ms));
18941893

18951894
if (sbi->gc_mode == GC_URGENT_HIGH ||
@@ -1907,8 +1906,6 @@ static int issue_discard_thread(void *data)
19071906
if (atomic_read(&dcc->queued_discard))
19081907
__wait_all_discard_cmd(sbi, NULL);
19091908

1910-
if (try_to_freeze())
1911-
continue;
19121909
if (f2fs_readonly(sbi->sb))
19131910
continue;
19141911
if (kthread_should_stop())

0 commit comments

Comments
 (0)