/* * look for an offset in the tree, and if it can't be found, return * the first offset we can find smaller than 'offset'. */ static inline struct rb_node *tree_search(struct rb_root *root, u64 offset) { struct rb_node *prev; struct rb_node *ret; ret = __tree_search(root, offset, &prev, NULL); if (!ret) return prev; return ret; }
rbtree_node_t * rbtree_node_get (rbtree_t *T, PyObject *key) { rbtree_node_t *x; int rc; x = __tree_search(T, T->root, key, &rc); return (rc != 0) ? NULL : x; }
static int __rb_del (rbtree_t *T, PyObject *k) { rbtree_node_t *z; int rc; z = __tree_search(T, T->root, k, &rc); if (rc == 0) { __rb_del_node(T, z); return 0; } return 1; }
*/ static inline struct rb_node *tree_search(struct btrfs_ordered_inode_tree *tree, u64 file_offset) { struct rb_root *root = &tree->tree; struct rb_node *prev = NULL; struct rb_node *ret; struct btrfs_ordered_extent *entry; if (tree->last) { entry = rb_entry(tree->last, struct btrfs_ordered_extent, rb_node); if (offset_in_entry(entry, file_offset)) return tree->last; } ret = __tree_search(root, file_offset, &prev); if (!ret) ret = prev; if (ret) tree->last = ret; return ret; } /* allocate and add a new ordered_extent into the per-inode tree. * file_offset is the logical offset in the file * * start is the disk block number of an extent already reserved in the * extent allocation tree * * len is the length of the extent *