Commit 1d7be270 authored by Jaegeuk Kim's avatar Jaegeuk Kim

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: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent b7b7c4cf
...@@ -32,13 +32,14 @@ static int gc_thread_func(void *data) ...@@ -32,13 +32,14 @@ static int gc_thread_func(void *data)
wait_ms = gc_th->min_sleep_time; wait_ms = gc_th->min_sleep_time;
set_freezable();
do { do {
if (try_to_freeze())
continue;
else
wait_event_interruptible_timeout(*wq, wait_event_interruptible_timeout(*wq,
kthread_should_stop(), kthread_should_stop() || freezing(current),
msecs_to_jiffies(wait_ms)); msecs_to_jiffies(wait_ms));
if (try_to_freeze())
continue;
if (kthread_should_stop()) if (kthread_should_stop())
break; break;
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include <linux/kthread.h> #include <linux/kthread.h>
#include <linux/swap.h> #include <linux/swap.h>
#include <linux/timer.h> #include <linux/timer.h>
#include <linux/freezer.h>
#include "f2fs.h" #include "f2fs.h"
#include "segment.h" #include "segment.h"
...@@ -1059,7 +1060,15 @@ static int issue_discard_thread(void *data) ...@@ -1059,7 +1060,15 @@ static int issue_discard_thread(void *data)
struct f2fs_sb_info *sbi = data; struct f2fs_sb_info *sbi = data;
struct discard_cmd_control *dcc = SM_I(sbi)->dcc_info; struct discard_cmd_control *dcc = SM_I(sbi)->dcc_info;
wait_queue_head_t *q = &dcc->discard_wait_queue; wait_queue_head_t *q = &dcc->discard_wait_queue;
repeat:
set_freezable();
do {
wait_event_interruptible(*q, kthread_should_stop() ||
freezing(current) ||
atomic_read(&dcc->discard_cmd_cnt));
if (try_to_freeze())
continue;
if (kthread_should_stop()) if (kthread_should_stop())
return 0; return 0;
...@@ -1067,10 +1076,8 @@ static int issue_discard_thread(void *data) ...@@ -1067,10 +1076,8 @@ static int issue_discard_thread(void *data)
__wait_discard_cmd(sbi, true); __wait_discard_cmd(sbi, true);
congestion_wait(BLK_RW_SYNC, HZ/50); congestion_wait(BLK_RW_SYNC, HZ/50);
} while (!kthread_should_stop());
wait_event_interruptible(*q, kthread_should_stop() || return 0;
atomic_read(&dcc->discard_cmd_cnt));
goto repeat;
} }
#ifdef CONFIG_BLK_DEV_ZONED #ifdef CONFIG_BLK_DEV_ZONED
......
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