linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] fsck.f2fs: No need to write a new cp if nothing to flush
@ 2016-11-04  9:34 Yunlei He
  2016-11-04  9:34 ` [PATCH 2/2] fsck.f2fs: Add a judgment after calloc Yunlei He
  0 siblings, 1 reply; 3+ messages in thread
From: Yunlei He @ 2016-11-04  9:34 UTC (permalink / raw)
  To: linux-f2fs-devel, jaegeuk, yuchao0; +Cc: heyunlei

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-11-04 23:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-04  9:34 [PATCH 1/2] fsck.f2fs: No need to write a new cp if nothing to flush Yunlei He
2016-11-04  9:34 ` [PATCH 2/2] fsck.f2fs: Add a judgment after calloc Yunlei He
2016-11-04 23:07   ` Jaegeuk Kim

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).