Lines Matching +full:1 +full:eb
173 static bool tree_mod_dont_log(struct btrfs_fs_info *fs_info, const struct extent_buffer *eb) in tree_mod_dont_log() argument
177 if (eb && btrfs_header_level(eb) == 0) in tree_mod_dont_log()
191 const struct extent_buffer *eb) in tree_mod_need_log() argument
195 if (eb && btrfs_header_level(eb) == 0) in tree_mod_need_log()
201 static struct tree_mod_elem *alloc_tree_mod_elem(const struct extent_buffer *eb, in alloc_tree_mod_elem() argument
211 tm->logical = eb->start; in alloc_tree_mod_elem()
213 btrfs_node_key(eb, &tm->key, slot); in alloc_tree_mod_elem()
214 tm->blockptr = btrfs_node_blockptr(eb, slot); in alloc_tree_mod_elem()
218 tm->generation = btrfs_node_ptr_generation(eb, slot); in alloc_tree_mod_elem()
224 int btrfs_tree_mod_log_insert_key(const struct extent_buffer *eb, int slot, in btrfs_tree_mod_log_insert_key() argument
230 if (!tree_mod_need_log(eb->fs_info, eb)) in btrfs_tree_mod_log_insert_key()
233 tm = alloc_tree_mod_elem(eb, slot, op); in btrfs_tree_mod_log_insert_key()
237 if (tree_mod_dont_log(eb->fs_info, eb)) { in btrfs_tree_mod_log_insert_key()
252 ret = tree_mod_log_insert(eb->fs_info, tm); in btrfs_tree_mod_log_insert_key()
254 write_unlock(&eb->fs_info->tree_mod_log_lock); in btrfs_tree_mod_log_insert_key()
261 static struct tree_mod_elem *tree_mod_log_alloc_move(const struct extent_buffer *eb, in tree_mod_log_alloc_move() argument
271 tm->logical = eb->start; in tree_mod_log_alloc_move()
281 int btrfs_tree_mod_log_insert_move(const struct extent_buffer *eb, in btrfs_tree_mod_log_insert_move() argument
291 if (!tree_mod_need_log(eb->fs_info, eb)) in btrfs_tree_mod_log_insert_move()
300 tm = tree_mod_log_alloc_move(eb, dst_slot, src_slot, nr_items); in btrfs_tree_mod_log_insert_move()
308 tm_list[i] = alloc_tree_mod_elem(eb, i + dst_slot, in btrfs_tree_mod_log_insert_move()
317 if (tree_mod_dont_log(eb->fs_info, eb)) { in btrfs_tree_mod_log_insert_move()
340 ret = tree_mod_log_insert(eb->fs_info, tm_list[i]); in btrfs_tree_mod_log_insert_move()
345 ret = tree_mod_log_insert(eb->fs_info, tm); in btrfs_tree_mod_log_insert_move()
348 write_unlock(&eb->fs_info->tree_mod_log_lock); in btrfs_tree_mod_log_insert_move()
357 rb_erase(&tm_list[i]->node, &eb->fs_info->tree_mod_log); in btrfs_tree_mod_log_insert_move()
362 write_unlock(&eb->fs_info->tree_mod_log_lock); in btrfs_tree_mod_log_insert_move()
376 for (i = nritems - 1; i >= 0; i--) { in tree_mod_log_free_eb()
379 for (j = nritems - 1; j > i; j--) in tree_mod_log_free_eb()
669 int btrfs_tree_mod_log_free_eb(struct extent_buffer *eb) in btrfs_tree_mod_log_free_eb() argument
676 if (!tree_mod_need_log(eb->fs_info, eb)) in btrfs_tree_mod_log_free_eb()
679 nritems = btrfs_header_nritems(eb); in btrfs_tree_mod_log_free_eb()
687 tm_list[i] = alloc_tree_mod_elem(eb, i, in btrfs_tree_mod_log_free_eb()
696 if (tree_mod_dont_log(eb->fs_info, eb)) { in btrfs_tree_mod_log_free_eb()
711 ret = tree_mod_log_free_eb(eb->fs_info, tm_list, nritems); in btrfs_tree_mod_log_free_eb()
713 write_unlock(&eb->fs_info->tree_mod_log_lock); in btrfs_tree_mod_log_free_eb()
751 while (1) { in tree_mod_log_oldest_root()
786 * tm is a pointer to the first operation to rewind within eb. Then, all
791 struct extent_buffer *eb, in tree_mod_log_rewind() argument
802 * max_slot tracks the maximum valid slot of the rewind eb at every in tree_mod_log_rewind()
809 * Since a rewind eb can start empty, max_slot is a signed integer with in tree_mod_log_rewind()
810 * a special meaning for -1, which is that no slot is valid to move out in tree_mod_log_rewind()
817 n = btrfs_header_nritems(eb); in tree_mod_log_rewind()
818 max_slot = n - 1; in tree_mod_log_rewind()
821 ASSERT(max_slot >= -1); in tree_mod_log_rewind()
833 btrfs_set_node_key(eb, &tm->key, tm->slot); in tree_mod_log_rewind()
834 btrfs_set_node_blockptr(eb, tm->slot, tm->blockptr); in tree_mod_log_rewind()
835 btrfs_set_node_ptr_generation(eb, tm->slot, in tree_mod_log_rewind()
843 btrfs_set_node_key(eb, &tm->key, tm->slot); in tree_mod_log_rewind()
844 btrfs_set_node_blockptr(eb, tm->slot, tm->blockptr); in tree_mod_log_rewind()
845 btrfs_set_node_ptr_generation(eb, tm->slot, in tree_mod_log_rewind()
865 move_src_end_slot = tm->move.dst_slot + tm->move.nr_items - 1; in tree_mod_log_rewind()
866 move_dst_end_slot = tm->slot + tm->move.nr_items - 1; in tree_mod_log_rewind()
867 o_dst = btrfs_node_key_ptr_offset(eb, tm->slot); in tree_mod_log_rewind()
868 o_src = btrfs_node_key_ptr_offset(eb, tm->move.dst_slot); in tree_mod_log_rewind()
872 "move from invalid tree mod log slot eb %llu slot %d dst_slot %d nr_items %d seq %llu n %u max_slot… in tree_mod_log_rewind()
873 eb->start, tm->slot, in tree_mod_log_rewind()
877 memmove_extent_buffer(eb, o_dst, o_src, in tree_mod_log_rewind()
901 btrfs_set_header_nritems(eb, n); in tree_mod_log_rewind()
905 * Called with eb read locked. If the buffer cannot be rewound, the same buffer
913 struct extent_buffer *eb, in btrfs_tree_mod_log_rewind() argument
920 return eb; in btrfs_tree_mod_log_rewind()
922 if (btrfs_header_level(eb) == 0) in btrfs_tree_mod_log_rewind()
923 return eb; in btrfs_tree_mod_log_rewind()
925 tm = tree_mod_log_search(fs_info, eb->start, time_seq); in btrfs_tree_mod_log_rewind()
927 return eb; in btrfs_tree_mod_log_rewind()
931 eb_rewin = alloc_dummy_extent_buffer(fs_info, eb->start); in btrfs_tree_mod_log_rewind()
933 btrfs_tree_read_unlock(eb); in btrfs_tree_mod_log_rewind()
934 free_extent_buffer(eb); in btrfs_tree_mod_log_rewind()
937 btrfs_set_header_bytenr(eb_rewin, eb->start); in btrfs_tree_mod_log_rewind()
939 btrfs_header_backref_rev(eb)); in btrfs_tree_mod_log_rewind()
940 btrfs_set_header_owner(eb_rewin, btrfs_header_owner(eb)); in btrfs_tree_mod_log_rewind()
941 btrfs_set_header_level(eb_rewin, btrfs_header_level(eb)); in btrfs_tree_mod_log_rewind()
943 eb_rewin = btrfs_clone_extent_buffer(eb); in btrfs_tree_mod_log_rewind()
945 btrfs_tree_read_unlock(eb); in btrfs_tree_mod_log_rewind()
946 free_extent_buffer(eb); in btrfs_tree_mod_log_rewind()
951 btrfs_tree_read_unlock(eb); in btrfs_tree_mod_log_rewind()
952 free_extent_buffer(eb); in btrfs_tree_mod_log_rewind()
975 struct extent_buffer *eb = NULL; in btrfs_get_old_root() local
1020 eb = btrfs_clone_extent_buffer(old); in btrfs_get_old_root()
1037 free_extent_buffer(eb); in btrfs_get_old_root()
1046 eb = alloc_dummy_extent_buffer(fs_info, logical); in btrfs_get_old_root()
1048 eb = btrfs_clone_extent_buffer(eb_root); in btrfs_get_old_root()
1053 if (!eb) in btrfs_get_old_root()
1056 btrfs_set_header_bytenr(eb, eb->start); in btrfs_get_old_root()
1057 btrfs_set_header_backref_rev(eb, BTRFS_MIXED_BACKREF_REV); in btrfs_get_old_root()
1058 btrfs_set_header_owner(eb, eb_root_owner); in btrfs_get_old_root()
1059 btrfs_set_header_level(eb, old_root->level); in btrfs_get_old_root()
1060 btrfs_set_header_generation(eb, old_generation); in btrfs_get_old_root()
1062 btrfs_set_buffer_lockdep_class(btrfs_header_owner(eb), eb, in btrfs_get_old_root()
1063 btrfs_header_level(eb)); in btrfs_get_old_root()
1064 btrfs_tree_read_lock(eb); in btrfs_get_old_root()
1066 tree_mod_log_rewind(fs_info, eb, time_seq, tm); in btrfs_get_old_root()
1068 WARN_ON(btrfs_header_level(eb) != 0); in btrfs_get_old_root()
1069 WARN_ON(btrfs_header_nritems(eb) > BTRFS_NODEPTRS_PER_BLOCK(fs_info)); in btrfs_get_old_root()
1071 return eb; in btrfs_get_old_root()