Lines Matching +full:cache +full:- +full:block

1 /* SPDX-License-Identifier: GPL-2.0 */
12 #include "disk-io.h"
18 * The value must be non-negative and must not be 0, 1 (which is a common return
27 * continue. Can return BTRFS_ITERATE_EXTENT_INODES_STOP or any other non-zero
82 * commit roots when searching b+trees - this is a special case for
100 * cache which maps the logical address (bytenr) of leaves to an array
175 * Cache the sharedness result for the last few extents we have found,
183 * So keep a small cache with the lookup results for the extent pointed
184 * by the last few file extent items. This cache is checked, with a
260 * Now it only supports iteration of tree block in commit root.
278 btrfs_free_path(iter->path); in btrfs_backref_iter_free()
287 return iter->path->nodes[0]; in btrfs_backref_get_eb()
291 * For metadata with EXTENT_ITEM key (non-skinny) case, the first inline data
299 if (iter->cur_key.type == BTRFS_EXTENT_ITEM_KEY && in btrfs_backref_has_tree_block_info()
300 iter->cur_ptr - iter->item_ptr == sizeof(struct btrfs_extent_item)) in btrfs_backref_has_tree_block_info()
312 if (iter->cur_key.type == BTRFS_EXTENT_ITEM_KEY || in btrfs_backref_iter_is_inline_ref()
313 iter->cur_key.type == BTRFS_METADATA_ITEM_KEY) in btrfs_backref_iter_is_inline_ref()
320 iter->bytenr = 0; in btrfs_backref_iter_release()
321 iter->item_ptr = 0; in btrfs_backref_iter_release()
322 iter->cur_ptr = 0; in btrfs_backref_iter_release()
323 iter->end_ptr = 0; in btrfs_backref_iter_release()
324 btrfs_release_path(iter->path); in btrfs_backref_iter_release()
325 memset(&iter->cur_key, 0, sizeof(iter->cur_key)); in btrfs_backref_iter_release()
329 * Backref cache related structures
331 * The whole objective of backref_cache is to build a bi-directional map
336 * Represent a tree block in the backref cache
345 /* Objectid of tree block owner, can be not uptodate */
357 /* Extent buffer got by COWing the block */
359 /* Level of the tree block */
361 /* Is the block in a non-shareable tree */
363 /* 1 if no child node is in the cache */
367 /* Has the block been processed */
369 /* Have backrefs of this block been checked */
372 * 1 if corresponding block has been COWed but some upper level block
380 * For generic purpose backref cache, where we only care if it's a reloc
408 /* Red black tree of all backref nodes in the cache */
413 * List of blocks that have been COWed but some block pointers in upper
429 /* List of unchecked backref edges during backref cache build */
432 /* List of useless backref nodes during backref cache build */
438 * Whether this cache is for relocation
440 * Reloction backref cache require more info for reloc root compared
441 * to generic backref cache.
447 struct btrfs_backref_cache *cache, bool is_reloc);
449 struct btrfs_backref_cache *cache, u64 bytenr, int level);
451 struct btrfs_backref_cache *cache);
460 ASSERT(upper && lower && upper->level == lower->level + 1); in btrfs_backref_link_edge()
461 edge->node[LOWER] = lower; in btrfs_backref_link_edge()
462 edge->node[UPPER] = upper; in btrfs_backref_link_edge()
464 list_add_tail(&edge->list[LOWER], &lower->upper); in btrfs_backref_link_edge()
466 list_add_tail(&edge->list[UPPER], &upper->lower); in btrfs_backref_link_edge()
469 static inline void btrfs_backref_free_node(struct btrfs_backref_cache *cache, in btrfs_backref_free_node() argument
473 ASSERT(list_empty(&node->list)); in btrfs_backref_free_node()
474 ASSERT(list_empty(&node->lower)); in btrfs_backref_free_node()
475 ASSERT(node->eb == NULL); in btrfs_backref_free_node()
476 cache->nr_nodes--; in btrfs_backref_free_node()
477 btrfs_put_root(node->root); in btrfs_backref_free_node()
482 static inline void btrfs_backref_free_edge(struct btrfs_backref_cache *cache, in btrfs_backref_free_edge() argument
486 cache->nr_edges--; in btrfs_backref_free_edge()
494 if (node->locked) { in btrfs_backref_unlock_node_buffer()
495 btrfs_tree_unlock(node->eb); in btrfs_backref_unlock_node_buffer()
496 node->locked = 0; in btrfs_backref_unlock_node_buffer()
503 if (node->eb) { in btrfs_backref_drop_node_buffer()
505 free_extent_buffer(node->eb); in btrfs_backref_drop_node_buffer()
506 node->eb = NULL; in btrfs_backref_drop_node_buffer()
511 * Drop the backref node from cache without cleaning up its children
520 ASSERT(list_empty(&node->upper)); in btrfs_backref_drop_node()
523 list_del_init(&node->list); in btrfs_backref_drop_node()
524 list_del_init(&node->lower); in btrfs_backref_drop_node()
525 if (!RB_EMPTY_NODE(&node->rb_node)) in btrfs_backref_drop_node()
526 rb_erase(&node->rb_node, &tree->rb_root); in btrfs_backref_drop_node()
530 void btrfs_backref_cleanup_node(struct btrfs_backref_cache *cache,
533 void btrfs_backref_release_cache(struct btrfs_backref_cache *cache);
539 "Inconsistency in backref cache found at offset %llu", in btrfs_backref_panic()
544 struct btrfs_backref_cache *cache,
550 int btrfs_backref_finish_upper_links(struct btrfs_backref_cache *cache,
553 void btrfs_backref_error_cleanup(struct btrfs_backref_cache *cache,