Lines Matching refs:et
105 static void __try_update_largest_extent(struct extent_tree *et, in __try_update_largest_extent() argument
108 if (et->type != EX_READ) in __try_update_largest_extent()
110 if (en->ei.len <= et->largest.len) in __try_update_largest_extent()
113 et->largest = en->ei; in __try_update_largest_extent()
114 et->largest_updated = true; in __try_update_largest_extent()
259 struct extent_tree *et, struct extent_info *ei, in __attach_extent_node() argument
263 struct extent_tree_info *eti = &sbi->extent_tree[et->type]; in __attach_extent_node()
272 en->et = et; in __attach_extent_node()
275 rb_insert_color_cached(&en->rb_node, &et->root, leftmost); in __attach_extent_node()
276 atomic_inc(&et->node_cnt); in __attach_extent_node()
282 struct extent_tree *et, struct extent_node *en) in __detach_extent_node() argument
284 struct extent_tree_info *eti = &sbi->extent_tree[et->type]; in __detach_extent_node()
286 rb_erase_cached(&en->rb_node, &et->root); in __detach_extent_node()
287 atomic_dec(&et->node_cnt); in __detach_extent_node()
290 if (et->cached_en == en) in __detach_extent_node()
291 et->cached_en = NULL; in __detach_extent_node()
302 struct extent_tree *et, struct extent_node *en) in __release_extent_node() argument
304 struct extent_tree_info *eti = &sbi->extent_tree[et->type]; in __release_extent_node()
311 __detach_extent_node(sbi, et, en); in __release_extent_node()
319 struct extent_tree *et; in __grab_extent_tree() local
323 et = radix_tree_lookup(&eti->extent_tree_root, ino); in __grab_extent_tree()
324 if (!et) { in __grab_extent_tree()
325 et = f2fs_kmem_cache_alloc(extent_tree_slab, in __grab_extent_tree()
327 f2fs_radix_tree_insert(&eti->extent_tree_root, ino, et); in __grab_extent_tree()
328 memset(et, 0, sizeof(struct extent_tree)); in __grab_extent_tree()
329 et->ino = ino; in __grab_extent_tree()
330 et->type = type; in __grab_extent_tree()
331 et->root = RB_ROOT_CACHED; in __grab_extent_tree()
332 et->cached_en = NULL; in __grab_extent_tree()
333 rwlock_init(&et->lock); in __grab_extent_tree()
334 INIT_LIST_HEAD(&et->list); in __grab_extent_tree()
335 atomic_set(&et->node_cnt, 0); in __grab_extent_tree()
339 list_del_init(&et->list); in __grab_extent_tree()
344 F2FS_I(inode)->extent_tree[type] = et; in __grab_extent_tree()
346 return et; in __grab_extent_tree()
350 struct extent_tree *et, unsigned int nr_shrink) in __free_extent_tree() argument
356 node = rb_first_cached(&et->root); in __free_extent_tree()
361 __release_extent_node(sbi, et, en); in __free_extent_tree()
368 static void __drop_largest_extent(struct extent_tree *et, in __drop_largest_extent() argument
371 if (fofs < (pgoff_t)et->largest.fofs + et->largest.len && in __drop_largest_extent()
372 fofs + len > et->largest.fofs) { in __drop_largest_extent()
373 et->largest.len = 0; in __drop_largest_extent()
374 et->largest_updated = true; in __drop_largest_extent()
383 struct extent_tree *et; in f2fs_init_read_extent_tree() local
398 et = __grab_extent_tree(inode, EX_READ); in f2fs_init_read_extent_tree()
402 write_lock(&et->lock); in f2fs_init_read_extent_tree()
403 if (atomic_read(&et->node_cnt) || !ei.len) in f2fs_init_read_extent_tree()
406 en = __attach_extent_node(sbi, et, &ei, NULL, in f2fs_init_read_extent_tree()
407 &et->root.rb_root.rb_node, true); in f2fs_init_read_extent_tree()
409 et->largest = en->ei; in f2fs_init_read_extent_tree()
410 et->cached_en = en; in f2fs_init_read_extent_tree()
419 et->largest.len = 0; in f2fs_init_read_extent_tree()
420 et->largest_updated = true; in f2fs_init_read_extent_tree()
422 write_unlock(&et->lock); in f2fs_init_read_extent_tree()
448 struct extent_tree *et = F2FS_I(inode)->extent_tree[type]; in __lookup_extent_tree() local
452 if (!et) in __lookup_extent_tree()
457 read_lock(&et->lock); in __lookup_extent_tree()
460 et->largest.fofs <= pgofs && in __lookup_extent_tree()
461 (pgoff_t)et->largest.fofs + et->largest.len > pgofs) { in __lookup_extent_tree()
462 *ei = et->largest; in __lookup_extent_tree()
468 en = __lookup_extent_node(&et->root, et->cached_en, pgofs); in __lookup_extent_tree()
472 if (en == et->cached_en) in __lookup_extent_tree()
481 et->cached_en = en; in __lookup_extent_tree()
487 read_unlock(&et->lock); in __lookup_extent_tree()
497 struct extent_tree *et, struct extent_info *ei, in __try_merge_extent_node() argument
501 struct extent_tree_info *eti = &sbi->extent_tree[et->type]; in __try_merge_extent_node()
504 if (prev_ex && __is_back_mergeable(ei, &prev_ex->ei, et->type)) { in __try_merge_extent_node()
510 if (next_ex && __is_front_mergeable(ei, &next_ex->ei, et->type)) { in __try_merge_extent_node()
513 if (et->type == EX_READ) in __try_merge_extent_node()
516 __release_extent_node(sbi, et, prev_ex); in __try_merge_extent_node()
524 __try_update_largest_extent(et, en); in __try_merge_extent_node()
529 et->cached_en = en; in __try_merge_extent_node()
536 struct extent_tree *et, struct extent_info *ei, in __insert_extent_tree() argument
541 struct extent_tree_info *eti = &sbi->extent_tree[et->type]; in __insert_extent_tree()
542 struct rb_node **p = &et->root.rb_root.rb_node; in __insert_extent_tree()
570 en = __attach_extent_node(sbi, et, ei, parent, p, leftmost); in __insert_extent_tree()
574 __try_update_largest_extent(et, en); in __insert_extent_tree()
579 et->cached_en = en; in __insert_extent_tree()
588 struct extent_tree *et = F2FS_I(inode)->extent_tree[type]; in __destroy_extent_node() local
594 if (!et || !atomic_read(&et->node_cnt)) in __destroy_extent_node()
597 while (atomic_read(&et->node_cnt)) { in __destroy_extent_node()
598 write_lock(&et->lock); in __destroy_extent_node()
599 node_cnt += __free_extent_tree(sbi, et, nr_shrink); in __destroy_extent_node()
600 write_unlock(&et->lock); in __destroy_extent_node()
603 f2fs_bug_on(sbi, atomic_read(&et->node_cnt)); in __destroy_extent_node()
612 struct extent_tree *et = F2FS_I(inode)->extent_tree[type]; in __update_extent_tree_range() local
622 if (!et) in __update_extent_tree_range()
632 write_lock(&et->lock); in __update_extent_tree_range()
636 write_unlock(&et->lock); in __update_extent_tree_range()
640 prev = et->largest; in __update_extent_tree_range()
647 __drop_largest_extent(et, fofs, len); in __update_extent_tree_range()
651 en = __lookup_extent_node_ret(&et->root, in __update_extent_tree_range()
652 et->cached_en, fofs, in __update_extent_tree_range()
685 en1 = __insert_extent_tree(sbi, et, &ei, in __update_extent_tree_range()
707 __try_update_largest_extent(et, en); in __update_extent_tree_range()
709 __release_extent_node(sbi, et, en); in __update_extent_tree_range()
732 if (!__try_merge_extent_node(sbi, et, &ei, prev_en, next_en)) in __update_extent_tree_range()
733 __insert_extent_tree(sbi, et, &ei, in __update_extent_tree_range()
739 et->largest.len < F2FS_MIN_EXTENT_LEN) { in __update_extent_tree_range()
740 et->largest.len = 0; in __update_extent_tree_range()
741 et->largest_updated = true; in __update_extent_tree_range()
746 if (et->largest_updated) { in __update_extent_tree_range()
747 et->largest_updated = false; in __update_extent_tree_range()
757 if (!__try_merge_extent_node(sbi, et, &ei, prev_en, next_en)) in __update_extent_tree_range()
758 __insert_extent_tree(sbi, et, &ei, in __update_extent_tree_range()
761 write_unlock(&et->lock); in __update_extent_tree_range()
776 struct extent_tree *et = F2FS_I(inode)->extent_tree[EX_READ]; in f2fs_update_read_extent_tree_range_compressed() local
790 write_lock(&et->lock); in f2fs_update_read_extent_tree_range_compressed()
792 en = __lookup_extent_node_ret(&et->root, in f2fs_update_read_extent_tree_range_compressed()
793 et->cached_en, fofs, in f2fs_update_read_extent_tree_range_compressed()
803 if (!__try_merge_extent_node(sbi, et, &ei, prev_en, next_en)) in f2fs_update_read_extent_tree_range_compressed()
804 __insert_extent_tree(sbi, et, &ei, in f2fs_update_read_extent_tree_range_compressed()
807 write_unlock(&et->lock); in f2fs_update_read_extent_tree_range_compressed()
915 struct extent_tree *et, *next; in __shrink_extent_tree() local
927 list_for_each_entry_safe(et, next, &eti->zombie_list, list) { in __shrink_extent_tree()
928 if (atomic_read(&et->node_cnt)) { in __shrink_extent_tree()
929 write_lock(&et->lock); in __shrink_extent_tree()
930 node_cnt += __free_extent_tree(sbi, et, in __shrink_extent_tree()
932 write_unlock(&et->lock); in __shrink_extent_tree()
935 if (atomic_read(&et->node_cnt)) in __shrink_extent_tree()
938 list_del_init(&et->list); in __shrink_extent_tree()
939 radix_tree_delete(&eti->extent_tree_root, et->ino); in __shrink_extent_tree()
940 kmem_cache_free(extent_tree_slab, et); in __shrink_extent_tree()
964 et = en->et; in __shrink_extent_tree()
965 if (!write_trylock(&et->lock)) { in __shrink_extent_tree()
974 __detach_extent_node(sbi, et, en); in __shrink_extent_tree()
976 write_unlock(&et->lock); in __shrink_extent_tree()
1084 struct extent_tree *et = F2FS_I(inode)->extent_tree[type]; in __drop_extent_tree() local
1090 write_lock(&et->lock); in __drop_extent_tree()
1093 if (et->largest.len) { in __drop_extent_tree()
1094 et->largest.len = 0; in __drop_extent_tree()
1098 write_unlock(&et->lock); in __drop_extent_tree()
1116 struct extent_tree *et = F2FS_I(inode)->extent_tree[type]; in __destroy_extent_tree() local
1119 if (!et) in __destroy_extent_tree()
1123 atomic_read(&et->node_cnt)) { in __destroy_extent_tree()
1125 list_add_tail(&et->list, &eti->zombie_list); in __destroy_extent_tree()
1136 f2fs_bug_on(sbi, atomic_read(&et->node_cnt)); in __destroy_extent_tree()
1138 kmem_cache_free(extent_tree_slab, et); in __destroy_extent_tree()