f2fs-tools: update checkpoint data atomically
PATCH 1/1 f2fs-tools: update checkpoint data atomically
This patch keeps line with f2fs kernel module for checkpoint update:
1. writeback all blocks inside checkpoint except last cp_park block;
2. fsync;
3. write last cp_park block;
4. fsync;
Signed-off-by Chao Yu <[email protected]>
--- fsck/fsck.c | 16 ++++++++++------ fsck/mount.c | 7 ++++--- 2 files changed, 14 insertions(+), 9 deletions(-)
fsck/fsck.c +10 -6
@@ -2113,24 +2113,28 @@ static void fix_checkpoint(struct f2fs_sb_info *sbi)ASSERT (ret >=0 ); } - ret =dev_write_block (cp, cp_blk_no++); -ASSERT (ret >=0 ); -/* Write nat bits */ if (flags &CP_NAT_BITS_FLAG )write_nat_bits (sbi, sb, cp, sbi->cur_cp); + + ret =f2fs_fsync_device (); +ASSERT (ret >=0 ); + + ret =dev_write_block (cp, cp_blk_no++); +ASSERT (ret >=0 ); + + ret =f2fs_fsync_device (); +ASSERT (ret >=0 ); }static void fix_checkpoints (struct f2fs_sb_info *sbi) { -int i, ret; +int i;for (i =0 ; i <2 ; i++) {/* write checkpoint out of place first */ sbi->cur_cp = sbi->cur_cp %2 +1 ;fix_checkpoint (sbi); - ret =f2fs_fsync_device (); -ASSERT (ret >=0 ); } }
fsck/mount.c +4 -3
@@ -2450,18 +2450,19 @@ void write_checkpoint(struct f2fs_sb_info *sbi)/* write the last cp */ ret =dev_write_block (cp, cp_blk_no++);ASSERT (ret >=0 ); + + ret =f2fs_fsync_device (); +ASSERT (ret >=0 ); }void write_checkpoints (struct f2fs_sb_info *sbi) { -int i, ret; +int i;for (i =0 ; i <2 ; i++) {/* write checkpoint out of place first */ sbi->cur_cp = sbi->cur_cp %2 +1 ;write_checkpoint (sbi); - ret =f2fs_fsync_device (); -ASSERT (ret >=0 ); } }
Signature · 1 line
2.18.0.rc1