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>
        do {
                bool sync_mode, foreground = false;
 
-               wait_event_interruptible_timeout(*wq,
-                               kthread_should_stop() || freezing(current) ||
+               wait_event_freezable_timeout(*wq,
+                               kthread_should_stop() ||
                                waitqueue_active(fggc_wq) ||
                                gc_th->gc_wake,
                                msecs_to_jiffies(wait_ms));
                if (gc_th->gc_wake)
                        gc_th->gc_wake = false;
 
-               if (try_to_freeze() || f2fs_readonly(sbi->sb)) {
+               if (f2fs_readonly(sbi->sb)) {
                        stat_other_skip_bggc_count(sbi);
                        continue;
                }
 
        set_freezable();
 
        do {
-               wait_event_interruptible_timeout(*q,
-                               kthread_should_stop() || freezing(current) ||
-                               dcc->discard_wake,
+               wait_event_freezable_timeout(*q,
+                               kthread_should_stop() || dcc->discard_wake,
                                msecs_to_jiffies(wait_ms));
 
                if (sbi->gc_mode == GC_URGENT_HIGH ||
                if (atomic_read(&dcc->queued_discard))
                        __wait_all_discard_cmd(sbi, NULL);
 
-               if (try_to_freeze())
-                       continue;
                if (f2fs_readonly(sbi->sb))
                        continue;
                if (kthread_should_stop())