aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJaegeuk Kim <jaegeuk.kim@samsung.com>2013-10-24 01:19:18 -0400
committerJaegeuk Kim <jaegeuk.kim@samsung.com>2013-10-25 03:54:38 -0400
commit4660f9c0fe484353b17a4b9d1cc2b036fa895f76 (patch)
treeb992484821791c6b87dc3debfc7df6139dff6480
parent81eb8d6e2869b119d4a7b8c02091c3779733a3ac (diff)
f2fs: introduce f2fs_balance_fs_bg for some background jobs
This patch merges some background jobs into this new function. Signed-off-by: Changman Lee <cm224.lee@samsung.com> Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
-rw-r--r--fs/f2fs/f2fs.h2
-rw-r--r--fs/f2fs/gc.c5
-rw-r--r--fs/f2fs/node.c10
-rw-r--r--fs/f2fs/segment.c8
4 files changed, 15 insertions, 10 deletions
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 6dff777cd94a..a61cc5f84638 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -965,6 +965,7 @@ long f2fs_compat_ioctl(struct file *, unsigned int, unsigned long);
965 */ 965 */
966void f2fs_set_inode_flags(struct inode *); 966void f2fs_set_inode_flags(struct inode *);
967struct inode *f2fs_iget(struct super_block *, unsigned long); 967struct inode *f2fs_iget(struct super_block *, unsigned long);
968int try_to_free_nats(struct f2fs_sb_info *, int);
968void update_inode(struct inode *, struct page *); 969void update_inode(struct inode *, struct page *);
969int update_inode_page(struct inode *); 970int update_inode_page(struct inode *);
970int f2fs_write_inode(struct inode *, struct writeback_control *); 971int f2fs_write_inode(struct inode *, struct writeback_control *);
@@ -1045,6 +1046,7 @@ void destroy_node_manager_caches(void);
1045 * segment.c 1046 * segment.c
1046 */ 1047 */
1047void f2fs_balance_fs(struct f2fs_sb_info *); 1048void f2fs_balance_fs(struct f2fs_sb_info *);
1049void f2fs_balance_fs_bg(struct f2fs_sb_info *);
1048void invalidate_blocks(struct f2fs_sb_info *, block_t); 1050void invalidate_blocks(struct f2fs_sb_info *, block_t);
1049void clear_prefree_segments(struct f2fs_sb_info *); 1051void clear_prefree_segments(struct f2fs_sb_info *);
1050int npages_for_summary_flush(struct f2fs_sb_info *); 1052int npages_for_summary_flush(struct f2fs_sb_info *);
diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
index 783c6cc6253c..b7ad1ec7e4cc 100644
--- a/fs/f2fs/gc.c
+++ b/fs/f2fs/gc.c
@@ -83,9 +83,8 @@ static int gc_thread_func(void *data)
83 if (f2fs_gc(sbi)) 83 if (f2fs_gc(sbi))
84 wait_ms = gc_th->no_gc_sleep_time; 84 wait_ms = gc_th->no_gc_sleep_time;
85 85
86 /* balancing prefree segments */ 86 /* balancing f2fs's metadata periodically */
87 if (excess_prefree_segs(sbi)) 87 f2fs_balance_fs_bg(sbi);
88 f2fs_sync_fs(sbi->sb, true);
89 88
90 } while (!kthread_should_stop()); 89 } while (!kthread_should_stop());
91 return 0; 90 return 0;
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 89dd8a5a3ca3..7bac4815f1d6 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -240,7 +240,7 @@ retry:
240 write_unlock(&nm_i->nat_tree_lock); 240 write_unlock(&nm_i->nat_tree_lock);
241} 241}
242 242
243static int try_to_free_nats(struct f2fs_sb_info *sbi, int nr_shrink) 243int try_to_free_nats(struct f2fs_sb_info *sbi, int nr_shrink)
244{ 244{
245 struct f2fs_nm_info *nm_i = NM_I(sbi); 245 struct f2fs_nm_info *nm_i = NM_I(sbi);
246 246
@@ -1205,12 +1205,8 @@ static int f2fs_write_node_pages(struct address_space *mapping,
1205 struct f2fs_sb_info *sbi = F2FS_SB(mapping->host->i_sb); 1205 struct f2fs_sb_info *sbi = F2FS_SB(mapping->host->i_sb);
1206 long nr_to_write = wbc->nr_to_write; 1206 long nr_to_write = wbc->nr_to_write;
1207 1207
1208 /* First check balancing cached NAT entries */ 1208 /* balancing f2fs's metadata in background */
1209 if (try_to_free_nats(sbi, NAT_ENTRY_PER_BLOCK) || 1209 f2fs_balance_fs_bg(sbi);
1210 excess_prefree_segs(sbi)) {
1211 f2fs_sync_fs(sbi->sb, true);
1212 return 0;
1213 }
1214 1210
1215 /* collect a number of dirty node pages and write together */ 1211 /* collect a number of dirty node pages and write together */
1216 if (get_pages(sbi, F2FS_DIRTY_NODES) < COLLECT_DIRTY_NODES) 1212 if (get_pages(sbi, F2FS_DIRTY_NODES) < COLLECT_DIRTY_NODES)
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 62b52f2f293a..8e5ca2869913 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -36,6 +36,14 @@ void f2fs_balance_fs(struct f2fs_sb_info *sbi)
36 } 36 }
37} 37}
38 38
39void f2fs_balance_fs_bg(struct f2fs_sb_info *sbi)
40{
41 /* check the # of cached NAT entries and prefree segments */
42 if (try_to_free_nats(sbi, NAT_ENTRY_PER_BLOCK) ||
43 excess_prefree_segs(sbi))
44 f2fs_sync_fs(sbi->sb, true);
45}
46
39static void __locate_dirty_segment(struct f2fs_sb_info *sbi, unsigned int segno, 47static void __locate_dirty_segment(struct f2fs_sb_info *sbi, unsigned int segno,
40 enum dirty_type dirty_type) 48 enum dirty_type dirty_type)
41{ 49{