f2fs: fix out-of-order execution in f2fs_issue_flush
authorChao Yu <yuchao0@huawei.com>
Mon, 21 Aug 2017 14:53:45 +0000 (22:53 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Tue, 29 Aug 2017 17:02:55 +0000 (10:02 -0700)
In f2fs_issue_flush, due to out-of-order execution of CPU, wake_up can
be called before we insert issue_list, result in long latency of
wait_for_completion. Fix this by adding smp_mb() to force the order of
related codes.

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

index e3922f902c8c4128a6877a5b25fb616bb4cad04d..be1c49b9402bbdd4ea6de62176e45ef80ea804b6 100644 (file)
@@ -549,7 +549,10 @@ int f2fs_issue_flush(struct f2fs_sb_info *sbi)
        atomic_inc(&fcc->issing_flush);
        llist_add(&cmd.llnode, &fcc->issue_list);
 
-       if (!fcc->dispatch_list)
+       /* update issue_list before we wake up issue_flush thread */
+       smp_mb();
+
+       if (waitqueue_active(&fcc->flush_wait_queue))
                wake_up(&fcc->flush_wait_queue);
 
        if (fcc->f2fs_issue_flush) {