aboutsummaryrefslogtreecommitdiffstats
path: root/fs/f2fs/node.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/f2fs/node.c')
-rw-r--r--fs/f2fs/node.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 5066bfd256c9..9bda63c9c166 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -1124,6 +1124,12 @@ static int f2fs_write_node_page(struct page *page,
1124 return 0; 1124 return 0;
1125} 1125}
1126 1126
1127/*
1128 * It is very important to gather dirty pages and write at once, so that we can
1129 * submit a big bio without interfering other data writes.
1130 * Be default, 512 pages (2MB), a segment size, is quite reasonable.
1131 */
1132#define COLLECT_DIRTY_NODES 512
1127static int f2fs_write_node_pages(struct address_space *mapping, 1133static int f2fs_write_node_pages(struct address_space *mapping,
1128 struct writeback_control *wbc) 1134 struct writeback_control *wbc)
1129{ 1135{
@@ -1131,17 +1137,16 @@ static int f2fs_write_node_pages(struct address_space *mapping,
1131 struct block_device *bdev = sbi->sb->s_bdev; 1137 struct block_device *bdev = sbi->sb->s_bdev;
1132 long nr_to_write = wbc->nr_to_write; 1138 long nr_to_write = wbc->nr_to_write;
1133 1139
1134 if (wbc->for_kupdate) 1140 /* First check balancing cached NAT entries */
1135 return 0;
1136
1137 if (get_pages(sbi, F2FS_DIRTY_NODES) == 0)
1138 return 0;
1139
1140 if (try_to_free_nats(sbi, NAT_ENTRY_PER_BLOCK)) { 1141 if (try_to_free_nats(sbi, NAT_ENTRY_PER_BLOCK)) {
1141 write_checkpoint(sbi, false, false); 1142 write_checkpoint(sbi, false, false);
1142 return 0; 1143 return 0;
1143 } 1144 }
1144 1145
1146 /* collect a number of dirty node pages and write together */
1147 if (get_pages(sbi, F2FS_DIRTY_NODES) < COLLECT_DIRTY_NODES)
1148 return 0;
1149
1145 /* if mounting is failed, skip writing node pages */ 1150 /* if mounting is failed, skip writing node pages */
1146 wbc->nr_to_write = bio_get_nr_vecs(bdev); 1151 wbc->nr_to_write = bio_get_nr_vecs(bdev);
1147 sync_node_pages(sbi, 0, wbc); 1152 sync_node_pages(sbi, 0, wbc);
@@ -1732,7 +1737,7 @@ void destroy_node_manager(struct f2fs_sb_info *sbi)
1732 kfree(nm_i); 1737 kfree(nm_i);
1733} 1738}
1734 1739
1735int create_node_manager_caches(void) 1740int __init create_node_manager_caches(void)
1736{ 1741{
1737 nat_entry_slab = f2fs_kmem_cache_create("nat_entry", 1742 nat_entry_slab = f2fs_kmem_cache_create("nat_entry",
1738 sizeof(struct nat_entry), NULL); 1743 sizeof(struct nat_entry), NULL);