Lines Matching refs:ifp

128 inline xfs_extnum_t xfs_iext_count(struct xfs_ifork *ifp)
130 return ifp->if_bytes / sizeof(struct xfs_iext_rec);
133 static inline int xfs_iext_max_recs(struct xfs_ifork *ifp)
135 if (ifp->if_height == 1)
136 return xfs_iext_count(ifp);
145 static inline bool xfs_iext_valid(struct xfs_ifork *ifp,
150 if (cur->pos < 0 || cur->pos >= xfs_iext_max_recs(ifp))
159 struct xfs_ifork *ifp)
161 struct xfs_iext_node *node = ifp->if_u1.if_root;
164 if (!ifp->if_height)
167 for (height = ifp->if_height; height > 1; height--) {
177 struct xfs_ifork *ifp)
179 struct xfs_iext_node *node = ifp->if_u1.if_root;
182 if (!ifp->if_height)
185 for (height = ifp->if_height; height > 1; height--) {
198 struct xfs_ifork *ifp,
202 cur->leaf = xfs_iext_find_first_leaf(ifp);
207 struct xfs_ifork *ifp,
212 cur->leaf = xfs_iext_find_last_leaf(ifp);
218 for (i = 1; i < xfs_iext_max_recs(ifp); i++) {
227 struct xfs_ifork *ifp,
232 xfs_iext_first(ifp, cur);
237 ASSERT(cur->pos < xfs_iext_max_recs(ifp));
240 if (ifp->if_height > 1 && !xfs_iext_valid(ifp, cur) &&
249 struct xfs_ifork *ifp,
254 xfs_iext_last(ifp, cur);
264 if (xfs_iext_valid(ifp, cur))
268 if (ifp->if_height > 1 && cur->leaf->prev) {
305 struct xfs_ifork *ifp,
309 struct xfs_iext_node *node = ifp->if_u1.if_root;
312 if (!ifp->if_height)
315 for (height = ifp->if_height; height > level; height--) {
375 struct xfs_ifork *ifp,
381 for (i = start; i < xfs_iext_max_recs(ifp); i++) {
399 struct xfs_ifork *ifp)
404 if (ifp->if_height == 1) {
405 struct xfs_iext_leaf *prev = ifp->if_u1.if_root;
410 struct xfs_iext_node *prev = ifp->if_u1.if_root;
412 ASSERT(ifp->if_height > 1);
421 ifp->if_u1.if_root = node;
422 ifp->if_height++;
427 struct xfs_ifork *ifp,
433 struct xfs_iext_node *node = ifp->if_u1.if_root;
436 for (height = ifp->if_height; height > level; height--) {
494 struct xfs_ifork *ifp,
503 if (ifp->if_height < level)
504 xfs_iext_grow(ifp);
507 node = xfs_iext_find_level(ifp, offset, level);
522 xfs_iext_update_node(ifp, node->keys[0], offset, level, node);
581 struct xfs_ifork *ifp,
584 ASSERT(ifp->if_bytes == 0);
586 ifp->if_u1.if_root = kmem_zalloc(sizeof(struct xfs_iext_rec), KM_NOFS);
587 ifp->if_height = 1;
590 cur->leaf = ifp->if_u1.if_root;
596 struct xfs_ifork *ifp,
599 int64_t new_size = ifp->if_bytes + sizeof(struct xfs_iext_rec);
606 new = krealloc(ifp->if_u1.if_root, new_size, GFP_NOFS | __GFP_NOFAIL);
607 memset(new + ifp->if_bytes, 0, new_size - ifp->if_bytes);
608 ifp->if_u1.if_root = new;
619 static inline void xfs_iext_inc_seq(struct xfs_ifork *ifp)
621 WRITE_ONCE(ifp->if_seq, READ_ONCE(ifp->if_seq) + 1);
631 struct xfs_ifork *ifp = xfs_iext_state_to_fork(ip, state);
636 xfs_iext_inc_seq(ifp);
638 if (ifp->if_height == 0)
639 xfs_iext_alloc_root(ifp, cur);
640 else if (ifp->if_height == 1)
641 xfs_iext_realloc_root(ifp, cur);
643 nr_entries = xfs_iext_leaf_nr_entries(ifp, cur->leaf, cur->pos);
656 xfs_iext_update_node(ifp, xfs_iext_leaf_key(cur->leaf, 0),
663 ifp->if_bytes += sizeof(struct xfs_iext_rec);
668 xfs_iext_insert_node(ifp, xfs_iext_leaf_key(new, 0), new, 2);
724 struct xfs_ifork *ifp,
731 ASSERT(level <= ifp->if_height);
732 node = xfs_iext_find_level(ifp, offset, level);
749 xfs_iext_update_node(ifp, offset, node->keys[0], level, node);
756 if (level < ifp->if_height) {
763 parent = xfs_iext_find_level(ifp, offset, level);
780 ASSERT(node == ifp->if_u1.if_root);
781 ifp->if_u1.if_root = node->ptrs[0];
782 ifp->if_height--;
789 struct xfs_ifork *ifp,
804 int nr_prev = xfs_iext_leaf_nr_entries(ifp, leaf->prev, 0), i;
819 int nr_next = xfs_iext_leaf_nr_entries(ifp, leaf->next, 0), i;
849 xfs_iext_remove_node(ifp, offset, leaf);
854 struct xfs_ifork *ifp)
856 ifp->if_height--;
857 kmem_free(ifp->if_u1.if_root);
858 ifp->if_u1.if_root = NULL;
867 struct xfs_ifork *ifp = xfs_iext_state_to_fork(ip, state);
874 ASSERT(ifp->if_height > 0);
875 ASSERT(ifp->if_u1.if_root != NULL);
876 ASSERT(xfs_iext_valid(ifp, cur));
878 xfs_iext_inc_seq(ifp);
880 nr_entries = xfs_iext_leaf_nr_entries(ifp, leaf, cur->pos) - 1;
884 ifp->if_bytes -= sizeof(struct xfs_iext_rec);
887 xfs_iext_update_node(ifp, offset, xfs_iext_leaf_key(leaf, 0), 1,
891 if (ifp->if_height > 1 && leaf->next)
901 if (ifp->if_height > 1)
902 xfs_iext_rebalance_leaf(ifp, cur, leaf, offset, nr_entries);
904 xfs_iext_free_last_leaf(ifp);
921 struct xfs_ifork *ifp,
928 cur->leaf = xfs_iext_find_level(ifp, offset, 1);
934 for (cur->pos = 0; cur->pos < xfs_iext_max_recs(ifp); cur->pos++) {
944 if (ifp->if_height == 1 || !cur->leaf->next)
948 if (!xfs_iext_valid(ifp, cur))
962 struct xfs_ifork *ifp,
968 if (xfs_iext_lookup_extent(ip, ifp, *end - 1, cur, gotp) &&
971 if (!xfs_iext_prev_extent(ifp, cur, gotp))
984 struct xfs_ifork *ifp = xfs_iext_state_to_fork(ip, state);
986 xfs_iext_inc_seq(ifp);
993 xfs_iext_update_node(ifp, old.br_startoff,
1009 struct xfs_ifork *ifp,
1013 if (!xfs_iext_valid(ifp, cur))
1043 struct xfs_ifork *ifp)
1045 xfs_iext_destroy_node(ifp->if_u1.if_root, ifp->if_height);
1047 ifp->if_bytes = 0;
1048 ifp->if_height = 0;
1049 ifp->if_u1.if_root = NULL;