Skip to contentSkip to conversation

f2fs: move out f2fs_balance_fs from gc_thread_func

PATCH In review Namjae Jeon 2 participants 3 messages Feb 2, 2013 – Feb 4, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 2/6 f2fs: move out f2fs_balance_fs from gc_thread_func

From: Namjae Jeon <[email protected]>

When GC thread is running continously there is no need to call f2fs_balance_fs unconditinally for garbage collection, instead the garbage collection will be taken via. calling f2fs_gc in the thread. So, we can move out the balance out of thread loop and make it run initially when the thread is started.

---
 fs/f2fs/gc.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/f2fs/gc.c +2 -1
index 375e69e..66ac6ad 100644
@@ -34,6 +34,8 @@ static int gc_thread_func(void *data)
 
 	wait_ms = GC_THREAD_MIN_SLEEP_TIME;
 
+	f2fs_balance_fs(sbi);
+
 	do {
 		if (try_to_freeze())
 			continue;
@@ -49,7 +51,6 @@ static int gc_thread_func(void *data)
 			continue;
 		}
 
-		f2fs_balance_fs(sbi);
 
 		if (!test_opt(sbi, BG_GC))
 			continue;
Signature · 1 line
1.7.9.5
#1 lore raw

As you know, f2fs_balance_fs conducts gc if f2fs has not enough free sections. But, the purpose of background gc is to conduct gc during idle time without checking free sections so that f2fs can solve defragment condition.

Could you review this?

--> 8 --

Quoted 1 line

From fbda3262dac81c4f0d7ae8b9b757c820da593120 Mon Sep 17 00:00:00 2001

From: Changman Lee <[email protected]>
Date: Mon, 4 Feb 2013 10:05:09 +0900
Subject: [PATCH] f2fs: remove unnecessary gc option check and balance_fs

1. If f2fs is mounted with background_gc_off option, checking BG_GC is not redundant.
2. f2fs_balance_fs is checked in f2fs_gc, so this is also redundant.

---
 fs/f2fs/gc.c |    7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
fs/f2fs/gc.c +2 -5
index 8fe43f3..e5c47f6 100644
@@ -49,11 +49,6 @@ static int gc_thread_func(void *data)
 			continue;
 		}
 
-		f2fs_balance_fs(sbi);
-
-		if (!test_opt(sbi, BG_GC))
-			continue;
-
 		/*
 		 * [GC triggering condition]
 		 * 0. GC is not conducted currently.
@@ -96,6 +91,8 @@ int start_gc_thread(struct f2fs_sb_info *sbi)
 {
 	struct f2fs_gc_kthread *gc_th;
 
+	if (!test_opt(sbi, BG_GC))
+		return 0;
 	gc_th = kmalloc(sizeof(struct f2fs_gc_kthread), GFP_KERNEL);
 	if (!gc_th)
 		return -ENOMEM;
Signature · 1 line
1.7.10.4
#2 lore raw

2013/2/4, Changman Lee <[email protected]>:

Quoted 6 lines

As you know, f2fs_balance_fs conducts gc if f2fs has not enough free sections. But, the purpose of background gc is to conduct gc during idle time without checking free sections so that f2fs can solve defragment condition.

Could you review this?

Yes, right. make sense.
This patch also looks good to me.
Thanks a lot !

Quoted 50 lines

--> 8 --

From fbda3262dac81c4f0d7ae8b9b757c820da593120 Mon Sep 17 00:00:00 2001
From: Changman Lee <[email protected]>
Date: Mon, 4 Feb 2013 10:05:09 +0900
Subject: [PATCH] f2fs: remove unnecessary gc option check and balance_fs

1. If f2fs is mounted with background_gc_off option, checking BG_GC is not redundant.
2. f2fs_balance_fs is checked in f2fs_gc, so this is also redundant.

---
 fs/f2fs/gc.c |    7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
fs/f2fs/gc.c +2 -6
index 8fe43f3..e5c47f6 100644
@@ -49,11 +49,6 @@ static int gc_thread_func(void *data)
 			continue;
 		}
 
-		f2fs_balance_fs(sbi);
-
-		if (!test_opt(sbi, BG_GC))
-			continue;
-
 		/*
 		 * [GC triggering condition]
 		 * 0. GC is not conducted currently.
@@ -96,6 +91,8 @@ int start_gc_thread(struct f2fs_sb_info *sbi)
 {
 	struct f2fs_gc_kthread *gc_th;
 
+	if (!test_opt(sbi, BG_GC))
+		return 0;
 	gc_th = kmalloc(sizeof(struct f2fs_gc_kthread), GFP_KERNEL);
 	if (!gc_th)
 		return -ENOMEM;
--

1.7.10.4