All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gu Zheng <guz.fnst@cn.fujitsu.com>
To: jaegeuk.kim@samsung.com
Cc: linux-f2fs-devel@lists.sourceforge.net
Subject: [f2fs-dev] [PATCH RESEND] f2fs: Modify do_garbage_collect() to collect all the segs in once
Date: Fri, 12 Jul 2013 13:51:38 +0800	[thread overview]
Message-ID: <51DF996A.4010803@cn.fujitsu.com> (raw)

Current do_garbage_collect() collect per segment per time. If there are more
than one segments in section, we need to call do_garbage_collect() many times to
collect all the segments(current is a for loop). We can move the loop into the
do_garbage_collect(), so that we can collect all the segs of section in one time.

Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com>
---
 fs/f2fs/gc.c |   59 ++++++++++++++++++++++++++++++++-------------------------
 1 files changed, 33 insertions(+), 26 deletions(-)

diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
index 35f9b1a..9589ffe 100644
--- a/fs/f2fs/gc.c
+++ b/fs/f2fs/gc.c
@@ -634,42 +634,50 @@ static int __get_victim(struct f2fs_sb_info *sbi, unsigned
int *victim,
 	return ret;
 }

-static void do_garbage_collect(struct f2fs_sb_info *sbi, unsigned int segno,
-				struct list_head *ilist, int gc_type)
+static void do_garbage_collect(struct f2fs_sb_info *sbi,
+		unsigned int start_segno, struct list_head *ilist, int gc_type)
 {
-	struct page *sum_page;
-	struct f2fs_summary_block *sum;
-	struct blk_plug plug;
+	unsigned int segno = start_segno;

-	/* read segment summary of victim */
-	sum_page = get_sum_page(sbi, segno);
-	if (IS_ERR(sum_page))
-		return;
+	for (; sbi->segs_per_sec--; segno++) {
+		struct page *sum_page;
+		struct f2fs_summary_block *sum;
+		struct blk_plug plug;

-	blk_start_plug(&plug);
+		/* read segment summary of victim */
+		sum_page = get_sum_page(sbi, segno);
+		if (IS_ERR(sum_page))
+			continue;

-	sum = page_address(sum_page);
+		blk_start_plug(&plug);

-	switch (GET_SUM_TYPE((&sum->footer))) {
-	case SUM_TYPE_NODE:
-		gc_node_segment(sbi, sum->entries, segno, gc_type);
-		break;
-	case SUM_TYPE_DATA:
-		gc_data_segment(sbi, sum->entries, ilist, segno, gc_type);
-		break;
-	}
-	blk_finish_plug(&plug);
+		sum = page_address(sum_page);

-	stat_inc_seg_count(sbi, GET_SUM_TYPE((&sum->footer)));
-	stat_inc_call_count(sbi->stat_info);
+		switch (GET_SUM_TYPE((&sum->footer))) {
+		case SUM_TYPE_NODE:
+			gc_node_segment(sbi, sum->entries,
+				segno, gc_type);
+			break;
+		case SUM_TYPE_DATA:
+			gc_data_segment(sbi, sum->entries, ilist,
+				segno, gc_type);
+			break;
+		default:
+			BUG();
+		}
+		blk_finish_plug(&plug);
+
+		stat_inc_seg_count(sbi, GET_SUM_TYPE((&sum->footer)));
+		stat_inc_call_count(sbi->stat_info);

-	f2fs_put_page(sum_page, 1);
+		f2fs_put_page(sum_page, 1);
+	}
 }

 int f2fs_gc(struct f2fs_sb_info *sbi)
 {
 	struct list_head ilist;
-	unsigned int segno, i;
+	unsigned int segno;
 	int gc_type = BG_GC;
 	int nfree = 0;
 	int ret = -1;
@@ -688,8 +696,7 @@ gc_more:
 		goto stop;
 	ret = 0;

-	for (i = 0; i < sbi->segs_per_sec; i++)
-		do_garbage_collect(sbi, segno + i, &ilist, gc_type);
+	do_garbage_collect(sbi, segno, &ilist, gc_type);

 	if (gc_type == FG_GC) {
 		sbi->cur_victim_sec = NULL_SEGNO;
-- 
1.7.7



------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk

             reply	other threads:[~2013-07-12  5:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-12  5:51 Gu Zheng [this message]
2013-07-14 23:56 ` [f2fs-dev] [PATCH RESEND] f2fs: Modify do_garbage_collect() to collect all the segs in once Jaegeuk Kim
2013-07-15  1:47   ` Gu Zheng

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=51DF996A.4010803@cn.fujitsu.com \
    --to=guz.fnst@cn.fujitsu.com \
    --cc=jaegeuk.kim@samsung.com \
    --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.