Skip to content

Commit 1d7be27

Browse files
author
Jaegeuk Kim
committed
f2fs: try to freeze in gc and discard threads
This allows to freeze gc and discard threads. Cc: stable@vger.kernel.org Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
1 parent b7b7c4c commit 1d7be27

2 files changed

Lines changed: 21 additions & 13 deletions

File tree

‎fs/f2fs/gc.c‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,14 @@ static int gc_thread_func(void *data)
3232

3333
wait_ms = gc_th->min_sleep_time;
3434

35+
set_freezable();
3536
do {
37+
wait_event_interruptible_timeout(*wq,
38+
kthread_should_stop() || freezing(current),
39+
msecs_to_jiffies(wait_ms));
40+
3641
if (try_to_freeze())
3742
continue;
38-
else
39-
wait_event_interruptible_timeout(*wq,
40-
kthread_should_stop(),
41-
msecs_to_jiffies(wait_ms));
4243
if (kthread_should_stop())
4344
break;
4445

‎fs/f2fs/segment.c‎

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <linux/kthread.h>
1717
#include <linux/swap.h>
1818
#include <linux/timer.h>
19+
#include <linux/freezer.h>
1920

2021
#include "f2fs.h"
2122
#include "segment.h"
@@ -1059,18 +1060,24 @@ static int issue_discard_thread(void *data)
10591060
struct f2fs_sb_info *sbi = data;
10601061
struct discard_cmd_control *dcc = SM_I(sbi)->dcc_info;
10611062
wait_queue_head_t *q = &dcc->discard_wait_queue;
1062-
repeat:
1063-
if (kthread_should_stop())
1064-
return 0;
10651063

1066-
__issue_discard_cmd(sbi, true);
1067-
__wait_discard_cmd(sbi, true);
1064+
set_freezable();
10681065

1069-
congestion_wait(BLK_RW_SYNC, HZ/50);
1066+
do {
1067+
wait_event_interruptible(*q, kthread_should_stop() ||
1068+
freezing(current) ||
1069+
atomic_read(&dcc->discard_cmd_cnt));
1070+
if (try_to_freeze())
1071+
continue;
1072+
if (kthread_should_stop())
1073+
return 0;
10701074

1071-
wait_event_interruptible(*q, kthread_should_stop() ||
1072-
atomic_read(&dcc->discard_cmd_cnt));
1073-
goto repeat;
1075+
__issue_discard_cmd(sbi, true);
1076+
__wait_discard_cmd(sbi, true);
1077+
1078+
congestion_wait(BLK_RW_SYNC, HZ/50);
1079+
} while (!kthread_should_stop());
1080+
return 0;
10741081
}
10751082

10761083
#ifdef CONFIG_BLK_DEV_ZONED

0 commit comments

Comments
 (0)