Lines Matching full:ifp

128 inline xfs_extnum_t xfs_iext_count(struct xfs_ifork *ifp)  in xfs_iext_count()  argument
130 return ifp->if_bytes / sizeof(struct xfs_iext_rec); in xfs_iext_count()
133 static inline int xfs_iext_max_recs(struct xfs_ifork *ifp) in xfs_iext_max_recs() argument
135 if (ifp->if_height == 1) in xfs_iext_max_recs()
136 return xfs_iext_count(ifp); in xfs_iext_max_recs()
145 static inline bool xfs_iext_valid(struct xfs_ifork *ifp, in xfs_iext_valid() argument
150 if (cur->pos < 0 || cur->pos >= xfs_iext_max_recs(ifp)) in xfs_iext_valid()
159 struct xfs_ifork *ifp) in xfs_iext_find_first_leaf() argument
161 struct xfs_iext_node *node = ifp->if_data; in xfs_iext_find_first_leaf()
164 if (!ifp->if_height) in xfs_iext_find_first_leaf()
167 for (height = ifp->if_height; height > 1; height--) { in xfs_iext_find_first_leaf()
177 struct xfs_ifork *ifp) in xfs_iext_find_last_leaf() argument
179 struct xfs_iext_node *node = ifp->if_data; in xfs_iext_find_last_leaf()
182 if (!ifp->if_height) in xfs_iext_find_last_leaf()
185 for (height = ifp->if_height; height > 1; height--) { in xfs_iext_find_last_leaf()
198 struct xfs_ifork *ifp, in xfs_iext_first() argument
202 cur->leaf = xfs_iext_find_first_leaf(ifp); in xfs_iext_first()
207 struct xfs_ifork *ifp, in xfs_iext_last() argument
212 cur->leaf = xfs_iext_find_last_leaf(ifp); in xfs_iext_last()
218 for (i = 1; i < xfs_iext_max_recs(ifp); i++) { in xfs_iext_last()
227 struct xfs_ifork *ifp, in xfs_iext_next() argument
232 xfs_iext_first(ifp, cur); in xfs_iext_next()
237 ASSERT(cur->pos < xfs_iext_max_recs(ifp)); in xfs_iext_next()
240 if (ifp->if_height > 1 && !xfs_iext_valid(ifp, cur) && in xfs_iext_next()
249 struct xfs_ifork *ifp, in xfs_iext_prev() argument
254 xfs_iext_last(ifp, cur); in xfs_iext_prev()
264 if (xfs_iext_valid(ifp, cur)) in xfs_iext_prev()
268 if (ifp->if_height > 1 && cur->leaf->prev) { in xfs_iext_prev()
305 struct xfs_ifork *ifp, in xfs_iext_find_level() argument
309 struct xfs_iext_node *node = ifp->if_data; in xfs_iext_find_level()
312 if (!ifp->if_height) in xfs_iext_find_level()
315 for (height = ifp->if_height; height > level; height--) { in xfs_iext_find_level()
375 struct xfs_ifork *ifp, in xfs_iext_leaf_nr_entries() argument
381 for (i = start; i < xfs_iext_max_recs(ifp); i++) { in xfs_iext_leaf_nr_entries()
406 struct xfs_ifork *ifp) in xfs_iext_grow() argument
411 if (ifp->if_height == 1) { in xfs_iext_grow()
412 struct xfs_iext_leaf *prev = ifp->if_data; in xfs_iext_grow()
417 struct xfs_iext_node *prev = ifp->if_data; in xfs_iext_grow()
419 ASSERT(ifp->if_height > 1); in xfs_iext_grow()
428 ifp->if_data = node; in xfs_iext_grow()
429 ifp->if_height++; in xfs_iext_grow()
434 struct xfs_ifork *ifp, in xfs_iext_update_node() argument
440 struct xfs_iext_node *node = ifp->if_data; in xfs_iext_update_node()
443 for (height = ifp->if_height; height > level; height--) { in xfs_iext_update_node()
501 struct xfs_ifork *ifp, in xfs_iext_insert_node() argument
510 if (ifp->if_height < level) in xfs_iext_insert_node()
511 xfs_iext_grow(ifp); in xfs_iext_insert_node()
514 node = xfs_iext_find_level(ifp, offset, level); in xfs_iext_insert_node()
529 xfs_iext_update_node(ifp, node->keys[0], offset, level, node); in xfs_iext_insert_node()
588 struct xfs_ifork *ifp, in xfs_iext_alloc_root() argument
591 ASSERT(ifp->if_bytes == 0); in xfs_iext_alloc_root()
593 ifp->if_data = xfs_iext_alloc_node(sizeof(struct xfs_iext_rec)); in xfs_iext_alloc_root()
594 ifp->if_height = 1; in xfs_iext_alloc_root()
597 cur->leaf = ifp->if_data; in xfs_iext_alloc_root()
603 struct xfs_ifork *ifp, in xfs_iext_realloc_root() argument
606 int64_t new_size = ifp->if_bytes + sizeof(struct xfs_iext_rec); in xfs_iext_realloc_root()
613 new = krealloc(ifp->if_data, new_size, in xfs_iext_realloc_root()
615 memset(new + ifp->if_bytes, 0, new_size - ifp->if_bytes); in xfs_iext_realloc_root()
616 ifp->if_data = new; in xfs_iext_realloc_root()
627 static inline void xfs_iext_inc_seq(struct xfs_ifork *ifp) in xfs_iext_inc_seq() argument
629 WRITE_ONCE(ifp->if_seq, READ_ONCE(ifp->if_seq) + 1); in xfs_iext_inc_seq()
634 struct xfs_ifork *ifp, in xfs_iext_insert_raw() argument
642 xfs_iext_inc_seq(ifp); in xfs_iext_insert_raw()
644 if (ifp->if_height == 0) in xfs_iext_insert_raw()
645 xfs_iext_alloc_root(ifp, cur); in xfs_iext_insert_raw()
646 else if (ifp->if_height == 1) in xfs_iext_insert_raw()
647 xfs_iext_realloc_root(ifp, cur); in xfs_iext_insert_raw()
649 nr_entries = xfs_iext_leaf_nr_entries(ifp, cur->leaf, cur->pos); in xfs_iext_insert_raw()
662 xfs_iext_update_node(ifp, xfs_iext_leaf_key(cur->leaf, 0), in xfs_iext_insert_raw()
669 ifp->if_bytes += sizeof(struct xfs_iext_rec); in xfs_iext_insert_raw()
672 xfs_iext_insert_node(ifp, xfs_iext_leaf_key(new, 0), new, 2); in xfs_iext_insert_raw()
682 struct xfs_ifork *ifp = xfs_iext_state_to_fork(ip, state); in xfs_iext_insert() local
684 xfs_iext_insert_raw(ifp, cur, irec); in xfs_iext_insert()
741 struct xfs_ifork *ifp, in xfs_iext_remove_node() argument
748 ASSERT(level <= ifp->if_height); in xfs_iext_remove_node()
749 node = xfs_iext_find_level(ifp, offset, level); in xfs_iext_remove_node()
766 xfs_iext_update_node(ifp, offset, node->keys[0], level, node); in xfs_iext_remove_node()
773 if (level < ifp->if_height) { in xfs_iext_remove_node()
780 parent = xfs_iext_find_level(ifp, offset, level); in xfs_iext_remove_node()
797 ASSERT(node == ifp->if_data); in xfs_iext_remove_node()
798 ifp->if_data = node->ptrs[0]; in xfs_iext_remove_node()
799 ifp->if_height--; in xfs_iext_remove_node()
806 struct xfs_ifork *ifp, in xfs_iext_rebalance_leaf() argument
821 int nr_prev = xfs_iext_leaf_nr_entries(ifp, leaf->prev, 0), i; in xfs_iext_rebalance_leaf()
836 int nr_next = xfs_iext_leaf_nr_entries(ifp, leaf->next, 0), i; in xfs_iext_rebalance_leaf()
866 xfs_iext_remove_node(ifp, offset, leaf); in xfs_iext_rebalance_leaf()
871 struct xfs_ifork *ifp) in xfs_iext_free_last_leaf() argument
873 ifp->if_height--; in xfs_iext_free_last_leaf()
874 kfree(ifp->if_data); in xfs_iext_free_last_leaf()
875 ifp->if_data = NULL; in xfs_iext_free_last_leaf()
884 struct xfs_ifork *ifp = xfs_iext_state_to_fork(ip, state); in xfs_iext_remove() local
891 ASSERT(ifp->if_height > 0); in xfs_iext_remove()
892 ASSERT(ifp->if_data != NULL); in xfs_iext_remove()
893 ASSERT(xfs_iext_valid(ifp, cur)); in xfs_iext_remove()
895 xfs_iext_inc_seq(ifp); in xfs_iext_remove()
897 nr_entries = xfs_iext_leaf_nr_entries(ifp, leaf, cur->pos) - 1; in xfs_iext_remove()
901 ifp->if_bytes -= sizeof(struct xfs_iext_rec); in xfs_iext_remove()
904 xfs_iext_update_node(ifp, offset, xfs_iext_leaf_key(leaf, 0), 1, in xfs_iext_remove()
908 if (ifp->if_height > 1 && leaf->next) in xfs_iext_remove()
918 if (ifp->if_height > 1) in xfs_iext_remove()
919 xfs_iext_rebalance_leaf(ifp, cur, leaf, offset, nr_entries); in xfs_iext_remove()
921 xfs_iext_free_last_leaf(ifp); in xfs_iext_remove()
938 struct xfs_ifork *ifp, in xfs_iext_lookup_extent() argument
945 cur->leaf = xfs_iext_find_level(ifp, offset, 1); in xfs_iext_lookup_extent()
951 for (cur->pos = 0; cur->pos < xfs_iext_max_recs(ifp); cur->pos++) { in xfs_iext_lookup_extent()
961 if (ifp->if_height == 1 || !cur->leaf->next) in xfs_iext_lookup_extent()
965 if (!xfs_iext_valid(ifp, cur)) in xfs_iext_lookup_extent()
979 struct xfs_ifork *ifp, in xfs_iext_lookup_extent_before() argument
985 if (xfs_iext_lookup_extent(ip, ifp, *end - 1, cur, gotp) && in xfs_iext_lookup_extent_before()
988 if (!xfs_iext_prev_extent(ifp, cur, gotp)) in xfs_iext_lookup_extent_before()
1001 struct xfs_ifork *ifp = xfs_iext_state_to_fork(ip, state); in xfs_iext_update_extent() local
1003 xfs_iext_inc_seq(ifp); in xfs_iext_update_extent()
1010 xfs_iext_update_node(ifp, old.br_startoff, in xfs_iext_update_extent()
1026 struct xfs_ifork *ifp, in xfs_iext_get_extent() argument
1030 if (!xfs_iext_valid(ifp, cur)) in xfs_iext_get_extent()
1060 struct xfs_ifork *ifp) in xfs_iext_destroy() argument
1062 xfs_iext_destroy_node(ifp->if_data, ifp->if_height); in xfs_iext_destroy()
1064 ifp->if_bytes = 0; in xfs_iext_destroy()
1065 ifp->if_height = 0; in xfs_iext_destroy()
1066 ifp->if_data = NULL; in xfs_iext_destroy()