Lines Matching full:et
104 static void __try_update_largest_extent(struct extent_tree *et, in __try_update_largest_extent() argument
107 if (et->type != EX_READ) in __try_update_largest_extent()
109 if (en->ei.len <= et->largest.len) in __try_update_largest_extent()
112 et->largest = en->ei; in __try_update_largest_extent()
113 et->largest_updated = true; in __try_update_largest_extent()
258 struct extent_tree *et, struct extent_info *ei, in __attach_extent_node() argument
262 struct extent_tree_info *eti = &sbi->extent_tree[et->type]; in __attach_extent_node()
271 en->et = et; in __attach_extent_node()
274 rb_insert_color_cached(&en->rb_node, &et->root, leftmost); in __attach_extent_node()
275 atomic_inc(&et->node_cnt); in __attach_extent_node()
281 struct extent_tree *et, struct extent_node *en) in __detach_extent_node() argument
283 struct extent_tree_info *eti = &sbi->extent_tree[et->type]; in __detach_extent_node()
285 rb_erase_cached(&en->rb_node, &et->root); in __detach_extent_node()
286 atomic_dec(&et->node_cnt); in __detach_extent_node()
289 if (et->cached_en == en) in __detach_extent_node()
290 et->cached_en = NULL; in __detach_extent_node()
301 struct extent_tree *et, struct extent_node *en) in __release_extent_node() argument
303 struct extent_tree_info *eti = &sbi->extent_tree[et->type]; in __release_extent_node()
310 __detach_extent_node(sbi, et, en); in __release_extent_node()
318 struct extent_tree *et; in __grab_extent_tree() local
322 et = radix_tree_lookup(&eti->extent_tree_root, ino); in __grab_extent_tree()
323 if (!et) { in __grab_extent_tree()
324 et = f2fs_kmem_cache_alloc(extent_tree_slab, in __grab_extent_tree()
326 f2fs_radix_tree_insert(&eti->extent_tree_root, ino, et); in __grab_extent_tree()
327 memset(et, 0, sizeof(struct extent_tree)); in __grab_extent_tree()
328 et->ino = ino; in __grab_extent_tree()
329 et->type = type; in __grab_extent_tree()
330 et->root = RB_ROOT_CACHED; in __grab_extent_tree()
331 et->cached_en = NULL; in __grab_extent_tree()
332 rwlock_init(&et->lock); in __grab_extent_tree()
333 INIT_LIST_HEAD(&et->list); in __grab_extent_tree()
334 atomic_set(&et->node_cnt, 0); in __grab_extent_tree()
338 list_del_init(&et->list); in __grab_extent_tree()
343 F2FS_I(inode)->extent_tree[type] = et; in __grab_extent_tree()
345 return et; in __grab_extent_tree()
349 struct extent_tree *et) in __free_extent_tree() argument
353 unsigned int count = atomic_read(&et->node_cnt); in __free_extent_tree()
355 node = rb_first_cached(&et->root); in __free_extent_tree()
359 __release_extent_node(sbi, et, en); in __free_extent_tree()
363 return count - atomic_read(&et->node_cnt); in __free_extent_tree()
366 static void __drop_largest_extent(struct extent_tree *et, in __drop_largest_extent() argument
369 if (fofs < (pgoff_t)et->largest.fofs + et->largest.len && in __drop_largest_extent()
370 fofs + len > et->largest.fofs) { in __drop_largest_extent()
371 et->largest.len = 0; in __drop_largest_extent()
372 et->largest_updated = true; in __drop_largest_extent()
381 struct extent_tree *et; in f2fs_init_read_extent_tree() local
396 et = __grab_extent_tree(inode, EX_READ); in f2fs_init_read_extent_tree()
400 write_lock(&et->lock); in f2fs_init_read_extent_tree()
401 if (atomic_read(&et->node_cnt) || !ei.len) in f2fs_init_read_extent_tree()
404 en = __attach_extent_node(sbi, et, &ei, NULL, in f2fs_init_read_extent_tree()
405 &et->root.rb_root.rb_node, true); in f2fs_init_read_extent_tree()
407 et->largest = en->ei; in f2fs_init_read_extent_tree()
408 et->cached_en = en; in f2fs_init_read_extent_tree()
417 et->largest.len = 0; in f2fs_init_read_extent_tree()
418 et->largest_updated = true; in f2fs_init_read_extent_tree()
420 write_unlock(&et->lock); in f2fs_init_read_extent_tree()
446 struct extent_tree *et = F2FS_I(inode)->extent_tree[type]; in __lookup_extent_tree() local
450 if (!et) in __lookup_extent_tree()
455 read_lock(&et->lock); in __lookup_extent_tree()
458 et->largest.fofs <= pgofs && in __lookup_extent_tree()
459 (pgoff_t)et->largest.fofs + et->largest.len > pgofs) { in __lookup_extent_tree()
460 *ei = et->largest; in __lookup_extent_tree()
466 en = __lookup_extent_node(&et->root, et->cached_en, pgofs); in __lookup_extent_tree()
470 if (en == et->cached_en) in __lookup_extent_tree()
479 et->cached_en = en; in __lookup_extent_tree()
485 read_unlock(&et->lock); in __lookup_extent_tree()
495 struct extent_tree *et, struct extent_info *ei, in __try_merge_extent_node() argument
499 struct extent_tree_info *eti = &sbi->extent_tree[et->type]; in __try_merge_extent_node()
502 if (prev_ex && __is_back_mergeable(ei, &prev_ex->ei, et->type)) { in __try_merge_extent_node()
508 if (next_ex && __is_front_mergeable(ei, &next_ex->ei, et->type)) { in __try_merge_extent_node()
511 if (et->type == EX_READ) in __try_merge_extent_node()
514 __release_extent_node(sbi, et, prev_ex); in __try_merge_extent_node()
522 __try_update_largest_extent(et, en); in __try_merge_extent_node()
527 et->cached_en = en; in __try_merge_extent_node()
534 struct extent_tree *et, struct extent_info *ei, in __insert_extent_tree() argument
539 struct extent_tree_info *eti = &sbi->extent_tree[et->type]; in __insert_extent_tree()
540 struct rb_node **p = &et->root.rb_root.rb_node; in __insert_extent_tree()
568 en = __attach_extent_node(sbi, et, ei, parent, p, leftmost); in __insert_extent_tree()
572 __try_update_largest_extent(et, en); in __insert_extent_tree()
577 et->cached_en = en; in __insert_extent_tree()
586 struct extent_tree *et = F2FS_I(inode)->extent_tree[type]; in __update_extent_tree_range() local
596 if (!et) in __update_extent_tree_range()
606 write_lock(&et->lock); in __update_extent_tree_range()
610 write_unlock(&et->lock); in __update_extent_tree_range()
614 prev = et->largest; in __update_extent_tree_range()
621 __drop_largest_extent(et, fofs, len); in __update_extent_tree_range()
625 en = __lookup_extent_node_ret(&et->root, in __update_extent_tree_range()
626 et->cached_en, fofs, in __update_extent_tree_range()
659 en1 = __insert_extent_tree(sbi, et, &ei, in __update_extent_tree_range()
681 __try_update_largest_extent(et, en); in __update_extent_tree_range()
683 __release_extent_node(sbi, et, en); in __update_extent_tree_range()
706 if (!__try_merge_extent_node(sbi, et, &ei, prev_en, next_en)) in __update_extent_tree_range()
707 __insert_extent_tree(sbi, et, &ei, in __update_extent_tree_range()
713 et->largest.len < F2FS_MIN_EXTENT_LEN) { in __update_extent_tree_range()
714 et->largest.len = 0; in __update_extent_tree_range()
715 et->largest_updated = true; in __update_extent_tree_range()
721 __free_extent_tree(sbi, et); in __update_extent_tree_range()
723 if (et->largest_updated) { in __update_extent_tree_range()
724 et->largest_updated = false; in __update_extent_tree_range()
734 if (!__try_merge_extent_node(sbi, et, &ei, prev_en, next_en)) in __update_extent_tree_range()
735 __insert_extent_tree(sbi, et, &ei, in __update_extent_tree_range()
738 write_unlock(&et->lock); in __update_extent_tree_range()
750 struct extent_tree *et = F2FS_I(inode)->extent_tree[EX_READ]; in f2fs_update_read_extent_tree_range_compressed() local
760 /* it is safe here to check FI_NO_EXTENT w/o et->lock in ro image */ in f2fs_update_read_extent_tree_range_compressed()
764 write_lock(&et->lock); in f2fs_update_read_extent_tree_range_compressed()
766 en = __lookup_extent_node_ret(&et->root, in f2fs_update_read_extent_tree_range_compressed()
767 et->cached_en, fofs, in f2fs_update_read_extent_tree_range_compressed()
777 if (!__try_merge_extent_node(sbi, et, &ei, prev_en, next_en)) in f2fs_update_read_extent_tree_range_compressed()
778 __insert_extent_tree(sbi, et, &ei, in f2fs_update_read_extent_tree_range_compressed()
781 write_unlock(&et->lock); in f2fs_update_read_extent_tree_range_compressed()
887 struct extent_tree *et, *next; in __shrink_extent_tree() local
899 list_for_each_entry_safe(et, next, &eti->zombie_list, list) { in __shrink_extent_tree()
900 if (atomic_read(&et->node_cnt)) { in __shrink_extent_tree()
901 write_lock(&et->lock); in __shrink_extent_tree()
902 node_cnt += __free_extent_tree(sbi, et); in __shrink_extent_tree()
903 write_unlock(&et->lock); in __shrink_extent_tree()
905 f2fs_bug_on(sbi, atomic_read(&et->node_cnt)); in __shrink_extent_tree()
906 list_del_init(&et->list); in __shrink_extent_tree()
907 radix_tree_delete(&eti->extent_tree_root, et->ino); in __shrink_extent_tree()
908 kmem_cache_free(extent_tree_slab, et); in __shrink_extent_tree()
932 et = en->et; in __shrink_extent_tree()
933 if (!write_trylock(&et->lock)) { in __shrink_extent_tree()
942 __detach_extent_node(sbi, et, en); in __shrink_extent_tree()
944 write_unlock(&et->lock); in __shrink_extent_tree()
1048 struct extent_tree *et = F2FS_I(inode)->extent_tree[type]; in __destroy_extent_node() local
1051 if (!et || !atomic_read(&et->node_cnt)) in __destroy_extent_node()
1054 write_lock(&et->lock); in __destroy_extent_node()
1055 node_cnt = __free_extent_tree(sbi, et); in __destroy_extent_node()
1056 write_unlock(&et->lock); in __destroy_extent_node()
1070 struct extent_tree *et = F2FS_I(inode)->extent_tree[type]; in __drop_extent_tree() local
1076 write_lock(&et->lock); in __drop_extent_tree()
1077 __free_extent_tree(sbi, et); in __drop_extent_tree()
1080 if (et->largest.len) { in __drop_extent_tree()
1081 et->largest.len = 0; in __drop_extent_tree()
1085 write_unlock(&et->lock); in __drop_extent_tree()
1100 struct extent_tree *et = F2FS_I(inode)->extent_tree[type]; in __destroy_extent_tree() local
1103 if (!et) in __destroy_extent_tree()
1107 atomic_read(&et->node_cnt)) { in __destroy_extent_tree()
1109 list_add_tail(&et->list, &eti->zombie_list); in __destroy_extent_tree()
1120 f2fs_bug_on(sbi, atomic_read(&et->node_cnt)); in __destroy_extent_tree()
1122 kmem_cache_free(extent_tree_slab, et); in __destroy_extent_tree()