Lines Matching refs:cur
140 static inline struct xfs_iext_rec *cur_rec(struct xfs_iext_cursor *cur) in cur_rec() argument
142 return &cur->leaf->recs[cur->pos]; in cur_rec()
146 struct xfs_iext_cursor *cur) in xfs_iext_valid() argument
148 if (!cur->leaf) in xfs_iext_valid()
150 if (cur->pos < 0 || cur->pos >= xfs_iext_max_recs(ifp)) in xfs_iext_valid()
152 if (xfs_iext_rec_is_empty(cur_rec(cur))) in xfs_iext_valid()
199 struct xfs_iext_cursor *cur) in xfs_iext_first() argument
201 cur->pos = 0; in xfs_iext_first()
202 cur->leaf = xfs_iext_find_first_leaf(ifp); in xfs_iext_first()
208 struct xfs_iext_cursor *cur) in xfs_iext_last() argument
212 cur->leaf = xfs_iext_find_last_leaf(ifp); in xfs_iext_last()
213 if (!cur->leaf) { in xfs_iext_last()
214 cur->pos = 0; in xfs_iext_last()
219 if (xfs_iext_rec_is_empty(&cur->leaf->recs[i])) in xfs_iext_last()
222 cur->pos = i - 1; in xfs_iext_last()
228 struct xfs_iext_cursor *cur) in xfs_iext_next() argument
230 if (!cur->leaf) { in xfs_iext_next()
231 ASSERT(cur->pos <= 0 || cur->pos >= RECS_PER_LEAF); in xfs_iext_next()
232 xfs_iext_first(ifp, cur); in xfs_iext_next()
236 ASSERT(cur->pos >= 0); in xfs_iext_next()
237 ASSERT(cur->pos < xfs_iext_max_recs(ifp)); in xfs_iext_next()
239 cur->pos++; in xfs_iext_next()
240 if (ifp->if_height > 1 && !xfs_iext_valid(ifp, cur) && in xfs_iext_next()
241 cur->leaf->next) { in xfs_iext_next()
242 cur->leaf = cur->leaf->next; in xfs_iext_next()
243 cur->pos = 0; in xfs_iext_next()
250 struct xfs_iext_cursor *cur) in xfs_iext_prev() argument
252 if (!cur->leaf) { in xfs_iext_prev()
253 ASSERT(cur->pos <= 0 || cur->pos >= RECS_PER_LEAF); in xfs_iext_prev()
254 xfs_iext_last(ifp, cur); in xfs_iext_prev()
258 ASSERT(cur->pos >= 0); in xfs_iext_prev()
259 ASSERT(cur->pos <= RECS_PER_LEAF); in xfs_iext_prev()
263 cur->pos--; in xfs_iext_prev()
264 if (xfs_iext_valid(ifp, cur)) in xfs_iext_prev()
266 } while (cur->pos > 0); in xfs_iext_prev()
268 if (ifp->if_height > 1 && cur->leaf->prev) { in xfs_iext_prev()
269 cur->leaf = cur->leaf->prev; in xfs_iext_prev()
270 cur->pos = RECS_PER_LEAF; in xfs_iext_prev()
541 struct xfs_iext_cursor *cur, in xfs_iext_split_leaf() argument
544 struct xfs_iext_leaf *leaf = cur->leaf; in xfs_iext_split_leaf()
551 if (cur->pos == RECS_PER_LEAF) { in xfs_iext_split_leaf()
552 cur->leaf = new; in xfs_iext_split_leaf()
553 cur->pos = 0; in xfs_iext_split_leaf()
563 if (cur->pos >= nr_keep) { in xfs_iext_split_leaf()
564 cur->leaf = new; in xfs_iext_split_leaf()
565 cur->pos -= nr_keep; in xfs_iext_split_leaf()
582 struct xfs_iext_cursor *cur) in xfs_iext_alloc_root() argument
590 cur->leaf = ifp->if_u1.if_root; in xfs_iext_alloc_root()
591 cur->pos = 0; in xfs_iext_alloc_root()
597 struct xfs_iext_cursor *cur) in xfs_iext_realloc_root() argument
609 cur->leaf = new; in xfs_iext_realloc_root()
627 struct xfs_iext_cursor *cur, in xfs_iext_insert() argument
639 xfs_iext_alloc_root(ifp, cur); in xfs_iext_insert()
641 xfs_iext_realloc_root(ifp, cur); in xfs_iext_insert()
643 nr_entries = xfs_iext_leaf_nr_entries(ifp, cur->leaf, cur->pos); in xfs_iext_insert()
645 ASSERT(cur->pos >= nr_entries || in xfs_iext_insert()
646 xfs_iext_rec_cmp(cur_rec(cur), irec->br_startoff) != 0); in xfs_iext_insert()
649 new = xfs_iext_split_leaf(cur, &nr_entries); in xfs_iext_insert()
655 if (cur->leaf != new && cur->pos == 0 && nr_entries > 0) { in xfs_iext_insert()
656 xfs_iext_update_node(ifp, xfs_iext_leaf_key(cur->leaf, 0), in xfs_iext_insert()
657 offset, 1, cur->leaf); in xfs_iext_insert()
660 for (i = nr_entries; i > cur->pos; i--) in xfs_iext_insert()
661 cur->leaf->recs[i] = cur->leaf->recs[i - 1]; in xfs_iext_insert()
662 xfs_iext_set(cur_rec(cur), irec); in xfs_iext_insert()
665 trace_xfs_iext_insert(ip, cur, state, _RET_IP_); in xfs_iext_insert()
790 struct xfs_iext_cursor *cur, in xfs_iext_rebalance_leaf() argument
810 if (cur->leaf == leaf) { in xfs_iext_rebalance_leaf()
811 cur->leaf = leaf->prev; in xfs_iext_rebalance_leaf()
812 cur->pos += nr_prev; in xfs_iext_rebalance_leaf()
832 if (cur->leaf == leaf->next) { in xfs_iext_rebalance_leaf()
833 cur->leaf = leaf; in xfs_iext_rebalance_leaf()
834 cur->pos += nr_entries; in xfs_iext_rebalance_leaf()
864 struct xfs_iext_cursor *cur, in xfs_iext_remove() argument
868 struct xfs_iext_leaf *leaf = cur->leaf; in xfs_iext_remove()
872 trace_xfs_iext_remove(ip, cur, state, _RET_IP_); in xfs_iext_remove()
876 ASSERT(xfs_iext_valid(ifp, cur)); in xfs_iext_remove()
880 nr_entries = xfs_iext_leaf_nr_entries(ifp, leaf, cur->pos) - 1; in xfs_iext_remove()
881 for (i = cur->pos; i < nr_entries; i++) in xfs_iext_remove()
886 if (cur->pos == 0 && nr_entries > 0) { in xfs_iext_remove()
890 } else if (cur->pos == nr_entries) { in xfs_iext_remove()
892 cur->leaf = leaf->next; in xfs_iext_remove()
894 cur->leaf = NULL; in xfs_iext_remove()
895 cur->pos = 0; in xfs_iext_remove()
902 xfs_iext_rebalance_leaf(ifp, cur, leaf, offset, nr_entries); in xfs_iext_remove()
923 struct xfs_iext_cursor *cur, in xfs_iext_lookup_extent() argument
928 cur->leaf = xfs_iext_find_level(ifp, offset, 1); in xfs_iext_lookup_extent()
929 if (!cur->leaf) { in xfs_iext_lookup_extent()
930 cur->pos = 0; in xfs_iext_lookup_extent()
934 for (cur->pos = 0; cur->pos < xfs_iext_max_recs(ifp); cur->pos++) { in xfs_iext_lookup_extent()
935 struct xfs_iext_rec *rec = cur_rec(cur); in xfs_iext_lookup_extent()
944 if (ifp->if_height == 1 || !cur->leaf->next) in xfs_iext_lookup_extent()
946 cur->leaf = cur->leaf->next; in xfs_iext_lookup_extent()
947 cur->pos = 0; in xfs_iext_lookup_extent()
948 if (!xfs_iext_valid(ifp, cur)) in xfs_iext_lookup_extent()
951 xfs_iext_get(gotp, cur_rec(cur)); in xfs_iext_lookup_extent()
964 struct xfs_iext_cursor *cur, in xfs_iext_lookup_extent_before() argument
968 if (xfs_iext_lookup_extent(ip, ifp, *end - 1, cur, gotp) && in xfs_iext_lookup_extent_before()
971 if (!xfs_iext_prev_extent(ifp, cur, gotp)) in xfs_iext_lookup_extent_before()
981 struct xfs_iext_cursor *cur, in xfs_iext_update_extent() argument
988 if (cur->pos == 0) { in xfs_iext_update_extent()
991 xfs_iext_get(&old, cur_rec(cur)); in xfs_iext_update_extent()
994 new->br_startoff, 1, cur->leaf); in xfs_iext_update_extent()
998 trace_xfs_bmap_pre_update(ip, cur, state, _RET_IP_); in xfs_iext_update_extent()
999 xfs_iext_set(cur_rec(cur), new); in xfs_iext_update_extent()
1000 trace_xfs_bmap_post_update(ip, cur, state, _RET_IP_); in xfs_iext_update_extent()
1010 struct xfs_iext_cursor *cur, in xfs_iext_get_extent() argument
1013 if (!xfs_iext_valid(ifp, cur)) in xfs_iext_get_extent()
1015 xfs_iext_get(gotp, cur_rec(cur)); in xfs_iext_get_extent()