All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chao Yu <yuchao0@huawei.com>
To: linux-f2fs-devel@lists.sourceforge.net
Cc: jaegeuk@kernel.org
Subject: [PATCH] f2fs-tools: update checkpoint data atomically
Date: Fri, 24 May 2019 16:26:40 +0800	[thread overview]
Message-ID: <20190524082640.109172-1-yuchao0@huawei.com> (raw)

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

                 reply	other threads:[~2019-05-24  8:27 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190524082640.109172-1-yuchao0@huawei.com \
    --to=yuchao0@huawei.com \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.