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()
205 struct tree_mod_elem *tm; in alloc_tree_mod_elem() local
207 tm = kzalloc(sizeof(*tm), GFP_NOFS); in alloc_tree_mod_elem()
208 if (!tm) in alloc_tree_mod_elem()
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()
216 tm->op = op; in alloc_tree_mod_elem()
217 tm->slot = slot; in alloc_tree_mod_elem()
218 tm->generation = btrfs_node_ptr_generation(eb, slot); in alloc_tree_mod_elem()
219 RB_CLEAR_NODE(&tm->node); in alloc_tree_mod_elem()
221 return tm; in alloc_tree_mod_elem()
227 struct tree_mod_elem *tm; in btrfs_tree_mod_log_insert_key() local
233 tm = alloc_tree_mod_elem(eb, slot, op); in btrfs_tree_mod_log_insert_key()
234 if (!tm) in btrfs_tree_mod_log_insert_key()
238 kfree(tm); in btrfs_tree_mod_log_insert_key()
252 ret = tree_mod_log_insert(eb->fs_info, tm); in btrfs_tree_mod_log_insert_key()
256 kfree(tm); in btrfs_tree_mod_log_insert_key()
265 struct tree_mod_elem *tm; in tree_mod_log_alloc_move() local
267 tm = kzalloc(sizeof(*tm), GFP_NOFS); in tree_mod_log_alloc_move()
268 if (!tm) in tree_mod_log_alloc_move()
271 tm->logical = eb->start; in tree_mod_log_alloc_move()
272 tm->slot = src_slot; in tree_mod_log_alloc_move()
273 tm->move.dst_slot = dst_slot; in tree_mod_log_alloc_move()
274 tm->move.nr_items = nr_items; in tree_mod_log_alloc_move()
275 tm->op = BTRFS_MOD_LOG_MOVE_KEYS; in tree_mod_log_alloc_move()
276 RB_CLEAR_NODE(&tm->node); in tree_mod_log_alloc_move()
278 return tm; in tree_mod_log_alloc_move()
285 struct tree_mod_elem *tm = NULL; in btrfs_tree_mod_log_insert_move() local
300 tm = tree_mod_log_alloc_move(eb, dst_slot, src_slot, nr_items); in btrfs_tree_mod_log_insert_move()
301 if (IS_ERR(tm)) { in btrfs_tree_mod_log_insert_move()
302 ret = PTR_ERR(tm); in btrfs_tree_mod_log_insert_move()
303 tm = NULL; in btrfs_tree_mod_log_insert_move()
345 ret = tree_mod_log_insert(eb->fs_info, tm); in btrfs_tree_mod_log_insert_move()
364 kfree(tm); in btrfs_tree_mod_log_insert_move()
394 struct tree_mod_elem *tm = NULL; in btrfs_tree_mod_log_insert_root() local
421 tm = kzalloc(sizeof(*tm), GFP_NOFS); in btrfs_tree_mod_log_insert_root()
422 if (!tm) { in btrfs_tree_mod_log_insert_root()
427 tm->logical = new_root->start; in btrfs_tree_mod_log_insert_root()
428 tm->old_root.logical = old_root->start; in btrfs_tree_mod_log_insert_root()
429 tm->old_root.level = btrfs_header_level(old_root); in btrfs_tree_mod_log_insert_root()
430 tm->generation = btrfs_header_generation(old_root); in btrfs_tree_mod_log_insert_root()
431 tm->op = BTRFS_MOD_LOG_ROOT_REPLACE; in btrfs_tree_mod_log_insert_root()
452 ret = tree_mod_log_insert(fs_info, tm); in btrfs_tree_mod_log_insert_root()
468 kfree(tm); in btrfs_tree_mod_log_insert_root()
737 struct tree_mod_elem *tm; in tree_mod_log_oldest_root() local
752 tm = tree_mod_log_search_oldest(eb_root->fs_info, root_logical, in tree_mod_log_oldest_root()
754 if (!looped && !tm) in tree_mod_log_oldest_root()
761 if (!tm) in tree_mod_log_oldest_root()
769 if (tm->op != BTRFS_MOD_LOG_ROOT_REPLACE) in tree_mod_log_oldest_root()
772 found = tm; in tree_mod_log_oldest_root()
773 root_logical = tm->old_root.logical; in tree_mod_log_oldest_root()
779 found = tm; in tree_mod_log_oldest_root()
786 * tm is a pointer to the first operation to rewind within eb. Then, all
797 struct tree_mod_elem *tm = first_tm; in tree_mod_log_rewind() local
820 while (tm && tm->seq >= time_seq) { in tree_mod_log_rewind()
827 switch (tm->op) { in tree_mod_log_rewind()
829 BUG_ON(tm->slot < n); 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()
836 tm->generation); in tree_mod_log_rewind()
838 if (tm->slot > max_slot) in tree_mod_log_rewind()
839 max_slot = tm->slot; in tree_mod_log_rewind()
842 BUG_ON(tm->slot >= n); 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()
846 tm->generation); in tree_mod_log_rewind()
858 if (tm->slot == max_slot) in tree_mod_log_rewind()
864 ASSERT(tm->move.nr_items > 0); 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()
870 tm->move.nr_items <= 0)) { in tree_mod_log_rewind()
873 eb->start, tm->slot, in tree_mod_log_rewind()
874 tm->move.dst_slot, tm->move.nr_items, in tree_mod_log_rewind()
875 tm->seq, n, max_slot); in tree_mod_log_rewind()
878 tm->move.nr_items * p_size); in tree_mod_log_rewind()
893 next = rb_next(&tm->node); in tree_mod_log_rewind()
896 tm = rb_entry(next, struct tree_mod_elem, node); in tree_mod_log_rewind()
897 if (tm->logical != first_tm->logical) in tree_mod_log_rewind()
917 struct tree_mod_elem *tm; in btrfs_tree_mod_log_rewind() local
925 tm = tree_mod_log_search(fs_info, eb->start, time_seq); in btrfs_tree_mod_log_rewind()
926 if (!tm) in btrfs_tree_mod_log_rewind()
929 if (tm->op == BTRFS_MOD_LOG_KEY_REMOVE_WHILE_FREEING) { in btrfs_tree_mod_log_rewind()
930 BUG_ON(tm->slot != 0); in btrfs_tree_mod_log_rewind()
957 tree_mod_log_rewind(fs_info, eb_rewin, time_seq, tm); in btrfs_tree_mod_log_rewind()
974 struct tree_mod_elem *tm; in btrfs_get_old_root() local
985 tm = tree_mod_log_oldest_root(eb_root, time_seq); in btrfs_get_old_root()
986 if (!tm) in btrfs_get_old_root()
989 if (tm->op == BTRFS_MOD_LOG_ROOT_REPLACE) { in btrfs_get_old_root()
990 old_root = &tm->old_root; in btrfs_get_old_root()
991 old_generation = tm->generation; in btrfs_get_old_root()
999 tm = tree_mod_log_search(fs_info, logical, time_seq); in btrfs_get_old_root()
1000 if (old_root && tm && tm->op != BTRFS_MOD_LOG_KEY_REMOVE_WHILE_FREEING) { in btrfs_get_old_root()
1035 ASSERT(tm2 == tm || tm2->seq > tm->seq); in btrfs_get_old_root()
1036 if (!tm2 || tm2->seq < tm->seq) { in btrfs_get_old_root()
1040 tm = tm2; in btrfs_get_old_root()
1065 if (tm) in btrfs_get_old_root()
1066 tree_mod_log_rewind(fs_info, eb, time_seq, tm); in btrfs_get_old_root()
1076 struct tree_mod_elem *tm; in btrfs_old_root_level() local
1080 tm = tree_mod_log_oldest_root(eb_root, time_seq); in btrfs_old_root_level()
1081 if (tm && tm->op == BTRFS_MOD_LOG_ROOT_REPLACE) in btrfs_old_root_level()
1082 level = tm->old_root.level; in btrfs_old_root_level()