f2fs: separate out iostat feature
[linux-2.6-microblaze.git] / fs / f2fs / gc.c
index 8d1f17a..2c18443 100644 (file)
@@ -19,6 +19,7 @@
 #include "node.h"
 #include "segment.h"
 #include "gc.h"
+#include "iostat.h"
 #include <trace/events/f2fs.h>
 
 static struct kmem_cache *victim_entry_slab;
@@ -371,7 +372,8 @@ static struct victim_entry *attach_victim_entry(struct f2fs_sb_info *sbi,
        struct atgc_management *am = &sbi->am;
        struct victim_entry *ve;
 
-       ve =  f2fs_kmem_cache_alloc(victim_entry_slab, GFP_NOFS);
+       ve =  f2fs_kmem_cache_alloc(victim_entry_slab,
+                               GFP_NOFS, true, NULL);
 
        ve->mtime = mtime;
        ve->segno = segno;
@@ -849,7 +851,8 @@ static void add_gc_inode(struct gc_inode_list *gc_list, struct inode *inode)
                iput(inode);
                return;
        }
-       new_ie = f2fs_kmem_cache_alloc(f2fs_inode_entry_slab, GFP_NOFS);
+       new_ie = f2fs_kmem_cache_alloc(f2fs_inode_entry_slab,
+                                       GFP_NOFS, true, NULL);
        new_ie->inode = inode;
 
        f2fs_radix_tree_insert(&gc_list->iroot, inode->i_ino, new_ie);
@@ -1031,8 +1034,8 @@ static bool is_alive(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
 
                if (unlikely(check_valid_map(sbi, segno, offset))) {
                        if (!test_and_set_bit(segno, SIT_I(sbi)->invalid_segmap)) {
-                               f2fs_err(sbi, "mismatched blkaddr %u (source_blkaddr %u) in seg %u\n",
-                                               blkaddr, source_blkaddr, segno);
+                               f2fs_err(sbi, "mismatched blkaddr %u (source_blkaddr %u) in seg %u",
+                                        blkaddr, source_blkaddr, segno);
                                f2fs_bug_on(sbi, 1);
                        }
                }
@@ -1261,6 +1264,7 @@ static int move_data_block(struct inode *inode, block_t bidx,
        f2fs_put_page(mpage, 1);
        invalidate_mapping_pages(META_MAPPING(fio.sbi),
                                fio.old_blkaddr, fio.old_blkaddr);
+       f2fs_invalidate_compress_page(fio.sbi, fio.old_blkaddr);
 
        set_page_dirty(fio.encrypted_page);
        if (clear_page_dirty_for_io(fio.encrypted_page))
@@ -1336,7 +1340,7 @@ static int move_data_page(struct inode *inode, block_t bidx, int gc_type,
                        goto out;
                }
                set_page_dirty(page);
-               set_cold_data(page);
+               set_page_private_gcing(page);
        } else {
                struct f2fs_io_info fio = {
                        .sbi = F2FS_I_SB(inode),
@@ -1362,11 +1366,11 @@ retry:
                        f2fs_remove_dirty_inode(inode);
                }
 
-               set_cold_data(page);
+               set_page_private_gcing(page);
 
                err = f2fs_do_write_data_page(&fio);
                if (err) {
-                       clear_cold_data(page);
+                       clear_page_private_gcing(page);
                        if (err == -ENOMEM) {
                                congestion_wait(BLK_RW_ASYNC,
                                                DEFAULT_IO_TIMEOUT);
@@ -1450,10 +1454,8 @@ next_step:
 
                if (phase == 3) {
                        inode = f2fs_iget(sb, dni.ino);
-                       if (IS_ERR(inode) || is_bad_inode(inode)) {
-                               set_sbi_flag(sbi, SBI_NEED_FSCK);
+                       if (IS_ERR(inode) || is_bad_inode(inode))
                                continue;
-                       }
 
                        if (!down_write_trylock(
                                &F2FS_I(inode)->i_gc_rwsem[WRITE])) {
@@ -1647,6 +1649,7 @@ static int do_garbage_collect(struct f2fs_sb_info *sbi,
                                                        force_migrate);
 
                stat_inc_seg_count(sbi, type, gc_type);
+               sbi->gc_reclaimed_segs[sbi->gc_mode]++;
                migrated++;
 
 freed:
@@ -1748,7 +1751,7 @@ gc_more:
                round++;
        }
 
-       if (gc_type == FG_GC && seg_freed)
+       if (gc_type == FG_GC)
                sbi->cur_victim_sec = NULL_SEGNO;
 
        if (sync)
@@ -1822,6 +1825,7 @@ static void init_atgc_management(struct f2fs_sb_info *sbi)
        am->candidate_ratio = DEF_GC_THREAD_CANDIDATE_RATIO;
        am->max_candidate_count = DEF_GC_THREAD_MAX_CANDIDATE_COUNT;
        am->age_weight = DEF_GC_THREAD_AGE_WEIGHT;
+       am->age_threshold = DEF_GC_THREAD_AGE_THRESHOLD;
 }
 
 void f2fs_build_gc_manager(struct f2fs_sb_info *sbi)