f2fs: fix to avoid race in between aio and gc
authorChao Yu <yuchao0@huawei.com>
Wed, 23 Aug 2017 10:23:24 +0000 (18:23 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Tue, 29 Aug 2017 17:05:42 +0000 (10:05 -0700)
We won't wait DIO synchronously when doing AIO, so there will be potential
IO reorder in between AIO and GC, which will cause data corruption.

This patch adds inode_dio_wait to serialize aio and data GC to avoid this
issue.

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

index 57bea2182f3035a37bd49ed8e6e3fcde60c60ae8..cd147e7c71e8fcd642da013e4fdde24413b55fca 100644 (file)
@@ -875,6 +875,9 @@ next_step:
                                        continue;
                                }
                                locked = true;
+
+                               /* wait for all inflight aio data */
+                               inode_dio_wait(inode);
                        }
 
                        start_bidx = start_bidx_of_node(nofs, inode)