fsck.f2fs: write checkpoint with OPU mode
authorChao Yu <yuchao0@huawei.com>
Wed, 17 Jul 2019 01:28:51 +0000 (09:28 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Tue, 20 Aug 2019 18:23:58 +0000 (11:23 -0700)
commit81bad9d11ea5f728cfc815a3060583171c2b4d7d
tree3167d8ff795677afaac79691a8832dd516be04a2
parent7c8df9e026483da8e783e1d5bd1988ab9109ba10
fsck.f2fs: write checkpoint with OPU mode

This original patch was from Weichao Guo.

We may encounter both checkpoints invalid in such a case:
1. kernel writes CP A;
2. power-cut when kernel writes CP B, then CP B is corrupted;
3. fsck: load CP A, fix meta/data;
4. power-cut when fsck writes CP A in-place, then CP A is corrupted too;

To avoid both checkpoints being invalid, this patch changes to duplicate
valid checkpoint to mirror position first, and then, write fixed checkpoint
to CP #0 position.

This can make sure that, while fsck repairing, even there is sudden
power-cut, last valid checkpoint can be kept in CP #1 position.

Signed-off-by: Weichao Guo <guoweichao@huawei.com>
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fsck/f2fs.h
fsck/fsck.c
fsck/fsck.h
fsck/mount.c