f2fs: don't give partially written atomic data from process crash
authorJaegeuk Kim <jaegeuk@kernel.org>
Tue, 25 Jul 2017 02:46:29 +0000 (19:46 -0700)
committerJaegeuk Kim <jaegeuk@kernel.org>
Sat, 29 Jul 2017 00:49:01 +0000 (17:49 -0700)
commit7a10f0177e117e9935ee9e5c595fcf3c57215de5
tree5b8f062a85ac3d175d0686323fc4c051ce484a17
parent640cc18982b1c2049ac3a7223444248aea7d51b4
f2fs: don't give partially written atomic data from process crash

This patch resolves the below scenario.

== Process 1 ==     == Process 2 ==
open(w)             open(rw)
begin
write(new_#1)
process_crash
  f_op->flush
  locks_remove_posix
  f_op>release
                    read (new_#1)

In order to avoid corrupted database caused by new_#1, we must do roll-back
at process_crash time. In order to check that, this patch keeps task which
triggers transaction begin, and does roll-back in f_op->flush before removing
file locks.

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