node.c (81eb8d6e2869b119d4a7b8c02091c3779733a3ac) node.c (4660f9c0fe484353b17a4b9d1cc2b036fa895f76)
1/*
2 * fs/f2fs/node.c
3 *
4 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 * http://www.samsung.com/
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as

--- 226 unchanged lines hidden (view full) ---

235 }
236
237 /* change address */
238 nat_set_blkaddr(e, new_blkaddr);
239 __set_nat_cache_dirty(nm_i, e);
240 write_unlock(&nm_i->nat_tree_lock);
241}
242
1/*
2 * fs/f2fs/node.c
3 *
4 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 * http://www.samsung.com/
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as

--- 226 unchanged lines hidden (view full) ---

235 }
236
237 /* change address */
238 nat_set_blkaddr(e, new_blkaddr);
239 __set_nat_cache_dirty(nm_i, e);
240 write_unlock(&nm_i->nat_tree_lock);
241}
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{
245 struct f2fs_nm_info *nm_i = NM_I(sbi);
246
247 if (nm_i->nat_cnt <= NM_WOUT_THRESHOLD)
248 return 0;
249
250 write_lock(&nm_i->nat_tree_lock);
251 while (nr_shrink && !list_empty(&nm_i->nat_entries)) {

--- 948 unchanged lines hidden (view full) ---

1200 */
1201#define COLLECT_DIRTY_NODES 1536
1202static int f2fs_write_node_pages(struct address_space *mapping,
1203 struct writeback_control *wbc)
1204{
1205 struct f2fs_sb_info *sbi = F2FS_SB(mapping->host->i_sb);
1206 long nr_to_write = wbc->nr_to_write;
1207
244{
245 struct f2fs_nm_info *nm_i = NM_I(sbi);
246
247 if (nm_i->nat_cnt <= NM_WOUT_THRESHOLD)
248 return 0;
249
250 write_lock(&nm_i->nat_tree_lock);
251 while (nr_shrink && !list_empty(&nm_i->nat_entries)) {

--- 948 unchanged lines hidden (view full) ---

1200 */
1201#define COLLECT_DIRTY_NODES 1536
1202static int f2fs_write_node_pages(struct address_space *mapping,
1203 struct writeback_control *wbc)
1204{
1205 struct f2fs_sb_info *sbi = F2FS_SB(mapping->host->i_sb);
1206 long nr_to_write = wbc->nr_to_write;
1207
1208 /* First check balancing cached NAT entries */
1209 if (try_to_free_nats(sbi, NAT_ENTRY_PER_BLOCK) ||
1210 excess_prefree_segs(sbi)) {
1211 f2fs_sync_fs(sbi->sb, true);
1212 return 0;
1213 }
1208 /* balancing f2fs's metadata in background */
1209 f2fs_balance_fs_bg(sbi);
1214
1215 /* collect a number of dirty node pages and write together */
1216 if (get_pages(sbi, F2FS_DIRTY_NODES) < COLLECT_DIRTY_NODES)
1217 return 0;
1218
1219 /* if mounting is failed, skip writing node pages */
1220 wbc->nr_to_write = 3 * max_hw_blocks(sbi);
1221 sync_node_pages(sbi, 0, wbc);

--- 610 unchanged lines hidden ---
1210
1211 /* collect a number of dirty node pages and write together */
1212 if (get_pages(sbi, F2FS_DIRTY_NODES) < COLLECT_DIRTY_NODES)
1213 return 0;
1214
1215 /* if mounting is failed, skip writing node pages */
1216 wbc->nr_to_write = 3 * max_hw_blocks(sbi);
1217 sync_node_pages(sbi, 0, wbc);

--- 610 unchanged lines hidden ---