Lines Matching defs:tree

199 	struct ocfs2_refcount_tree *tree = NULL;
202 tree = rb_entry(n, struct ocfs2_refcount_tree, rf_node);
204 if (blkno < tree->rf_blkno)
206 else if (blkno > tree->rf_blkno)
209 return tree;
246 static void ocfs2_free_refcount_tree(struct ocfs2_refcount_tree *tree)
248 ocfs2_metadata_cache_exit(&tree->rf_ci);
249 ocfs2_simple_drop_lockres(OCFS2_SB(tree->rf_sb), &tree->rf_lockres);
250 ocfs2_lock_res_free(&tree->rf_lockres);
251 kfree(tree);
256 struct ocfs2_refcount_tree *tree)
258 rb_erase(&tree->rf_node, &osb->osb_rf_lock_tree);
259 if (osb->osb_ref_tree_lru && osb->osb_ref_tree_lru == tree)
264 struct ocfs2_refcount_tree *tree)
267 ocfs2_erase_refcount_tree_from_list_no_lock(osb, tree);
273 struct ocfs2_refcount_tree *tree =
276 ocfs2_free_refcount_tree(tree);
280 ocfs2_refcount_tree_get(struct ocfs2_refcount_tree *tree)
282 kref_get(&tree->rf_getcnt);
286 ocfs2_refcount_tree_put(struct ocfs2_refcount_tree *tree)
288 kref_put(&tree->rf_getcnt, ocfs2_kref_remove_refcount_tree);
329 struct ocfs2_refcount_tree *tree, *new = NULL;
336 tree = osb->osb_ref_tree_lru;
338 tree = ocfs2_find_refcount_tree(osb, rf_blkno);
339 if (tree)
351 * We need the generation to create the refcount tree lock and since
352 * it isn't changed during the tree modification, we are safe here to
373 tree = ocfs2_find_refcount_tree(osb, rf_blkno);
374 if (tree)
379 tree = new;
383 *ret_tree = tree;
385 osb->osb_ref_tree_lru = tree;
418 struct ocfs2_refcount_tree *tree, int rw)
422 ret = ocfs2_refcount_lock(tree, rw);
429 down_write(&tree->rf_sem);
431 down_read(&tree->rf_sem);
438 * Lock the refcount tree pointed by ref_blkno and return the tree.
439 * In most case, we lock the tree and read the refcount block.
442 * If the tree has been re-created by other node, it will free the
451 struct ocfs2_refcount_tree *tree = NULL;
456 ret = ocfs2_get_refcount_tree(osb, ref_blkno, &tree);
462 ocfs2_refcount_tree_get(tree);
464 ret = __ocfs2_lock_refcount_tree(osb, tree, rw);
467 ocfs2_refcount_tree_put(tree);
471 ret = ocfs2_read_refcount_block(&tree->rf_ci, tree->rf_blkno,
475 ocfs2_unlock_refcount_tree(osb, tree, rw);
482 * to recreate the refcount tree also.
484 * Here we just remove the tree from the rb-tree, and the last
487 * the new refcount tree for us.
489 if (tree->rf_generation != le32_to_cpu(rb->rf_generation)) {
490 if (!tree->rf_removed) {
491 ocfs2_erase_refcount_tree_from_list(osb, tree);
492 tree->rf_removed = 1;
496 ocfs2_unlock_refcount_tree(osb, tree, rw);
499 * tree, so another put will destroy it.
502 ocfs2_refcount_tree_put(tree);
508 *ret_tree = tree;
519 struct ocfs2_refcount_tree *tree, int rw)
522 up_write(&tree->rf_sem);
524 up_read(&tree->rf_sem);
526 ocfs2_refcount_unlock(tree, rw);
527 ocfs2_refcount_tree_put(tree);
533 struct ocfs2_refcount_tree *tree;
537 tree = rb_entry(node, struct ocfs2_refcount_tree, rf_node);
540 (unsigned long long) tree->rf_blkno);
542 rb_erase(&tree->rf_node, root);
543 ocfs2_free_refcount_tree(tree);
548 * Create a refcount tree for an inode.
562 struct ocfs2_refcount_tree *new_tree = NULL, *tree = NULL;
651 * We have to init the tree lock here since it will use
659 tree = ocfs2_find_refcount_tree(osb, first_blkno);
662 * We've just created a new refcount tree in this block. If
663 * we found a refcount tree on the ocfs2_super, it must be
664 * one we just deleted. We free the old tree before
665 * inserting the new tree.
667 BUG_ON(tree && tree->rf_generation == new_tree->rf_generation);
668 if (tree)
669 ocfs2_erase_refcount_tree_from_list_no_lock(osb, tree);
673 if (tree)
674 ocfs2_refcount_tree_put(tree);
919 * Try to remove refcount tree. The mechanism is:
923 * 4) Remove the tree.
994 * the subroot. Otherwise we may corrupt the b-tree.
1098 "refcount tree %llu has non zero tree depth in leaf btree tree block %llu\n",
1406 * But we will use the low 32 bit to be the e_cpos in the b-tree.
1621 * the old root bh hasn't been expanded to a b-tree,
1636 /* Now add a new refcount block into the tree.*/
1647 * Adjust the extent rec in b-tree representing ref_leaf_bh.
1817 * This is much simple than our b-tree code.
2287 /* Caller must hold refcount tree lock. */
2297 struct ocfs2_refcount_tree *tree;
2307 ret = ocfs2_get_refcount_tree(OCFS2_SB(inode->i_sb), ref_blkno, &tree);
2313 ret = ocfs2_read_refcount_block(&tree->rf_ci, tree->rf_blkno,
2320 ret = __ocfs2_decrease_refcount(handle, &tree->rf_ci, ref_root_bh,
2351 ret = ocfs2_error(inode->i_sb, "Inode %lu want to use refcount tree, but the feature bit is not set in the super block\n",
2480 * So we may need ref_blocks to insert into the tree.
2481 * That also means we need to change the b-tree and add that number
2510 * For refcount tree, we will decrease some contiguous clusters
2519 * Caller must hold refcount tree lock.
2530 struct ocfs2_refcount_tree *tree;
2534 ret = ocfs2_error(inode->i_sb, "Inode %lu want to use refcount tree, but the feature bit is not set in the super block\n",
2542 refcount_loc, &tree);
2548 ret = ocfs2_read_refcount_block(&tree->rf_ci, refcount_loc,
2556 &tree->rf_ci,
2627 * get good I/O from the resulting extent tree.
2660 "Inode %lu has non zero tree depth in leaf block %llu\n",
2830 * clusters(starting form p_cluster) in the refcount tree.
2833 * 1. since we may split the old tree, so we at most will need num_clusters + 2
3365 return ocfs2_error(inode->i_sb, "Inode %lu want to use refcount tree, but the feature bit is not set in the super block\n",
3535 * refcount tree change if we truncate it to 0.
3680 * Insert a new extent into refcount tree and mark a extent rec
3681 * as refcounted in the dinode tree.
3697 /* We need to be able to handle at least an extent tree split. */
4615 /* Set up refcount tree and remap s_inode to t_inode. */
4660 /* Neither inode has a refcount tree. Add one to s_inode. */
4670 /* Ensure that both inodes end up with the same refcount tree. */