]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - fs/f2fs/segment.c
f2fs: introduce f2fs_balance_fs_bg for some background jobs
[karo-tx-linux.git] / fs / f2fs / segment.c
index 8ac1619652420a26330d402e8dcf58a18bc049c0..8e5ca286991301322ff0ec6ceca162a3ea19ff54 100644 (file)
@@ -36,6 +36,14 @@ void f2fs_balance_fs(struct f2fs_sb_info *sbi)
        }
 }
 
+void f2fs_balance_fs_bg(struct f2fs_sb_info *sbi)
+{
+       /* check the # of cached NAT entries and prefree segments */
+       if (try_to_free_nats(sbi, NAT_ENTRY_PER_BLOCK) ||
+                               excess_prefree_segs(sbi))
+               f2fs_sync_fs(sbi->sb, true);
+}
+
 static void __locate_dirty_segment(struct f2fs_sb_info *sbi, unsigned int segno,
                enum dirty_type dirty_type)
 {
@@ -554,9 +562,8 @@ static void allocate_segment_by_default(struct f2fs_sb_info *sbi,
                change_curseg(sbi, type, true);
        else
                new_curseg(sbi, type, false);
-#ifdef CONFIG_F2FS_STAT_FS
-       sbi->segment_count[curseg->alloc_type]++;
-#endif
+
+       stat_inc_seg_type(sbi, curseg);
 }
 
 void allocate_new_segments(struct f2fs_sb_info *sbi)
@@ -811,9 +818,8 @@ static void do_write_page(struct f2fs_sb_info *sbi, struct page *page,
 
        mutex_lock(&sit_i->sentry_lock);
        __refresh_next_blkoff(sbi, curseg);
-#ifdef CONFIG_F2FS_STAT_FS
-       sbi->block_count[curseg->alloc_type]++;
-#endif
+
+       stat_inc_block_count(sbi, curseg);
 
        /*
         * SIT information should be updated before segment allocation,
@@ -1647,6 +1653,7 @@ int build_segment_manager(struct f2fs_sb_info *sbi)
        sm_info->ovp_segments = le32_to_cpu(ckpt->overprov_segment_count);
        sm_info->main_segments = le32_to_cpu(raw_super->segment_count_main);
        sm_info->ssa_blkaddr = le32_to_cpu(raw_super->ssa_blkaddr);
+       sm_info->rec_prefree_segments = DEF_RECLAIM_PREFREE_SEGMENTS;
 
        err = build_sit_info(sbi);
        if (err)