Lines Matching full:tm
80 struct tree_mod_elem *tm; in btrfs_put_tree_mod_seq() local
116 tm = rb_entry(node, struct tree_mod_elem, node); in btrfs_put_tree_mod_seq()
117 if (tm->seq >= min_seq) in btrfs_put_tree_mod_seq()
120 kfree(tm); in btrfs_put_tree_mod_seq()
134 struct tree_mod_elem *tm) in tree_mod_log_insert() argument
143 tm->seq = btrfs_inc_tree_mod_seq(fs_info); in tree_mod_log_insert()
150 if (cur->logical < tm->logical) in tree_mod_log_insert()
152 else if (cur->logical > tm->logical) in tree_mod_log_insert()
154 else if (cur->seq < tm->seq) in tree_mod_log_insert()
156 else if (cur->seq > tm->seq) in tree_mod_log_insert()
162 rb_link_node(&tm->node, parent, new); in tree_mod_log_insert()
163 rb_insert_color(&tm->node, tm_root); in tree_mod_log_insert()
206 struct tree_mod_elem *tm; in alloc_tree_mod_elem() local
208 tm = kzalloc(sizeof(*tm), GFP_NOFS); in alloc_tree_mod_elem()
209 if (!tm) in alloc_tree_mod_elem()
212 tm->logical = eb->start; in alloc_tree_mod_elem()
214 btrfs_node_key(eb, &tm->key, slot); in alloc_tree_mod_elem()
215 tm->blockptr = btrfs_node_blockptr(eb, slot); in alloc_tree_mod_elem()
217 tm->op = op; in alloc_tree_mod_elem()
218 tm->slot = slot; in alloc_tree_mod_elem()
219 tm->generation = btrfs_node_ptr_generation(eb, slot); in alloc_tree_mod_elem()
220 RB_CLEAR_NODE(&tm->node); in alloc_tree_mod_elem()
222 return tm; in alloc_tree_mod_elem()
228 struct tree_mod_elem *tm; in btrfs_tree_mod_log_insert_key() local
234 tm = alloc_tree_mod_elem(eb, slot, op); in btrfs_tree_mod_log_insert_key()
235 if (!tm) in btrfs_tree_mod_log_insert_key()
239 kfree(tm); in btrfs_tree_mod_log_insert_key()
253 ret = tree_mod_log_insert(eb->fs_info, tm); in btrfs_tree_mod_log_insert_key()
257 kfree(tm); in btrfs_tree_mod_log_insert_key()
266 struct tree_mod_elem *tm; in tree_mod_log_alloc_move() local
268 tm = kzalloc(sizeof(*tm), GFP_NOFS); in tree_mod_log_alloc_move()
269 if (!tm) in tree_mod_log_alloc_move()
272 tm->logical = eb->start; in tree_mod_log_alloc_move()
273 tm->slot = src_slot; in tree_mod_log_alloc_move()
274 tm->move.dst_slot = dst_slot; in tree_mod_log_alloc_move()
275 tm->move.nr_items = nr_items; in tree_mod_log_alloc_move()
276 tm->op = BTRFS_MOD_LOG_MOVE_KEYS; in tree_mod_log_alloc_move()
277 RB_CLEAR_NODE(&tm->node); in tree_mod_log_alloc_move()
279 return tm; in tree_mod_log_alloc_move()
286 struct tree_mod_elem *tm = NULL; in btrfs_tree_mod_log_insert_move() local
301 tm = tree_mod_log_alloc_move(eb, dst_slot, src_slot, nr_items); in btrfs_tree_mod_log_insert_move()
302 if (IS_ERR(tm)) { in btrfs_tree_mod_log_insert_move()
303 ret = PTR_ERR(tm); in btrfs_tree_mod_log_insert_move()
304 tm = NULL; in btrfs_tree_mod_log_insert_move()
346 ret = tree_mod_log_insert(eb->fs_info, tm); in btrfs_tree_mod_log_insert_move()
365 kfree(tm); in btrfs_tree_mod_log_insert_move()
395 struct tree_mod_elem *tm = NULL; in btrfs_tree_mod_log_insert_root() local
422 tm = kzalloc(sizeof(*tm), GFP_NOFS); in btrfs_tree_mod_log_insert_root()
423 if (!tm) { in btrfs_tree_mod_log_insert_root()
428 tm->logical = new_root->start; in btrfs_tree_mod_log_insert_root()
429 tm->old_root.logical = old_root->start; in btrfs_tree_mod_log_insert_root()
430 tm->old_root.level = btrfs_header_level(old_root); in btrfs_tree_mod_log_insert_root()
431 tm->generation = btrfs_header_generation(old_root); in btrfs_tree_mod_log_insert_root()
432 tm->op = BTRFS_MOD_LOG_ROOT_REPLACE; in btrfs_tree_mod_log_insert_root()
453 ret = tree_mod_log_insert(fs_info, tm); in btrfs_tree_mod_log_insert_root()
469 kfree(tm); in btrfs_tree_mod_log_insert_root()
738 struct tree_mod_elem *tm; in tree_mod_log_oldest_root() local
753 tm = tree_mod_log_search_oldest(eb_root->fs_info, root_logical, in tree_mod_log_oldest_root()
755 if (!looped && !tm) in tree_mod_log_oldest_root()
762 if (!tm) in tree_mod_log_oldest_root()
770 if (tm->op != BTRFS_MOD_LOG_ROOT_REPLACE) in tree_mod_log_oldest_root()
773 found = tm; in tree_mod_log_oldest_root()
774 root_logical = tm->old_root.logical; in tree_mod_log_oldest_root()
780 found = tm; in tree_mod_log_oldest_root()
787 * tm is a pointer to the first operation to rewind within eb. Then, all
798 struct tree_mod_elem *tm = first_tm; in tree_mod_log_rewind() local
821 while (tm && tm->seq >= time_seq) { in tree_mod_log_rewind()
828 switch (tm->op) { in tree_mod_log_rewind()
830 BUG_ON(tm->slot < n); in tree_mod_log_rewind()
834 btrfs_set_node_key(eb, &tm->key, tm->slot); in tree_mod_log_rewind()
835 btrfs_set_node_blockptr(eb, tm->slot, tm->blockptr); in tree_mod_log_rewind()
836 btrfs_set_node_ptr_generation(eb, tm->slot, in tree_mod_log_rewind()
837 tm->generation); in tree_mod_log_rewind()
839 if (tm->slot > max_slot) in tree_mod_log_rewind()
840 max_slot = tm->slot; in tree_mod_log_rewind()
843 BUG_ON(tm->slot >= n); in tree_mod_log_rewind()
844 btrfs_set_node_key(eb, &tm->key, tm->slot); in tree_mod_log_rewind()
845 btrfs_set_node_blockptr(eb, tm->slot, tm->blockptr); in tree_mod_log_rewind()
846 btrfs_set_node_ptr_generation(eb, tm->slot, in tree_mod_log_rewind()
847 tm->generation); in tree_mod_log_rewind()
859 if (tm->slot == max_slot) in tree_mod_log_rewind()
865 ASSERT(tm->move.nr_items > 0); in tree_mod_log_rewind()
866 move_src_end_slot = tm->move.dst_slot + tm->move.nr_items - 1; in tree_mod_log_rewind()
867 move_dst_end_slot = tm->slot + tm->move.nr_items - 1; in tree_mod_log_rewind()
868 o_dst = btrfs_node_key_ptr_offset(eb, tm->slot); in tree_mod_log_rewind()
869 o_src = btrfs_node_key_ptr_offset(eb, tm->move.dst_slot); in tree_mod_log_rewind()
871 tm->move.nr_items <= 0)) { in tree_mod_log_rewind()
874 eb->start, tm->slot, in tree_mod_log_rewind()
875 tm->move.dst_slot, tm->move.nr_items, in tree_mod_log_rewind()
876 tm->seq, n, max_slot); in tree_mod_log_rewind()
879 tm->move.nr_items * p_size); in tree_mod_log_rewind()
894 next = rb_next(&tm->node); in tree_mod_log_rewind()
897 tm = rb_entry(next, struct tree_mod_elem, node); in tree_mod_log_rewind()
898 if (tm->logical != first_tm->logical) in tree_mod_log_rewind()
918 struct tree_mod_elem *tm; in btrfs_tree_mod_log_rewind() local
926 tm = tree_mod_log_search(fs_info, eb->start, time_seq); in btrfs_tree_mod_log_rewind()
927 if (!tm) in btrfs_tree_mod_log_rewind()
930 if (tm->op == BTRFS_MOD_LOG_KEY_REMOVE_WHILE_FREEING) { in btrfs_tree_mod_log_rewind()
931 BUG_ON(tm->slot != 0); in btrfs_tree_mod_log_rewind()
958 tree_mod_log_rewind(fs_info, eb_rewin, time_seq, tm); in btrfs_tree_mod_log_rewind()
975 struct tree_mod_elem *tm; in btrfs_get_old_root() local
986 tm = tree_mod_log_oldest_root(eb_root, time_seq); in btrfs_get_old_root()
987 if (!tm) in btrfs_get_old_root()
990 if (tm->op == BTRFS_MOD_LOG_ROOT_REPLACE) { in btrfs_get_old_root()
991 old_root = &tm->old_root; in btrfs_get_old_root()
992 old_generation = tm->generation; in btrfs_get_old_root()
1000 tm = tree_mod_log_search(fs_info, logical, time_seq); in btrfs_get_old_root()
1001 if (old_root && tm && tm->op != BTRFS_MOD_LOG_KEY_REMOVE_WHILE_FREEING) { in btrfs_get_old_root()
1036 ASSERT(tm2 == tm || tm2->seq > tm->seq); in btrfs_get_old_root()
1037 if (!tm2 || tm2->seq < tm->seq) { in btrfs_get_old_root()
1041 tm = tm2; in btrfs_get_old_root()
1066 if (tm) in btrfs_get_old_root()
1067 tree_mod_log_rewind(fs_info, eb, time_seq, tm); in btrfs_get_old_root()
1077 struct tree_mod_elem *tm; in btrfs_old_root_level() local
1081 tm = tree_mod_log_oldest_root(eb_root, time_seq); in btrfs_old_root_level()
1082 if (tm && tm->op == BTRFS_MOD_LOG_ROOT_REPLACE) in btrfs_old_root_level()
1083 level = tm->old_root.level; in btrfs_old_root_level()