All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] f2fs-tools: update checkpoint data atomically
@ 2019-05-24  8:26 Chao Yu
  0 siblings, 0 replies; only message in thread
From: Chao Yu @ 2019-05-24  8:26 UTC (permalink / raw)
  To: linux-f2fs-devel; +Cc: jaegeuk

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 <yuchao0@huawei.com>
---
 fsck/fsck.c  | 16 ++++++++++------
 fsck/mount.c |  7 ++++---
 2 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/fsck/fsck.c b/fsck/fsck.c
index 6aed51d..3c0332c 100644
--- a/fsck/fsck.c
+++ b/fsck/fsck.c
@@ -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);
 	}
 }
 
diff --git a/fsck/mount.c b/fsck/mount.c
index bbb1af7..a627f1d 100644
--- a/fsck/mount.c
+++ b/fsck/mount.c
@@ -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);
 	}
 }
 
-- 
2.18.0.rc1

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-05-24  8:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-24  8:26 [PATCH] f2fs-tools: update checkpoint data atomically Chao Yu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.