linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
From: Yunlei He <heyunlei@huawei.com>
To: linux-f2fs-devel@lists.sourceforge.net, jaegeuk@kernel.org,
	yuchao0@huawei.com
Cc: heyunlei@huwei.com
Subject: [PATCH 1/2] fsck.f2fs: No need to write a new cp if nothing to flush
Date: Fri, 4 Nov 2016 17:34:10 +0800	[thread overview]
Message-ID: <20161104093411.14921-1-heyunlei@huawei.com> (raw)

This patch avoid to write a new cp if no journal info

Signed-off-by: Yunlei He <heyunlei@huawei.com>
---
 fsck/mount.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/fsck/mount.c b/fsck/mount.c
index dd7a081..f2055e4 100644
--- a/fsck/mount.c
+++ b/fsck/mount.c
@@ -1447,7 +1447,7 @@ void rewrite_sit_area_bitmap(struct f2fs_sb_info *sbi)
 	}
 }
 
-static void flush_sit_journal_entries(struct f2fs_sb_info *sbi)
+static int flush_sit_journal_entries(struct f2fs_sb_info *sbi)
 {
 	struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_COLD_DATA);
 	struct f2fs_journal *journal = &curseg->sum_blk->journal;
@@ -1474,10 +1474,12 @@ static void flush_sit_journal_entries(struct f2fs_sb_info *sbi)
 		rewrite_current_sit_page(sbi, segno, sit_blk);
 		free(sit_blk);
 	}
+
 	journal->n_sits = 0;
+	return i;
 }
 
-static void flush_nat_journal_entries(struct f2fs_sb_info *sbi)
+static int flush_nat_journal_entries(struct f2fs_sb_info *sbi)
 {
 	struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_HOT_DATA);
 	struct f2fs_journal *journal = &curseg->sum_blk->journal;
@@ -1491,7 +1493,7 @@ static void flush_nat_journal_entries(struct f2fs_sb_info *sbi)
 next:
 	if (i >= nats_in_cursum(journal)) {
 		journal->n_nats = 0;
-		return;
+		return i;
 	}
 
 	nid = le32_to_cpu(nid_in_journal(journal, i));
@@ -1515,9 +1517,11 @@ next:
 
 void flush_journal_entries(struct f2fs_sb_info *sbi)
 {
-	flush_nat_journal_entries(sbi);
-	flush_sit_journal_entries(sbi);
-	write_checkpoint(sbi);
+	int n_nats = flush_nat_journal_entries(sbi);
+	int n_sits = flush_sit_journal_entries(sbi);
+
+	if (n_nats || n_sits)
+		write_checkpoint(sbi);
 }
 
 void flush_sit_entries(struct f2fs_sb_info *sbi)
-- 
2.10.1


------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi

             reply	other threads:[~2016-11-04  9:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-04  9:34 Yunlei He [this message]
2016-11-04  9:34 ` [PATCH 2/2] fsck.f2fs: Add a judgment after calloc Yunlei He
2016-11-04 23:07   ` Jaegeuk Kim

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=20161104093411.14921-1-heyunlei@huawei.com \
    --to=heyunlei@huawei.com \
    --cc=heyunlei@huwei.com \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=yuchao0@huawei.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).