f2fs: fix data corruption issue with hardware encryption
authorSahitya Tummala <stummala@codeaurora.org>
Wed, 10 Oct 2018 05:26:22 +0000 (10:56 +0530)
committerJaegeuk Kim <jaegeuk@kernel.org>
Fri, 26 Oct 2018 18:27:04 +0000 (11:27 -0700)
commitc315c32ca5a52d1988c8cc22b84fb985ba1dcf76
tree391ab931d0d126c113a60b9c6acebbd96ee04996
parent3ea7192afe097fe2c03878ad3f80f44859394d1f
f2fs: fix data corruption issue with hardware encryption

Direct IO can be used in case of hardware encryption. The following
scenario results into data corruption issue in this path -

Thread A -                          Thread B-
-> write file#1 in direct IO
                                    -> GC gets kicked in
                                    -> GC submitted bio on meta mapping
       for file#1, but pending completion
-> write file#1 again with new data
   in direct IO
                                    -> GC bio gets completed now
                                    -> GC writes old data to the new
                                       location and thus file#1 is
       corrupted.

Fix this by submitting and waiting for pending io on meta mapping
for direct IO case in f2fs_map_blocks().

Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/data.c
fs/f2fs/f2fs.h
fs/f2fs/segment.c