Lines Matching refs:nm_i

23 #define on_f2fs_build_free_nids(nmi) mutex_is_locked(&(nm_i)->build_lock)
47 struct f2fs_nm_info *nm_i = NM_I(sbi); in f2fs_available_free_memory() local
54 if (!nm_i) in f2fs_available_free_memory()
66 mem_size = (nm_i->nid_cnt[FREE_NID] * in f2fs_available_free_memory()
68 res = mem_size < ((avail_ram * nm_i->ram_thresh / 100) >> 2); in f2fs_available_free_memory()
70 mem_size = (nm_i->nat_cnt[TOTAL_NAT] * in f2fs_available_free_memory()
72 res = mem_size < ((avail_ram * nm_i->ram_thresh / 100) >> 2); in f2fs_available_free_memory()
79 res = mem_size < ((avail_ram * nm_i->ram_thresh / 100) >> 1); in f2fs_available_free_memory()
87 res = mem_size < ((avail_ram * nm_i->ram_thresh / 100) >> 1); in f2fs_available_free_memory()
93 res = mem_size < ((avail_ram * nm_i->ram_thresh / 100) >> 1); in f2fs_available_free_memory()
97 res = mem_size < (avail_ram * nm_i->ram_thresh / 100); in f2fs_available_free_memory()
141 struct f2fs_nm_info *nm_i = NM_I(sbi); in get_next_nat_page() local
158 set_to_next_nat(nm_i, nid); in get_next_nat_page()
183 static struct nat_entry *__init_nat_entry(struct f2fs_nm_info *nm_i, in __init_nat_entry() argument
187 f2fs_radix_tree_insert(&nm_i->nat_root, nat_get_nid(ne), ne); in __init_nat_entry()
188 else if (radix_tree_insert(&nm_i->nat_root, nat_get_nid(ne), ne)) in __init_nat_entry()
194 spin_lock(&nm_i->nat_list_lock); in __init_nat_entry()
195 list_add_tail(&ne->list, &nm_i->nat_entries); in __init_nat_entry()
196 spin_unlock(&nm_i->nat_list_lock); in __init_nat_entry()
198 nm_i->nat_cnt[TOTAL_NAT]++; in __init_nat_entry()
199 nm_i->nat_cnt[RECLAIMABLE_NAT]++; in __init_nat_entry()
203 static struct nat_entry *__lookup_nat_cache(struct f2fs_nm_info *nm_i, nid_t n) in __lookup_nat_cache() argument
207 ne = radix_tree_lookup(&nm_i->nat_root, n); in __lookup_nat_cache()
211 spin_lock(&nm_i->nat_list_lock); in __lookup_nat_cache()
213 list_move_tail(&ne->list, &nm_i->nat_entries); in __lookup_nat_cache()
214 spin_unlock(&nm_i->nat_list_lock); in __lookup_nat_cache()
220 static unsigned int __gang_lookup_nat_cache(struct f2fs_nm_info *nm_i, in __gang_lookup_nat_cache() argument
223 return radix_tree_gang_lookup(&nm_i->nat_root, (void **)ep, start, nr); in __gang_lookup_nat_cache()
226 static void __del_from_nat_cache(struct f2fs_nm_info *nm_i, struct nat_entry *e) in __del_from_nat_cache() argument
228 radix_tree_delete(&nm_i->nat_root, nat_get_nid(e)); in __del_from_nat_cache()
229 nm_i->nat_cnt[TOTAL_NAT]--; in __del_from_nat_cache()
230 nm_i->nat_cnt[RECLAIMABLE_NAT]--; in __del_from_nat_cache()
234 static struct nat_entry_set *__grab_nat_entry_set(struct f2fs_nm_info *nm_i, in __grab_nat_entry_set() argument
240 head = radix_tree_lookup(&nm_i->nat_set_root, set); in __grab_nat_entry_set()
249 f2fs_radix_tree_insert(&nm_i->nat_set_root, set, head); in __grab_nat_entry_set()
254 static void __set_nat_cache_dirty(struct f2fs_nm_info *nm_i, in __set_nat_cache_dirty() argument
261 head = __grab_nat_entry_set(nm_i, ne); in __set_nat_cache_dirty()
277 nm_i->nat_cnt[DIRTY_NAT]++; in __set_nat_cache_dirty()
278 nm_i->nat_cnt[RECLAIMABLE_NAT]--; in __set_nat_cache_dirty()
281 spin_lock(&nm_i->nat_list_lock); in __set_nat_cache_dirty()
286 spin_unlock(&nm_i->nat_list_lock); in __set_nat_cache_dirty()
289 static void __clear_nat_cache_dirty(struct f2fs_nm_info *nm_i, in __clear_nat_cache_dirty() argument
292 spin_lock(&nm_i->nat_list_lock); in __clear_nat_cache_dirty()
293 list_move_tail(&ne->list, &nm_i->nat_entries); in __clear_nat_cache_dirty()
294 spin_unlock(&nm_i->nat_list_lock); in __clear_nat_cache_dirty()
298 nm_i->nat_cnt[DIRTY_NAT]--; in __clear_nat_cache_dirty()
299 nm_i->nat_cnt[RECLAIMABLE_NAT]++; in __clear_nat_cache_dirty()
302 static unsigned int __gang_lookup_nat_set(struct f2fs_nm_info *nm_i, in __gang_lookup_nat_set() argument
305 return radix_tree_gang_lookup(&nm_i->nat_set_root, (void **)ep, in __gang_lookup_nat_set()
378 struct f2fs_nm_info *nm_i = NM_I(sbi); in f2fs_need_dentry_mark() local
382 f2fs_down_read(&nm_i->nat_tree_lock); in f2fs_need_dentry_mark()
383 e = __lookup_nat_cache(nm_i, nid); in f2fs_need_dentry_mark()
389 f2fs_up_read(&nm_i->nat_tree_lock); in f2fs_need_dentry_mark()
395 struct f2fs_nm_info *nm_i = NM_I(sbi); in f2fs_is_checkpointed_node() local
399 f2fs_down_read(&nm_i->nat_tree_lock); in f2fs_is_checkpointed_node()
400 e = __lookup_nat_cache(nm_i, nid); in f2fs_is_checkpointed_node()
403 f2fs_up_read(&nm_i->nat_tree_lock); in f2fs_is_checkpointed_node()
409 struct f2fs_nm_info *nm_i = NM_I(sbi); in f2fs_need_inode_block_update() local
413 f2fs_down_read(&nm_i->nat_tree_lock); in f2fs_need_inode_block_update()
414 e = __lookup_nat_cache(nm_i, ino); in f2fs_need_inode_block_update()
419 f2fs_up_read(&nm_i->nat_tree_lock); in f2fs_need_inode_block_update()
427 struct f2fs_nm_info *nm_i = NM_I(sbi); in cache_nat_entry() local
438 f2fs_down_write(&nm_i->nat_tree_lock); in cache_nat_entry()
439 e = __lookup_nat_cache(nm_i, nid); in cache_nat_entry()
441 e = __init_nat_entry(nm_i, new, ne, false); in cache_nat_entry()
447 f2fs_up_write(&nm_i->nat_tree_lock); in cache_nat_entry()
455 struct f2fs_nm_info *nm_i = NM_I(sbi); in set_node_addr() local
459 f2fs_down_write(&nm_i->nat_tree_lock); in set_node_addr()
460 e = __lookup_nat_cache(nm_i, ni->nid); in set_node_addr()
462 e = __init_nat_entry(nm_i, new, NULL, true); in set_node_addr()
498 __set_nat_cache_dirty(nm_i, e); in set_node_addr()
502 e = __lookup_nat_cache(nm_i, ni->ino); in set_node_addr()
508 f2fs_up_write(&nm_i->nat_tree_lock); in set_node_addr()
513 struct f2fs_nm_info *nm_i = NM_I(sbi); in f2fs_try_to_free_nats() local
516 if (!f2fs_down_write_trylock(&nm_i->nat_tree_lock)) in f2fs_try_to_free_nats()
519 spin_lock(&nm_i->nat_list_lock); in f2fs_try_to_free_nats()
523 if (list_empty(&nm_i->nat_entries)) in f2fs_try_to_free_nats()
526 ne = list_first_entry(&nm_i->nat_entries, in f2fs_try_to_free_nats()
529 spin_unlock(&nm_i->nat_list_lock); in f2fs_try_to_free_nats()
531 __del_from_nat_cache(nm_i, ne); in f2fs_try_to_free_nats()
534 spin_lock(&nm_i->nat_list_lock); in f2fs_try_to_free_nats()
536 spin_unlock(&nm_i->nat_list_lock); in f2fs_try_to_free_nats()
538 f2fs_up_write(&nm_i->nat_tree_lock); in f2fs_try_to_free_nats()
545 struct f2fs_nm_info *nm_i = NM_I(sbi); in f2fs_get_node_info() local
560 f2fs_down_read(&nm_i->nat_tree_lock); in f2fs_get_node_info()
561 e = __lookup_nat_cache(nm_i, nid); in f2fs_get_node_info()
566 f2fs_up_read(&nm_i->nat_tree_lock); in f2fs_get_node_info()
578 } else if (f2fs_rwsem_is_contended(&nm_i->nat_tree_lock) || in f2fs_get_node_info()
580 f2fs_up_read(&nm_i->nat_tree_lock); in f2fs_get_node_info()
591 f2fs_up_read(&nm_i->nat_tree_lock); in f2fs_get_node_info()
597 f2fs_up_read(&nm_i->nat_tree_lock); in f2fs_get_node_info()
2171 static struct free_nid *__lookup_free_nid_list(struct f2fs_nm_info *nm_i, in __lookup_free_nid_list() argument
2174 return radix_tree_lookup(&nm_i->free_nid_root, n); in __lookup_free_nid_list()
2180 struct f2fs_nm_info *nm_i = NM_I(sbi); in __insert_free_nid() local
2181 int err = radix_tree_insert(&nm_i->free_nid_root, i->nid, i); in __insert_free_nid()
2186 nm_i->nid_cnt[FREE_NID]++; in __insert_free_nid()
2187 list_add_tail(&i->list, &nm_i->free_nid_list); in __insert_free_nid()
2194 struct f2fs_nm_info *nm_i = NM_I(sbi); in __remove_free_nid() local
2197 nm_i->nid_cnt[state]--; in __remove_free_nid()
2200 radix_tree_delete(&nm_i->free_nid_root, i->nid); in __remove_free_nid()
2206 struct f2fs_nm_info *nm_i = NM_I(sbi); in __move_free_nid() local
2210 nm_i->nid_cnt[org_state]--; in __move_free_nid()
2211 nm_i->nid_cnt[dst_state]++; in __move_free_nid()
2218 list_add_tail(&i->list, &nm_i->free_nid_list); in __move_free_nid()
2227 struct f2fs_nm_info *nm_i = NM_I(sbi); in f2fs_nat_bitmap_enabled() local
2231 f2fs_down_read(&nm_i->nat_tree_lock); in f2fs_nat_bitmap_enabled()
2232 for (i = 0; i < nm_i->nat_blocks; i++) { in f2fs_nat_bitmap_enabled()
2233 if (!test_bit_le(i, nm_i->nat_block_bitmap)) { in f2fs_nat_bitmap_enabled()
2238 f2fs_up_read(&nm_i->nat_tree_lock); in f2fs_nat_bitmap_enabled()
2246 struct f2fs_nm_info *nm_i = NM_I(sbi); in update_free_nid_bitmap() local
2250 if (!test_bit_le(nat_ofs, nm_i->nat_block_bitmap)) in update_free_nid_bitmap()
2254 if (test_bit_le(nid_ofs, nm_i->free_nid_bitmap[nat_ofs])) in update_free_nid_bitmap()
2256 __set_bit_le(nid_ofs, nm_i->free_nid_bitmap[nat_ofs]); in update_free_nid_bitmap()
2257 nm_i->free_nid_count[nat_ofs]++; in update_free_nid_bitmap()
2259 if (!test_bit_le(nid_ofs, nm_i->free_nid_bitmap[nat_ofs])) in update_free_nid_bitmap()
2261 __clear_bit_le(nid_ofs, nm_i->free_nid_bitmap[nat_ofs]); in update_free_nid_bitmap()
2263 nm_i->free_nid_count[nat_ofs]--; in update_free_nid_bitmap()
2271 struct f2fs_nm_info *nm_i = NM_I(sbi); in add_free_nid() local
2290 spin_lock(&nm_i->nid_list_lock); in add_free_nid()
2314 ne = __lookup_nat_cache(nm_i, nid); in add_free_nid()
2319 e = __lookup_free_nid_list(nm_i, nid); in add_free_nid()
2332 nm_i->available_nids++; in add_free_nid()
2334 spin_unlock(&nm_i->nid_list_lock); in add_free_nid()
2344 struct f2fs_nm_info *nm_i = NM_I(sbi); in remove_free_nid() local
2348 spin_lock(&nm_i->nid_list_lock); in remove_free_nid()
2349 i = __lookup_free_nid_list(nm_i, nid); in remove_free_nid()
2354 spin_unlock(&nm_i->nid_list_lock); in remove_free_nid()
2363 struct f2fs_nm_info *nm_i = NM_I(sbi); in scan_nat_page() local
2369 __set_bit_le(nat_ofs, nm_i->nat_block_bitmap); in scan_nat_page()
2374 if (unlikely(start_nid >= nm_i->max_nid)) in scan_nat_page()
2417 struct f2fs_nm_info *nm_i = NM_I(sbi); in scan_free_nid_bits() local
2421 f2fs_down_read(&nm_i->nat_tree_lock); in scan_free_nid_bits()
2423 for (i = 0; i < nm_i->nat_blocks; i++) { in scan_free_nid_bits()
2424 if (!test_bit_le(i, nm_i->nat_block_bitmap)) in scan_free_nid_bits()
2426 if (!nm_i->free_nid_count[i]) in scan_free_nid_bits()
2429 idx = find_next_bit_le(nm_i->free_nid_bitmap[i], in scan_free_nid_bits()
2437 if (nm_i->nid_cnt[FREE_NID] >= MAX_FREE_NIDS) in scan_free_nid_bits()
2444 f2fs_up_read(&nm_i->nat_tree_lock); in scan_free_nid_bits()
2450 struct f2fs_nm_info *nm_i = NM_I(sbi); in __f2fs_build_free_nids() local
2452 nid_t nid = nm_i->next_scan_nid; in __f2fs_build_free_nids()
2454 if (unlikely(nid >= nm_i->max_nid)) in __f2fs_build_free_nids()
2461 if (nm_i->nid_cnt[FREE_NID] >= NAT_ENTRY_PER_BLOCK) in __f2fs_build_free_nids()
2471 if (nm_i->nid_cnt[FREE_NID] >= NAT_ENTRY_PER_BLOCK) in __f2fs_build_free_nids()
2479 f2fs_down_read(&nm_i->nat_tree_lock); in __f2fs_build_free_nids()
2483 nm_i->nat_block_bitmap)) { in __f2fs_build_free_nids()
2494 f2fs_up_read(&nm_i->nat_tree_lock); in __f2fs_build_free_nids()
2501 if (unlikely(nid >= nm_i->max_nid)) in __f2fs_build_free_nids()
2509 nm_i->next_scan_nid = nid; in __f2fs_build_free_nids()
2514 f2fs_up_read(&nm_i->nat_tree_lock); in __f2fs_build_free_nids()
2516 f2fs_ra_meta_pages(sbi, NAT_BLOCK_OFFSET(nm_i->next_scan_nid), in __f2fs_build_free_nids()
2517 nm_i->ra_nid_pages, META_NAT, false); in __f2fs_build_free_nids()
2540 struct f2fs_nm_info *nm_i = NM_I(sbi); in f2fs_alloc_nid() local
2548 spin_lock(&nm_i->nid_list_lock); in f2fs_alloc_nid()
2550 if (unlikely(nm_i->available_nids == 0)) { in f2fs_alloc_nid()
2551 spin_unlock(&nm_i->nid_list_lock); in f2fs_alloc_nid()
2556 if (nm_i->nid_cnt[FREE_NID] && !on_f2fs_build_free_nids(nm_i)) { in f2fs_alloc_nid()
2557 f2fs_bug_on(sbi, list_empty(&nm_i->free_nid_list)); in f2fs_alloc_nid()
2558 i = list_first_entry(&nm_i->free_nid_list, in f2fs_alloc_nid()
2563 nm_i->available_nids--; in f2fs_alloc_nid()
2567 spin_unlock(&nm_i->nid_list_lock); in f2fs_alloc_nid()
2570 spin_unlock(&nm_i->nid_list_lock); in f2fs_alloc_nid()
2583 struct f2fs_nm_info *nm_i = NM_I(sbi); in f2fs_alloc_nid_done() local
2586 spin_lock(&nm_i->nid_list_lock); in f2fs_alloc_nid_done()
2587 i = __lookup_free_nid_list(nm_i, nid); in f2fs_alloc_nid_done()
2590 spin_unlock(&nm_i->nid_list_lock); in f2fs_alloc_nid_done()
2600 struct f2fs_nm_info *nm_i = NM_I(sbi); in f2fs_alloc_nid_failed() local
2607 spin_lock(&nm_i->nid_list_lock); in f2fs_alloc_nid_failed()
2608 i = __lookup_free_nid_list(nm_i, nid); in f2fs_alloc_nid_failed()
2618 nm_i->available_nids++; in f2fs_alloc_nid_failed()
2622 spin_unlock(&nm_i->nid_list_lock); in f2fs_alloc_nid_failed()
2630 struct f2fs_nm_info *nm_i = NM_I(sbi); in f2fs_try_to_free_nids() local
2633 if (nm_i->nid_cnt[FREE_NID] <= MAX_FREE_NIDS) in f2fs_try_to_free_nids()
2636 if (!mutex_trylock(&nm_i->build_lock)) in f2fs_try_to_free_nids()
2639 while (nr_shrink && nm_i->nid_cnt[FREE_NID] > MAX_FREE_NIDS) { in f2fs_try_to_free_nids()
2643 spin_lock(&nm_i->nid_list_lock); in f2fs_try_to_free_nids()
2644 list_for_each_entry_safe(i, next, &nm_i->free_nid_list, list) { in f2fs_try_to_free_nids()
2646 nm_i->nid_cnt[FREE_NID] <= MAX_FREE_NIDS) in f2fs_try_to_free_nids()
2653 spin_unlock(&nm_i->nid_list_lock); in f2fs_try_to_free_nids()
2656 mutex_unlock(&nm_i->build_lock); in f2fs_try_to_free_nids()
2856 struct f2fs_nm_info *nm_i = NM_I(sbi); in remove_nats_in_journal() local
2872 ne = __lookup_nat_cache(nm_i, nid); in remove_nats_in_journal()
2875 __init_nat_entry(nm_i, ne, &raw_ne, true); in remove_nats_in_journal()
2885 spin_lock(&nm_i->nid_list_lock); in remove_nats_in_journal()
2886 nm_i->available_nids--; in remove_nats_in_journal()
2887 spin_unlock(&nm_i->nid_list_lock); in remove_nats_in_journal()
2890 __set_nat_cache_dirty(nm_i, ne); in remove_nats_in_journal()
2914 static void __update_nat_bits(struct f2fs_nm_info *nm_i, unsigned int nat_ofs, in __update_nat_bits() argument
2918 __set_bit_le(nat_ofs, nm_i->empty_nat_bits); in __update_nat_bits()
2919 __clear_bit_le(nat_ofs, nm_i->full_nat_bits); in __update_nat_bits()
2923 __clear_bit_le(nat_ofs, nm_i->empty_nat_bits); in __update_nat_bits()
2925 __set_bit_le(nat_ofs, nm_i->full_nat_bits); in __update_nat_bits()
2927 __clear_bit_le(nat_ofs, nm_i->full_nat_bits); in __update_nat_bits()
2933 struct f2fs_nm_info *nm_i = NM_I(sbi); in update_nat_bits() local
2951 __update_nat_bits(nm_i, nat_index, valid); in update_nat_bits()
2956 struct f2fs_nm_info *nm_i = NM_I(sbi); in f2fs_enable_nat_bits() local
2959 f2fs_down_read(&nm_i->nat_tree_lock); in f2fs_enable_nat_bits()
2961 for (nat_ofs = 0; nat_ofs < nm_i->nat_blocks; nat_ofs++) { in f2fs_enable_nat_bits()
2972 nm_i->free_nid_bitmap[nat_ofs])) in f2fs_enable_nat_bits()
2976 __update_nat_bits(nm_i, nat_ofs, valid); in f2fs_enable_nat_bits()
2979 f2fs_up_read(&nm_i->nat_tree_lock); in f2fs_enable_nat_bits()
3062 struct f2fs_nm_info *nm_i = NM_I(sbi); in f2fs_flush_nat_entries() local
3077 f2fs_down_write(&nm_i->nat_tree_lock); in f2fs_flush_nat_entries()
3079 f2fs_up_write(&nm_i->nat_tree_lock); in f2fs_flush_nat_entries()
3082 if (!nm_i->nat_cnt[DIRTY_NAT]) in f2fs_flush_nat_entries()
3085 f2fs_down_write(&nm_i->nat_tree_lock); in f2fs_flush_nat_entries()
3094 nm_i->nat_cnt[DIRTY_NAT], NAT_JOURNAL)) in f2fs_flush_nat_entries()
3097 while ((found = __gang_lookup_nat_set(nm_i, in f2fs_flush_nat_entries()
3114 f2fs_up_write(&nm_i->nat_tree_lock); in f2fs_flush_nat_entries()
3123 struct f2fs_nm_info *nm_i = NM_I(sbi); in __get_nat_bitmaps() local
3124 unsigned int nat_bits_bytes = nm_i->nat_blocks / BITS_PER_BYTE; in __get_nat_bitmaps()
3129 nm_i->nat_bits_blocks = F2FS_BLK_ALIGN((nat_bits_bytes << 1) + 8); in __get_nat_bitmaps()
3130 nm_i->nat_bits = f2fs_kvzalloc(sbi, in __get_nat_bitmaps()
3131 nm_i->nat_bits_blocks << F2FS_BLKSIZE_BITS, GFP_KERNEL); in __get_nat_bitmaps()
3132 if (!nm_i->nat_bits) in __get_nat_bitmaps()
3135 nm_i->full_nat_bits = nm_i->nat_bits + 8; in __get_nat_bitmaps()
3136 nm_i->empty_nat_bits = nm_i->full_nat_bits + nat_bits_bytes; in __get_nat_bitmaps()
3142 nm_i->nat_bits_blocks; in __get_nat_bitmaps()
3143 for (i = 0; i < nm_i->nat_bits_blocks; i++) { in __get_nat_bitmaps()
3150 memcpy(nm_i->nat_bits + (i << F2FS_BLKSIZE_BITS), in __get_nat_bitmaps()
3156 if (cpu_to_le64(cp_ver) != *(__le64 *)nm_i->nat_bits) { in __get_nat_bitmaps()
3159 cp_ver, le64_to_cpu(*(__le64 *)nm_i->nat_bits)); in __get_nat_bitmaps()
3169 struct f2fs_nm_info *nm_i = NM_I(sbi); in load_free_nid_bitmap() local
3176 for (i = 0; i < nm_i->nat_blocks; i++) { in load_free_nid_bitmap()
3177 i = find_next_bit_le(nm_i->empty_nat_bits, nm_i->nat_blocks, i); in load_free_nid_bitmap()
3178 if (i >= nm_i->nat_blocks) in load_free_nid_bitmap()
3181 __set_bit_le(i, nm_i->nat_block_bitmap); in load_free_nid_bitmap()
3192 for (i = 0; i < nm_i->nat_blocks; i++) { in load_free_nid_bitmap()
3193 i = find_next_bit_le(nm_i->full_nat_bits, nm_i->nat_blocks, i); in load_free_nid_bitmap()
3194 if (i >= nm_i->nat_blocks) in load_free_nid_bitmap()
3197 __set_bit_le(i, nm_i->nat_block_bitmap); in load_free_nid_bitmap()
3204 struct f2fs_nm_info *nm_i = NM_I(sbi); in init_node_manager() local
3209 nm_i->nat_blkaddr = le32_to_cpu(sb_raw->nat_blkaddr); in init_node_manager()
3213 nm_i->nat_blocks = nat_segs << le32_to_cpu(sb_raw->log_blocks_per_seg); in init_node_manager()
3214 nm_i->max_nid = NAT_ENTRY_PER_BLOCK * nm_i->nat_blocks; in init_node_manager()
3217 nm_i->available_nids = nm_i->max_nid - sbi->total_valid_node_count - in init_node_manager()
3219 nm_i->nid_cnt[FREE_NID] = 0; in init_node_manager()
3220 nm_i->nid_cnt[PREALLOC_NID] = 0; in init_node_manager()
3221 nm_i->ram_thresh = DEF_RAM_THRESHOLD; in init_node_manager()
3222 nm_i->ra_nid_pages = DEF_RA_NID_PAGES; in init_node_manager()
3223 nm_i->dirty_nats_ratio = DEF_DIRTY_NAT_RATIO_THRESHOLD; in init_node_manager()
3224 nm_i->max_rf_node_blocks = DEF_RF_NODE_BLOCKS; in init_node_manager()
3226 INIT_RADIX_TREE(&nm_i->free_nid_root, GFP_ATOMIC); in init_node_manager()
3227 INIT_LIST_HEAD(&nm_i->free_nid_list); in init_node_manager()
3228 INIT_RADIX_TREE(&nm_i->nat_root, GFP_NOIO); in init_node_manager()
3229 INIT_RADIX_TREE(&nm_i->nat_set_root, GFP_NOIO); in init_node_manager()
3230 INIT_LIST_HEAD(&nm_i->nat_entries); in init_node_manager()
3231 spin_lock_init(&nm_i->nat_list_lock); in init_node_manager()
3233 mutex_init(&nm_i->build_lock); in init_node_manager()
3234 spin_lock_init(&nm_i->nid_list_lock); in init_node_manager()
3235 init_f2fs_rwsem(&nm_i->nat_tree_lock); in init_node_manager()
3237 nm_i->next_scan_nid = le32_to_cpu(sbi->ckpt->next_free_nid); in init_node_manager()
3238 nm_i->bitmap_size = __bitmap_size(sbi, NAT_BITMAP); in init_node_manager()
3240 nm_i->nat_bitmap = kmemdup(version_bitmap, nm_i->bitmap_size, in init_node_manager()
3242 if (!nm_i->nat_bitmap) in init_node_manager()
3250 nm_i->nat_bitmap_mir = kmemdup(version_bitmap, nm_i->bitmap_size, in init_node_manager()
3252 if (!nm_i->nat_bitmap_mir) in init_node_manager()
3261 struct f2fs_nm_info *nm_i = NM_I(sbi); in init_free_nid_cache() local
3264 nm_i->free_nid_bitmap = in init_free_nid_cache()
3266 nm_i->nat_blocks), in init_free_nid_cache()
3268 if (!nm_i->free_nid_bitmap) in init_free_nid_cache()
3271 for (i = 0; i < nm_i->nat_blocks; i++) { in init_free_nid_cache()
3272 nm_i->free_nid_bitmap[i] = f2fs_kvzalloc(sbi, in init_free_nid_cache()
3274 if (!nm_i->free_nid_bitmap[i]) in init_free_nid_cache()
3278 nm_i->nat_block_bitmap = f2fs_kvzalloc(sbi, nm_i->nat_blocks / 8, in init_free_nid_cache()
3280 if (!nm_i->nat_block_bitmap) in init_free_nid_cache()
3283 nm_i->free_nid_count = in init_free_nid_cache()
3285 nm_i->nat_blocks), in init_free_nid_cache()
3287 if (!nm_i->free_nid_count) in init_free_nid_cache()
3317 struct f2fs_nm_info *nm_i = NM_I(sbi); in f2fs_destroy_node_manager() local
3324 if (!nm_i) in f2fs_destroy_node_manager()
3328 spin_lock(&nm_i->nid_list_lock); in f2fs_destroy_node_manager()
3329 list_for_each_entry_safe(i, next_i, &nm_i->free_nid_list, list) { in f2fs_destroy_node_manager()
3331 spin_unlock(&nm_i->nid_list_lock); in f2fs_destroy_node_manager()
3333 spin_lock(&nm_i->nid_list_lock); in f2fs_destroy_node_manager()
3335 f2fs_bug_on(sbi, nm_i->nid_cnt[FREE_NID]); in f2fs_destroy_node_manager()
3336 f2fs_bug_on(sbi, nm_i->nid_cnt[PREALLOC_NID]); in f2fs_destroy_node_manager()
3337 f2fs_bug_on(sbi, !list_empty(&nm_i->free_nid_list)); in f2fs_destroy_node_manager()
3338 spin_unlock(&nm_i->nid_list_lock); in f2fs_destroy_node_manager()
3341 f2fs_down_write(&nm_i->nat_tree_lock); in f2fs_destroy_node_manager()
3342 while ((found = __gang_lookup_nat_cache(nm_i, in f2fs_destroy_node_manager()
3348 spin_lock(&nm_i->nat_list_lock); in f2fs_destroy_node_manager()
3350 spin_unlock(&nm_i->nat_list_lock); in f2fs_destroy_node_manager()
3352 __del_from_nat_cache(nm_i, natvec[idx]); in f2fs_destroy_node_manager()
3355 f2fs_bug_on(sbi, nm_i->nat_cnt[TOTAL_NAT]); in f2fs_destroy_node_manager()
3359 while ((found = __gang_lookup_nat_set(nm_i, in f2fs_destroy_node_manager()
3367 radix_tree_delete(&nm_i->nat_set_root, setvec[idx]->set); in f2fs_destroy_node_manager()
3371 f2fs_up_write(&nm_i->nat_tree_lock); in f2fs_destroy_node_manager()
3373 kvfree(nm_i->nat_block_bitmap); in f2fs_destroy_node_manager()
3374 if (nm_i->free_nid_bitmap) { in f2fs_destroy_node_manager()
3377 for (i = 0; i < nm_i->nat_blocks; i++) in f2fs_destroy_node_manager()
3378 kvfree(nm_i->free_nid_bitmap[i]); in f2fs_destroy_node_manager()
3379 kvfree(nm_i->free_nid_bitmap); in f2fs_destroy_node_manager()
3381 kvfree(nm_i->free_nid_count); in f2fs_destroy_node_manager()
3383 kvfree(nm_i->nat_bitmap); in f2fs_destroy_node_manager()
3384 kvfree(nm_i->nat_bits); in f2fs_destroy_node_manager()
3386 kvfree(nm_i->nat_bitmap_mir); in f2fs_destroy_node_manager()
3389 kfree(nm_i); in f2fs_destroy_node_manager()