From: Chao Yu Date: Fri, 24 May 2019 08:26:40 +0000 (+0800) Subject: f2fs-tools: update checkpoint data atomically X-Git-Tag: v1.13.0~35 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d1094d9cffde308ef97b15bb9e7e0b17dd5adb99;p=platform%2Fupstream%2Ff2fs-tools.git 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 Signed-off-by: Jaegeuk Kim --- diff --git a/fsck/fsck.c b/fsck/fsck.c index e2104dd..d7b9ab7 100644 --- a/fsck/fsck.c +++ b/fsck/fsck.c @@ -2113,12 +2113,18 @@ 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); } int check_curseg_offset(struct f2fs_sb_info *sbi, int type) diff --git a/fsck/mount.c b/fsck/mount.c index dae11e1..887c9fc 100644 --- a/fsck/mount.c +++ b/fsck/mount.c @@ -2453,6 +2453,9 @@ 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 build_nat_area_bitmap(struct f2fs_sb_info *sbi)