Lines Matching refs: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()
243 ret = tree_mod_log_insert(eb->fs_info, tm); in btrfs_tree_mod_log_insert_key()
246 kfree(tm); in btrfs_tree_mod_log_insert_key()
255 struct tree_mod_elem *tm = NULL; in btrfs_tree_mod_log_insert_move() local
268 tm = kzalloc(sizeof(*tm), GFP_NOFS); in btrfs_tree_mod_log_insert_move()
269 if (!tm) { in btrfs_tree_mod_log_insert_move()
274 tm->logical = eb->start; in btrfs_tree_mod_log_insert_move()
275 tm->slot = src_slot; in btrfs_tree_mod_log_insert_move()
276 tm->move.dst_slot = dst_slot; in btrfs_tree_mod_log_insert_move()
277 tm->move.nr_items = nr_items; in btrfs_tree_mod_log_insert_move()
278 tm->op = BTRFS_MOD_LOG_MOVE_KEYS; in btrfs_tree_mod_log_insert_move()
304 ret = tree_mod_log_insert(eb->fs_info, tm); in btrfs_tree_mod_log_insert_move()
321 kfree(tm); in btrfs_tree_mod_log_insert_move()
351 struct tree_mod_elem *tm = NULL; in btrfs_tree_mod_log_insert_root() local
378 tm = kzalloc(sizeof(*tm), GFP_NOFS); in btrfs_tree_mod_log_insert_root()
379 if (!tm) { in btrfs_tree_mod_log_insert_root()
384 tm->logical = new_root->start; in btrfs_tree_mod_log_insert_root()
385 tm->old_root.logical = old_root->start; in btrfs_tree_mod_log_insert_root()
386 tm->old_root.level = btrfs_header_level(old_root); in btrfs_tree_mod_log_insert_root()
387 tm->generation = btrfs_header_generation(old_root); in btrfs_tree_mod_log_insert_root()
388 tm->op = BTRFS_MOD_LOG_ROOT_REPLACE; in btrfs_tree_mod_log_insert_root()
396 ret = tree_mod_log_insert(fs_info, tm); in btrfs_tree_mod_log_insert_root()
411 kfree(tm); in btrfs_tree_mod_log_insert_root()
603 struct tree_mod_elem *tm; in tree_mod_log_oldest_root() local
618 tm = tree_mod_log_search_oldest(eb_root->fs_info, root_logical, in tree_mod_log_oldest_root()
620 if (!looped && !tm) in tree_mod_log_oldest_root()
627 if (!tm) in tree_mod_log_oldest_root()
635 if (tm->op != BTRFS_MOD_LOG_ROOT_REPLACE) in tree_mod_log_oldest_root()
638 found = tm; in tree_mod_log_oldest_root()
639 root_logical = tm->old_root.logical; in tree_mod_log_oldest_root()
645 found = tm; in tree_mod_log_oldest_root()
663 struct tree_mod_elem *tm = first_tm; in tree_mod_log_rewind() local
670 while (tm && tm->seq >= time_seq) { in tree_mod_log_rewind()
676 switch (tm->op) { in tree_mod_log_rewind()
678 BUG_ON(tm->slot < n); in tree_mod_log_rewind()
682 btrfs_set_node_key(eb, &tm->key, tm->slot); in tree_mod_log_rewind()
683 btrfs_set_node_blockptr(eb, tm->slot, tm->blockptr); in tree_mod_log_rewind()
684 btrfs_set_node_ptr_generation(eb, tm->slot, in tree_mod_log_rewind()
685 tm->generation); in tree_mod_log_rewind()
689 BUG_ON(tm->slot >= n); in tree_mod_log_rewind()
690 btrfs_set_node_key(eb, &tm->key, tm->slot); in tree_mod_log_rewind()
691 btrfs_set_node_blockptr(eb, tm->slot, tm->blockptr); in tree_mod_log_rewind()
692 btrfs_set_node_ptr_generation(eb, tm->slot, in tree_mod_log_rewind()
693 tm->generation); in tree_mod_log_rewind()
700 o_dst = btrfs_node_key_ptr_offset(eb, tm->slot); in tree_mod_log_rewind()
701 o_src = btrfs_node_key_ptr_offset(eb, tm->move.dst_slot); in tree_mod_log_rewind()
703 tm->move.nr_items * p_size); in tree_mod_log_rewind()
717 next = rb_next(&tm->node); in tree_mod_log_rewind()
720 tm = rb_entry(next, struct tree_mod_elem, node); in tree_mod_log_rewind()
721 if (tm->logical != first_tm->logical) in tree_mod_log_rewind()
741 struct tree_mod_elem *tm; in btrfs_tree_mod_log_rewind() local
749 tm = tree_mod_log_search(fs_info, eb->start, time_seq); in btrfs_tree_mod_log_rewind()
750 if (!tm) in btrfs_tree_mod_log_rewind()
753 if (tm->op == BTRFS_MOD_LOG_KEY_REMOVE_WHILE_FREEING) { in btrfs_tree_mod_log_rewind()
754 BUG_ON(tm->slot != 0); in btrfs_tree_mod_log_rewind()
781 tree_mod_log_rewind(fs_info, eb_rewin, time_seq, tm); in btrfs_tree_mod_log_rewind()
798 struct tree_mod_elem *tm; in btrfs_get_old_root() local
809 tm = tree_mod_log_oldest_root(eb_root, time_seq); in btrfs_get_old_root()
810 if (!tm) in btrfs_get_old_root()
813 if (tm->op == BTRFS_MOD_LOG_ROOT_REPLACE) { in btrfs_get_old_root()
814 old_root = &tm->old_root; in btrfs_get_old_root()
815 old_generation = tm->generation; in btrfs_get_old_root()
823 tm = tree_mod_log_search(fs_info, logical, time_seq); in btrfs_get_old_root()
824 if (old_root && tm && tm->op != BTRFS_MOD_LOG_KEY_REMOVE_WHILE_FREEING) { in btrfs_get_old_root()
859 ASSERT(tm2 == tm || tm2->seq > tm->seq); in btrfs_get_old_root()
860 if (!tm2 || tm2->seq < tm->seq) { in btrfs_get_old_root()
864 tm = tm2; in btrfs_get_old_root()
889 if (tm) in btrfs_get_old_root()
890 tree_mod_log_rewind(fs_info, eb, time_seq, tm); in btrfs_get_old_root()
900 struct tree_mod_elem *tm; in btrfs_old_root_level() local
904 tm = tree_mod_log_oldest_root(eb_root, time_seq); in btrfs_old_root_level()
905 if (tm && tm->op == BTRFS_MOD_LOG_ROOT_REPLACE) in btrfs_old_root_level()
906 level = tm->old_root.level; in btrfs_old_root_level()