f2fs: clear discard_wake earlier
authorSheng Yong <shengyong1@huawei.com>
Tue, 8 May 2018 09:51:34 +0000 (17:51 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Mon, 9 Jul 2018 00:40:58 +0000 (17:40 -0700)
If SBI_NEED_FSCK is set, discard_wake will never be cleared. As a
result, the condition of wait_event_interruptible_timeout() is always
true, which gets discard thread run too frequently.

Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/segment.c

index d61f5ca661ce5fcce6d1276181fc825620a6c074..bfbf66675ce2fbab6a71fd4714f46cea887706d5 100644 (file)
@@ -1402,6 +1402,10 @@ static int issue_discard_thread(void *data)
                                kthread_should_stop() || freezing(current) ||
                                dcc->discard_wake,
                                msecs_to_jiffies(wait_ms));
+
+               if (dcc->discard_wake)
+                       dcc->discard_wake = 0;
+
                if (try_to_freeze())
                        continue;
                if (f2fs_readonly(sbi->sb))
@@ -1413,9 +1417,6 @@ static int issue_discard_thread(void *data)
                        continue;
                }
 
-               if (dcc->discard_wake)
-                       dcc->discard_wake = 0;
-
                if (sbi->gc_mode == GC_URGENT)
                        __init_discard_policy(sbi, &dpolicy, DPOLICY_FORCE, 1);