Lines Matching defs:tree

31  * Initialize the extent tree @tree.  Should be called for each new inode or
34 void extent_map_tree_init(struct extent_map_tree *tree)
36 tree->map = RB_ROOT_CACHED;
37 INIT_LIST_HEAD(&tree->modified_extents);
38 rwlock_init(&tree->lock);
136 * Search through the tree for an extent_map with a given offset. If it can't
237 struct extent_map_tree *tree = &inode->extent_tree;
242 * We can't modify an extent map that is in the tree and that is being
245 * the tree and 1 for this task (which is unpinning the extent map or
268 rb_erase_cached(&merge->rb_node, &tree->map);
281 rb_erase_cached(&merge->rb_node, &tree->map);
303 * -ENOENT when the extent is not found in the tree
309 struct extent_map_tree *tree = &inode->extent_tree;
313 write_lock(&tree->lock);
314 em = lookup_extent_mapping(tree, start, len);
340 write_unlock(&tree->lock);
370 * Add a new extent map to an inode's extent map tree.
377 * Insert @em into the @inode's extent map tree or perform a simple
379 * in will be inserted into the tree directly, with an additional reference
385 struct extent_map_tree *tree = &inode->extent_tree;
390 lockdep_assert_held_write(&tree->lock);
392 ret = tree_insert(&tree->map, em);
405 __lookup_extent_mapping(struct extent_map_tree *tree,
413 rb_node = __tree_search(&tree->map.rb_root, start, &prev_or_next);
433 * @tree: tree to lookup in
437 * Find and return the first extent_map struct in @tree that intersects the
438 * [start, len] range. There may be additional objects in the tree that
442 struct extent_map *lookup_extent_mapping(struct extent_map_tree *tree,
445 return __lookup_extent_mapping(tree, start, len, 1);
451 * @tree: tree to lookup in
455 * Find and return the first extent_map struct in @tree that intersects the
460 struct extent_map *search_extent_mapping(struct extent_map_tree *tree,
463 return __lookup_extent_mapping(tree, start, len, 0);
467 * Remove an extent_map from its inode's extent tree.
472 * Remove @em from the extent tree of @inode. No reference counts are dropped,
477 struct extent_map_tree *tree = &inode->extent_tree;
479 lockdep_assert_held_write(&tree->lock);
482 rb_erase_cached(&em->rb_node, &tree->map);
495 struct extent_map_tree *tree = &inode->extent_tree;
497 lockdep_assert_held_write(&tree->lock);
503 rb_replace_node_cached(&cur->rb_node, &new->rb_node, &tree->map);
530 * Helper for btrfs_get_extent. Given an existing extent in the tree,
533 * the best fitted new extent into the tree.
573 * Add extent mapping into an inode's extent map tree.
583 * Insert @em_in into the inode's extent map tree. In case there is an
607 /* it is possible that someone inserted the extent into the tree
609 * an overlapping map exists in the tree
653 * Drop all extent maps from a tree in the fastest possible way, rescheduling
654 * if needed. This avoids searching the tree, from the root down to the first
659 struct extent_map_tree *tree = &inode->extent_tree;
661 write_lock(&tree->lock);
662 while (!RB_EMPTY_ROOT(&tree->map.rb_root)) {
666 node = rb_first_cached(&tree->map);
671 cond_resched_rwlock_write(&tree->lock);
673 write_unlock(&tree->lock);
688 * tree before calling this function.
856 * If the extent map is still in the tree it means that
869 * load it again from the subvolume tree's file extent
883 * Once for the tree reference (we replaced or removed the
884 * extent map from the tree).
901 * Replace a range in the inode's extent map tree with a new extent map.
904 * @new_em: The new extent map to add to the inode's extent map tree.
908 * Drops all the extent maps in the inode's extent map tree that intersect the
909 * range of the new extent map and adds the new extent map to the tree.
911 * tree before calling this function.
918 struct extent_map_tree *tree = &inode->extent_tree;
925 * tree, but getting -EEXIST when adding the new extent map can still
933 write_lock(&tree->lock);
935 write_unlock(&tree->lock);
1019 /* Once for the tree */
1034 struct extent_map_tree *tree = &inode->extent_tree;
1041 * in case we have to remove extent maps in the tree's list of modified
1045 * during inode logging it sees the flag set and uses the subvolume tree
1060 write_lock(&tree->lock);
1061 node = rb_first_cached(&tree->map);
1084 /* Drop the reference for the tree. */
1096 if (cond_resched_rwlock_write(&tree->lock))
1097 node = rb_first_cached(&tree->map);
1099 write_unlock(&tree->lock);