Lines Matching refs:ifp
132 inline xfs_extnum_t xfs_iext_count(struct xfs_ifork *ifp) in xfs_iext_count() argument
134 return ifp->if_bytes / sizeof(struct xfs_iext_rec); in xfs_iext_count()
137 static inline int xfs_iext_max_recs(struct xfs_ifork *ifp) in xfs_iext_max_recs() argument
139 if (ifp->if_height == 1) in xfs_iext_max_recs()
140 return xfs_iext_count(ifp); in xfs_iext_max_recs()
149 static inline bool xfs_iext_valid(struct xfs_ifork *ifp, in xfs_iext_valid() argument
154 if (cur->pos < 0 || cur->pos >= xfs_iext_max_recs(ifp)) in xfs_iext_valid()
163 struct xfs_ifork *ifp) in xfs_iext_find_first_leaf() argument
165 struct xfs_iext_node *node = ifp->if_u1.if_root; in xfs_iext_find_first_leaf()
168 if (!ifp->if_height) in xfs_iext_find_first_leaf()
171 for (height = ifp->if_height; height > 1; height--) { in xfs_iext_find_first_leaf()
181 struct xfs_ifork *ifp) in xfs_iext_find_last_leaf() argument
183 struct xfs_iext_node *node = ifp->if_u1.if_root; in xfs_iext_find_last_leaf()
186 if (!ifp->if_height) in xfs_iext_find_last_leaf()
189 for (height = ifp->if_height; height > 1; height--) { in xfs_iext_find_last_leaf()
202 struct xfs_ifork *ifp, in xfs_iext_first() argument
206 cur->leaf = xfs_iext_find_first_leaf(ifp); in xfs_iext_first()
211 struct xfs_ifork *ifp, in xfs_iext_last() argument
216 cur->leaf = xfs_iext_find_last_leaf(ifp); in xfs_iext_last()
222 for (i = 1; i < xfs_iext_max_recs(ifp); i++) { in xfs_iext_last()
231 struct xfs_ifork *ifp, in xfs_iext_next() argument
236 xfs_iext_first(ifp, cur); in xfs_iext_next()
241 ASSERT(cur->pos < xfs_iext_max_recs(ifp)); in xfs_iext_next()
244 if (ifp->if_height > 1 && !xfs_iext_valid(ifp, cur) && in xfs_iext_next()
253 struct xfs_ifork *ifp, in xfs_iext_prev() argument
258 xfs_iext_last(ifp, cur); in xfs_iext_prev()
268 if (xfs_iext_valid(ifp, cur)) in xfs_iext_prev()
272 if (ifp->if_height > 1 && cur->leaf->prev) { in xfs_iext_prev()
309 struct xfs_ifork *ifp, in xfs_iext_find_level() argument
313 struct xfs_iext_node *node = ifp->if_u1.if_root; in xfs_iext_find_level()
316 if (!ifp->if_height) in xfs_iext_find_level()
319 for (height = ifp->if_height; height > level; height--) { in xfs_iext_find_level()
379 struct xfs_ifork *ifp, in xfs_iext_leaf_nr_entries() argument
385 for (i = start; i < xfs_iext_max_recs(ifp); i++) { in xfs_iext_leaf_nr_entries()
403 struct xfs_ifork *ifp) in xfs_iext_grow() argument
408 if (ifp->if_height == 1) { in xfs_iext_grow()
409 struct xfs_iext_leaf *prev = ifp->if_u1.if_root; in xfs_iext_grow()
414 struct xfs_iext_node *prev = ifp->if_u1.if_root; in xfs_iext_grow()
416 ASSERT(ifp->if_height > 1); in xfs_iext_grow()
425 ifp->if_u1.if_root = node; in xfs_iext_grow()
426 ifp->if_height++; in xfs_iext_grow()
431 struct xfs_ifork *ifp, in xfs_iext_update_node() argument
437 struct xfs_iext_node *node = ifp->if_u1.if_root; in xfs_iext_update_node()
440 for (height = ifp->if_height; height > level; height--) { in xfs_iext_update_node()
498 struct xfs_ifork *ifp, in xfs_iext_insert_node() argument
507 if (ifp->if_height < level) in xfs_iext_insert_node()
508 xfs_iext_grow(ifp); in xfs_iext_insert_node()
511 node = xfs_iext_find_level(ifp, offset, level); in xfs_iext_insert_node()
526 xfs_iext_update_node(ifp, node->keys[0], offset, level, node); in xfs_iext_insert_node()
585 struct xfs_ifork *ifp, in xfs_iext_alloc_root() argument
588 ASSERT(ifp->if_bytes == 0); in xfs_iext_alloc_root()
590 ifp->if_u1.if_root = kmem_zalloc(sizeof(struct xfs_iext_rec), KM_NOFS); in xfs_iext_alloc_root()
591 ifp->if_height = 1; in xfs_iext_alloc_root()
594 cur->leaf = ifp->if_u1.if_root; in xfs_iext_alloc_root()
600 struct xfs_ifork *ifp, in xfs_iext_realloc_root() argument
603 size_t new_size = ifp->if_bytes + sizeof(struct xfs_iext_rec); in xfs_iext_realloc_root()
610 new = kmem_realloc(ifp->if_u1.if_root, new_size, KM_NOFS); in xfs_iext_realloc_root()
611 memset(new + ifp->if_bytes, 0, new_size - ifp->if_bytes); in xfs_iext_realloc_root()
612 ifp->if_u1.if_root = new; in xfs_iext_realloc_root()
623 static inline void xfs_iext_inc_seq(struct xfs_ifork *ifp, int state) in xfs_iext_inc_seq() argument
626 WRITE_ONCE(ifp->if_seq, READ_ONCE(ifp->if_seq) + 1); in xfs_iext_inc_seq()
636 struct xfs_ifork *ifp = xfs_iext_state_to_fork(ip, state); in xfs_iext_insert() local
641 xfs_iext_inc_seq(ifp, state); in xfs_iext_insert()
643 if (ifp->if_height == 0) in xfs_iext_insert()
644 xfs_iext_alloc_root(ifp, cur); in xfs_iext_insert()
645 else if (ifp->if_height == 1) in xfs_iext_insert()
646 xfs_iext_realloc_root(ifp, cur); in xfs_iext_insert()
648 nr_entries = xfs_iext_leaf_nr_entries(ifp, cur->leaf, cur->pos); in xfs_iext_insert()
661 xfs_iext_update_node(ifp, xfs_iext_leaf_key(cur->leaf, 0), in xfs_iext_insert()
668 ifp->if_bytes += sizeof(struct xfs_iext_rec); in xfs_iext_insert()
673 xfs_iext_insert_node(ifp, xfs_iext_leaf_key(new, 0), new, 2); in xfs_iext_insert()
729 struct xfs_ifork *ifp, in xfs_iext_remove_node() argument
736 ASSERT(level <= ifp->if_height); in xfs_iext_remove_node()
737 node = xfs_iext_find_level(ifp, offset, level); in xfs_iext_remove_node()
754 xfs_iext_update_node(ifp, offset, node->keys[0], level, node); in xfs_iext_remove_node()
761 if (level < ifp->if_height) { in xfs_iext_remove_node()
768 parent = xfs_iext_find_level(ifp, offset, level); in xfs_iext_remove_node()
785 ASSERT(node == ifp->if_u1.if_root); in xfs_iext_remove_node()
786 ifp->if_u1.if_root = node->ptrs[0]; in xfs_iext_remove_node()
787 ifp->if_height--; in xfs_iext_remove_node()
794 struct xfs_ifork *ifp, in xfs_iext_rebalance_leaf() argument
809 int nr_prev = xfs_iext_leaf_nr_entries(ifp, leaf->prev, 0), i; in xfs_iext_rebalance_leaf()
824 int nr_next = xfs_iext_leaf_nr_entries(ifp, leaf->next, 0), i; in xfs_iext_rebalance_leaf()
854 xfs_iext_remove_node(ifp, offset, leaf); in xfs_iext_rebalance_leaf()
859 struct xfs_ifork *ifp) in xfs_iext_free_last_leaf() argument
861 ifp->if_height--; in xfs_iext_free_last_leaf()
862 kmem_free(ifp->if_u1.if_root); in xfs_iext_free_last_leaf()
863 ifp->if_u1.if_root = NULL; in xfs_iext_free_last_leaf()
872 struct xfs_ifork *ifp = xfs_iext_state_to_fork(ip, state); in xfs_iext_remove() local
879 ASSERT(ifp->if_height > 0); in xfs_iext_remove()
880 ASSERT(ifp->if_u1.if_root != NULL); in xfs_iext_remove()
881 ASSERT(xfs_iext_valid(ifp, cur)); in xfs_iext_remove()
883 xfs_iext_inc_seq(ifp, state); in xfs_iext_remove()
885 nr_entries = xfs_iext_leaf_nr_entries(ifp, leaf, cur->pos) - 1; in xfs_iext_remove()
889 ifp->if_bytes -= sizeof(struct xfs_iext_rec); in xfs_iext_remove()
892 xfs_iext_update_node(ifp, offset, xfs_iext_leaf_key(leaf, 0), 1, in xfs_iext_remove()
896 if (ifp->if_height > 1 && leaf->next) in xfs_iext_remove()
906 if (ifp->if_height > 1) in xfs_iext_remove()
907 xfs_iext_rebalance_leaf(ifp, cur, leaf, offset, nr_entries); in xfs_iext_remove()
909 xfs_iext_free_last_leaf(ifp); in xfs_iext_remove()
926 struct xfs_ifork *ifp, in xfs_iext_lookup_extent() argument
933 cur->leaf = xfs_iext_find_level(ifp, offset, 1); in xfs_iext_lookup_extent()
939 for (cur->pos = 0; cur->pos < xfs_iext_max_recs(ifp); cur->pos++) { in xfs_iext_lookup_extent()
949 if (ifp->if_height == 1 || !cur->leaf->next) in xfs_iext_lookup_extent()
953 if (!xfs_iext_valid(ifp, cur)) in xfs_iext_lookup_extent()
967 struct xfs_ifork *ifp, in xfs_iext_lookup_extent_before() argument
973 if (xfs_iext_lookup_extent(ip, ifp, *end - 1, cur, gotp) && in xfs_iext_lookup_extent_before()
976 if (!xfs_iext_prev_extent(ifp, cur, gotp)) in xfs_iext_lookup_extent_before()
989 struct xfs_ifork *ifp = xfs_iext_state_to_fork(ip, state); in xfs_iext_update_extent() local
991 xfs_iext_inc_seq(ifp, state); in xfs_iext_update_extent()
998 xfs_iext_update_node(ifp, old.br_startoff, in xfs_iext_update_extent()
1014 struct xfs_ifork *ifp, in xfs_iext_get_extent() argument
1018 if (!xfs_iext_valid(ifp, cur)) in xfs_iext_get_extent()
1048 struct xfs_ifork *ifp) in xfs_iext_destroy() argument
1050 xfs_iext_destroy_node(ifp->if_u1.if_root, ifp->if_height); in xfs_iext_destroy()
1052 ifp->if_bytes = 0; in xfs_iext_destroy()
1053 ifp->if_height = 0; in xfs_iext_destroy()
1054 ifp->if_u1.if_root = NULL; in xfs_iext_destroy()