Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+21 -13
+5 -4
fs/f2fs/gc.c
··· 32 32 33 33 wait_ms = gc_th->min_sleep_time; 34 34 35 + set_freezable(); 35 36 do { 37 + wait_event_interruptible_timeout(*wq, 38 + kthread_should_stop() || freezing(current), 39 + msecs_to_jiffies(wait_ms)); 40 + 36 41 if (try_to_freeze()) 37 42 continue; 38 - else 39 - wait_event_interruptible_timeout(*wq, 40 - kthread_should_stop(), 41 - msecs_to_jiffies(wait_ms)); 42 43 if (kthread_should_stop()) 43 44 break; 44 45
+16 -9
fs/f2fs/segment.c
··· 16 16 #include <linux/kthread.h> 17 17 #include <linux/swap.h> 18 18 #include <linux/timer.h> 19 + #include <linux/freezer.h> 19 20 20 21 #include "f2fs.h" 21 22 #include "segment.h" ··· 1060 1059 struct f2fs_sb_info *sbi = data; 1061 1060 struct discard_cmd_control *dcc = SM_I(sbi)->dcc_info; 1062 1061 wait_queue_head_t *q = &dcc->discard_wait_queue; 1063 - repeat: 1064 - if (kthread_should_stop()) 1065 - return 0; 1066 1062 1067 - __issue_discard_cmd(sbi, true); 1068 - __wait_discard_cmd(sbi, true); 1063 + set_freezable(); 1069 1064 1070 - congestion_wait(BLK_RW_SYNC, HZ/50); 1065 + do { 1066 + wait_event_interruptible(*q, kthread_should_stop() || 1067 + freezing(current) || 1068 + atomic_read(&dcc->discard_cmd_cnt)); 1069 + if (try_to_freeze()) 1070 + continue; 1071 + if (kthread_should_stop()) 1072 + return 0; 1071 1073 1072 - wait_event_interruptible(*q, kthread_should_stop() || 1073 - atomic_read(&dcc->discard_cmd_cnt)); 1074 - goto repeat; 1074 + __issue_discard_cmd(sbi, true); 1075 + __wait_discard_cmd(sbi, true); 1076 + 1077 + congestion_wait(BLK_RW_SYNC, HZ/50); 1078 + } while (!kthread_should_stop()); 1079 + return 0; 1075 1080 } 1076 1081 1077 1082 #ifdef CONFIG_BLK_DEV_ZONED