aboutsummaryrefslogtreecommitdiffstats
path: root/fs/f2fs/gc.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/f2fs/gc.c')
-rw-r--r--fs/f2fs/gc.c38
1 files changed, 9 insertions, 29 deletions
diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
index eec0933a4819..76adbc3641f1 100644
--- a/fs/f2fs/gc.c
+++ b/fs/f2fs/gc.c
@@ -24,8 +24,6 @@
24#include "gc.h" 24#include "gc.h"
25#include <trace/events/f2fs.h> 25#include <trace/events/f2fs.h>
26 26
27static struct kmem_cache *winode_slab;
28
29static int gc_thread_func(void *data) 27static int gc_thread_func(void *data)
30{ 28{
31 struct f2fs_sb_info *sbi = data; 29 struct f2fs_sb_info *sbi = data;
@@ -46,7 +44,7 @@ static int gc_thread_func(void *data)
46 break; 44 break;
47 45
48 if (sbi->sb->s_writers.frozen >= SB_FREEZE_WRITE) { 46 if (sbi->sb->s_writers.frozen >= SB_FREEZE_WRITE) {
49 wait_ms = increase_sleep_time(gc_th, wait_ms); 47 increase_sleep_time(gc_th, &wait_ms);
50 continue; 48 continue;
51 } 49 }
52 50
@@ -67,15 +65,15 @@ static int gc_thread_func(void *data)
67 continue; 65 continue;
68 66
69 if (!is_idle(sbi)) { 67 if (!is_idle(sbi)) {
70 wait_ms = increase_sleep_time(gc_th, wait_ms); 68 increase_sleep_time(gc_th, &wait_ms);
71 mutex_unlock(&sbi->gc_mutex); 69 mutex_unlock(&sbi->gc_mutex);
72 continue; 70 continue;
73 } 71 }
74 72
75 if (has_enough_invalid_blocks(sbi)) 73 if (has_enough_invalid_blocks(sbi))
76 wait_ms = decrease_sleep_time(gc_th, wait_ms); 74 decrease_sleep_time(gc_th, &wait_ms);
77 else 75 else
78 wait_ms = increase_sleep_time(gc_th, wait_ms); 76 increase_sleep_time(gc_th, &wait_ms);
79 77
80 stat_inc_bggc_count(sbi); 78 stat_inc_bggc_count(sbi);
81 79
@@ -356,13 +354,10 @@ static void add_gc_inode(struct gc_inode_list *gc_list, struct inode *inode)
356 iput(inode); 354 iput(inode);
357 return; 355 return;
358 } 356 }
359 new_ie = f2fs_kmem_cache_alloc(winode_slab, GFP_NOFS); 357 new_ie = f2fs_kmem_cache_alloc(inode_entry_slab, GFP_NOFS);
360 new_ie->inode = inode; 358 new_ie->inode = inode;
361retry: 359
362 if (radix_tree_insert(&gc_list->iroot, inode->i_ino, new_ie)) { 360 f2fs_radix_tree_insert(&gc_list->iroot, inode->i_ino, new_ie);
363 cond_resched();
364 goto retry;
365 }
366 list_add_tail(&new_ie->list, &gc_list->ilist); 361 list_add_tail(&new_ie->list, &gc_list->ilist);
367} 362}
368 363
@@ -373,7 +368,7 @@ static void put_gc_inode(struct gc_inode_list *gc_list)
373 radix_tree_delete(&gc_list->iroot, ie->inode->i_ino); 368 radix_tree_delete(&gc_list->iroot, ie->inode->i_ino);
374 iput(ie->inode); 369 iput(ie->inode);
375 list_del(&ie->list); 370 list_del(&ie->list);
376 kmem_cache_free(winode_slab, ie); 371 kmem_cache_free(inode_entry_slab, ie);
377 } 372 }
378} 373}
379 374
@@ -703,8 +698,7 @@ int f2fs_gc(struct f2fs_sb_info *sbi)
703 .iroot = RADIX_TREE_INIT(GFP_NOFS), 698 .iroot = RADIX_TREE_INIT(GFP_NOFS),
704 }; 699 };
705 700
706 cpc.reason = test_opt(sbi, FASTBOOT) ? CP_UMOUNT : CP_SYNC; 701 cpc.reason = __get_cp_reason(sbi);
707
708gc_more: 702gc_more:
709 if (unlikely(!(sbi->sb->s_flags & MS_ACTIVE))) 703 if (unlikely(!(sbi->sb->s_flags & MS_ACTIVE)))
710 goto stop; 704 goto stop;
@@ -750,17 +744,3 @@ void build_gc_manager(struct f2fs_sb_info *sbi)
750{ 744{
751 DIRTY_I(sbi)->v_ops = &default_v_ops; 745 DIRTY_I(sbi)->v_ops = &default_v_ops;
752} 746}
753
754int __init create_gc_caches(void)
755{
756 winode_slab = f2fs_kmem_cache_create("f2fs_gc_inodes",
757 sizeof(struct inode_entry));
758 if (!winode_slab)
759 return -ENOMEM;
760 return 0;
761}
762
763void destroy_gc_caches(void)
764{
765 kmem_cache_destroy(winode_slab);
766}