OSDN Git Service

f2fs: fix to avoid data corruption by forbidding SSR overwrite
authorChao Yu <yuchao0@huawei.com>
Fri, 16 Aug 2019 03:03:34 +0000 (11:03 +0800)
committer0ranko0P <ranko0p@outlook.com>
Tue, 24 Dec 2019 20:42:24 +0000 (04:42 +0800)
commitf9c898c816676178673783dc0ed74d42b6c6d4bf
tree2fd785db577062e573447b488dd64adc17b24d76
parent71e7fcf6ce9bc5d24a3222a6d0c2cba6d810113a
f2fs: fix to avoid data corruption by forbidding SSR overwrite

There is one case can cause data corruption.

- write 4k to fileA
- fsync fileA, 4k data is writebacked to lbaA
- write 4k to fileA
- kworker flushs 4k to lbaB; dnode contain lbaB didn't be persisted yet
- write 4k to fileB
- kworker flush 4k to lbaA due to SSR
- SPOR -> dnode with lbaA will be recovered, however lbaA contains fileB's
data

One solution is tracking all fsynced file's block history, and disallow
SSR overwrite on newly invalidated block on that file.

However, during recovery, no matter the dnode is flushed or fsynced, all
previous dnodes until last fsynced one in node chain can be recovered,
that means we need to record all block change in flushed dnode, which
will cause heavy cost, so let's just use simple fix by forbidding SSR
overwrite directly.

Fixes: 5b6c6be2d878 ("f2fs: use SSR for warm node as well")
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/segment.c