Lines Matching refs:cur
48 struct xfs_btree_cur *cur, in xfs_refcount_lookup_le() argument
52 trace_xfs_refcount_lookup(cur->bc_mp, cur->bc_ag.pag->pag_agno, bno, in xfs_refcount_lookup_le()
54 cur->bc_rec.rc.rc_startblock = bno; in xfs_refcount_lookup_le()
55 cur->bc_rec.rc.rc_blockcount = 0; in xfs_refcount_lookup_le()
56 return xfs_btree_lookup(cur, XFS_LOOKUP_LE, stat); in xfs_refcount_lookup_le()
65 struct xfs_btree_cur *cur, in xfs_refcount_lookup_ge() argument
69 trace_xfs_refcount_lookup(cur->bc_mp, cur->bc_ag.pag->pag_agno, bno, in xfs_refcount_lookup_ge()
71 cur->bc_rec.rc.rc_startblock = bno; in xfs_refcount_lookup_ge()
72 cur->bc_rec.rc.rc_blockcount = 0; in xfs_refcount_lookup_ge()
73 return xfs_btree_lookup(cur, XFS_LOOKUP_GE, stat); in xfs_refcount_lookup_ge()
82 struct xfs_btree_cur *cur, in xfs_refcount_lookup_eq() argument
86 trace_xfs_refcount_lookup(cur->bc_mp, cur->bc_ag.pag->pag_agno, bno, in xfs_refcount_lookup_eq()
88 cur->bc_rec.rc.rc_startblock = bno; in xfs_refcount_lookup_eq()
89 cur->bc_rec.rc.rc_blockcount = 0; in xfs_refcount_lookup_eq()
90 return xfs_btree_lookup(cur, XFS_LOOKUP_EQ, stat); in xfs_refcount_lookup_eq()
109 struct xfs_btree_cur *cur, in xfs_refcount_get_rec() argument
113 struct xfs_mount *mp = cur->bc_mp; in xfs_refcount_get_rec()
114 xfs_agnumber_t agno = cur->bc_ag.pag->pag_agno; in xfs_refcount_get_rec()
119 error = xfs_btree_get_rec(cur, &rec, stat); in xfs_refcount_get_rec()
125 agno = cur->bc_ag.pag->pag_agno; in xfs_refcount_get_rec()
150 trace_xfs_refcount_get(cur->bc_mp, cur->bc_ag.pag->pag_agno, irec); in xfs_refcount_get_rec()
169 struct xfs_btree_cur *cur, in xfs_refcount_update() argument
175 trace_xfs_refcount_update(cur->bc_mp, cur->bc_ag.pag->pag_agno, irec); in xfs_refcount_update()
179 error = xfs_btree_update(cur, &rec); in xfs_refcount_update()
181 trace_xfs_refcount_update_error(cur->bc_mp, in xfs_refcount_update()
182 cur->bc_ag.pag->pag_agno, error, _RET_IP_); in xfs_refcount_update()
193 struct xfs_btree_cur *cur, in xfs_refcount_insert() argument
199 trace_xfs_refcount_insert(cur->bc_mp, cur->bc_ag.pag->pag_agno, irec); in xfs_refcount_insert()
200 cur->bc_rec.rc.rc_startblock = irec->rc_startblock; in xfs_refcount_insert()
201 cur->bc_rec.rc.rc_blockcount = irec->rc_blockcount; in xfs_refcount_insert()
202 cur->bc_rec.rc.rc_refcount = irec->rc_refcount; in xfs_refcount_insert()
203 error = xfs_btree_insert(cur, i); in xfs_refcount_insert()
206 if (XFS_IS_CORRUPT(cur->bc_mp, *i != 1)) { in xfs_refcount_insert()
213 trace_xfs_refcount_insert_error(cur->bc_mp, in xfs_refcount_insert()
214 cur->bc_ag.pag->pag_agno, error, _RET_IP_); in xfs_refcount_insert()
226 struct xfs_btree_cur *cur, in xfs_refcount_delete() argument
233 error = xfs_refcount_get_rec(cur, &irec, &found_rec); in xfs_refcount_delete()
236 if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) { in xfs_refcount_delete()
240 trace_xfs_refcount_delete(cur->bc_mp, cur->bc_ag.pag->pag_agno, &irec); in xfs_refcount_delete()
241 error = xfs_btree_delete(cur, i); in xfs_refcount_delete()
242 if (XFS_IS_CORRUPT(cur->bc_mp, *i != 1)) { in xfs_refcount_delete()
248 error = xfs_refcount_lookup_ge(cur, irec.rc_startblock, &found_rec); in xfs_refcount_delete()
251 trace_xfs_refcount_delete_error(cur->bc_mp, in xfs_refcount_delete()
252 cur->bc_ag.pag->pag_agno, error, _RET_IP_); in xfs_refcount_delete()
346 struct xfs_btree_cur *cur, in xfs_refcount_split_extent() argument
355 error = xfs_refcount_lookup_le(cur, agbno, &found_rec); in xfs_refcount_split_extent()
361 error = xfs_refcount_get_rec(cur, &rcext, &found_rec); in xfs_refcount_split_extent()
364 if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) { in xfs_refcount_split_extent()
372 trace_xfs_refcount_split_extent(cur->bc_mp, cur->bc_ag.pag->pag_agno, in xfs_refcount_split_extent()
379 error = xfs_refcount_update(cur, &tmp); in xfs_refcount_split_extent()
386 error = xfs_refcount_insert(cur, &tmp, &found_rec); in xfs_refcount_split_extent()
389 if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) { in xfs_refcount_split_extent()
396 trace_xfs_refcount_split_extent_error(cur->bc_mp, in xfs_refcount_split_extent()
397 cur->bc_ag.pag->pag_agno, error, _RET_IP_); in xfs_refcount_split_extent()
406 struct xfs_btree_cur *cur, in xfs_refcount_merge_center_extents() argument
416 trace_xfs_refcount_merge_center_extents(cur->bc_mp, in xfs_refcount_merge_center_extents()
417 cur->bc_ag.pag->pag_agno, left, center, right); in xfs_refcount_merge_center_extents()
427 error = xfs_refcount_lookup_ge(cur, center->rc_startblock, in xfs_refcount_merge_center_extents()
431 if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) { in xfs_refcount_merge_center_extents()
436 error = xfs_refcount_delete(cur, &found_rec); in xfs_refcount_merge_center_extents()
439 if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) { in xfs_refcount_merge_center_extents()
445 error = xfs_refcount_delete(cur, &found_rec); in xfs_refcount_merge_center_extents()
448 if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) { in xfs_refcount_merge_center_extents()
455 error = xfs_refcount_lookup_le(cur, left->rc_startblock, in xfs_refcount_merge_center_extents()
459 if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) { in xfs_refcount_merge_center_extents()
465 error = xfs_refcount_update(cur, left); in xfs_refcount_merge_center_extents()
473 trace_xfs_refcount_merge_center_extents_error(cur->bc_mp, in xfs_refcount_merge_center_extents()
474 cur->bc_ag.pag->pag_agno, error, _RET_IP_); in xfs_refcount_merge_center_extents()
483 struct xfs_btree_cur *cur, in xfs_refcount_merge_left_extent() argument
492 trace_xfs_refcount_merge_left_extent(cur->bc_mp, in xfs_refcount_merge_left_extent()
493 cur->bc_ag.pag->pag_agno, left, cleft); in xfs_refcount_merge_left_extent()
497 error = xfs_refcount_lookup_le(cur, cleft->rc_startblock, in xfs_refcount_merge_left_extent()
501 if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) { in xfs_refcount_merge_left_extent()
506 error = xfs_refcount_delete(cur, &found_rec); in xfs_refcount_merge_left_extent()
509 if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) { in xfs_refcount_merge_left_extent()
516 error = xfs_refcount_lookup_le(cur, left->rc_startblock, in xfs_refcount_merge_left_extent()
520 if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) { in xfs_refcount_merge_left_extent()
526 error = xfs_refcount_update(cur, left); in xfs_refcount_merge_left_extent()
535 trace_xfs_refcount_merge_left_extent_error(cur->bc_mp, in xfs_refcount_merge_left_extent()
536 cur->bc_ag.pag->pag_agno, error, _RET_IP_); in xfs_refcount_merge_left_extent()
545 struct xfs_btree_cur *cur, in xfs_refcount_merge_right_extent() argument
553 trace_xfs_refcount_merge_right_extent(cur->bc_mp, in xfs_refcount_merge_right_extent()
554 cur->bc_ag.pag->pag_agno, cright, right); in xfs_refcount_merge_right_extent()
561 error = xfs_refcount_lookup_le(cur, cright->rc_startblock, in xfs_refcount_merge_right_extent()
565 if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) { in xfs_refcount_merge_right_extent()
570 error = xfs_refcount_delete(cur, &found_rec); in xfs_refcount_merge_right_extent()
573 if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) { in xfs_refcount_merge_right_extent()
580 error = xfs_refcount_lookup_le(cur, right->rc_startblock, in xfs_refcount_merge_right_extent()
584 if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) { in xfs_refcount_merge_right_extent()
591 error = xfs_refcount_update(cur, right); in xfs_refcount_merge_right_extent()
599 trace_xfs_refcount_merge_right_extent_error(cur->bc_mp, in xfs_refcount_merge_right_extent()
600 cur->bc_ag.pag->pag_agno, error, _RET_IP_); in xfs_refcount_merge_right_extent()
612 struct xfs_btree_cur *cur, in xfs_refcount_find_left_extents() argument
624 error = xfs_refcount_lookup_le(cur, agbno - 1, &found_rec); in xfs_refcount_find_left_extents()
630 error = xfs_refcount_get_rec(cur, &tmp, &found_rec); in xfs_refcount_find_left_extents()
633 if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) { in xfs_refcount_find_left_extents()
647 error = xfs_btree_increment(cur, 0, &found_rec); in xfs_refcount_find_left_extents()
651 error = xfs_refcount_get_rec(cur, &tmp, &found_rec); in xfs_refcount_find_left_extents()
654 if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) { in xfs_refcount_find_left_extents()
685 trace_xfs_refcount_find_left_extent(cur->bc_mp, cur->bc_ag.pag->pag_agno, in xfs_refcount_find_left_extents()
690 trace_xfs_refcount_find_left_extent_error(cur->bc_mp, in xfs_refcount_find_left_extents()
691 cur->bc_ag.pag->pag_agno, error, _RET_IP_); in xfs_refcount_find_left_extents()
701 struct xfs_btree_cur *cur, in xfs_refcount_find_right_extents() argument
713 error = xfs_refcount_lookup_ge(cur, agbno + aglen, &found_rec); in xfs_refcount_find_right_extents()
719 error = xfs_refcount_get_rec(cur, &tmp, &found_rec); in xfs_refcount_find_right_extents()
722 if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) { in xfs_refcount_find_right_extents()
736 error = xfs_btree_decrement(cur, 0, &found_rec); in xfs_refcount_find_right_extents()
740 error = xfs_refcount_get_rec(cur, &tmp, &found_rec); in xfs_refcount_find_right_extents()
743 if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) { in xfs_refcount_find_right_extents()
774 trace_xfs_refcount_find_right_extent(cur->bc_mp, cur->bc_ag.pag->pag_agno, in xfs_refcount_find_right_extents()
779 trace_xfs_refcount_find_right_extent_error(cur->bc_mp, in xfs_refcount_find_right_extents()
780 cur->bc_ag.pag->pag_agno, error, _RET_IP_); in xfs_refcount_find_right_extents()
797 struct xfs_btree_cur *cur, in xfs_refcount_merge_extents() argument
816 error = xfs_refcount_find_left_extents(cur, &left, &cleft, *agbno, in xfs_refcount_merge_extents()
820 error = xfs_refcount_find_right_extents(cur, &right, &cright, *agbno, in xfs_refcount_merge_extents()
841 return xfs_refcount_merge_center_extents(cur, &left, &cleft, in xfs_refcount_merge_extents()
851 error = xfs_refcount_merge_left_extent(cur, &left, &cleft, in xfs_refcount_merge_extents()
870 return xfs_refcount_merge_right_extent(cur, &right, &cright, in xfs_refcount_merge_extents()
885 struct xfs_btree_cur *cur) in xfs_refcount_still_have_space() argument
889 overhead = cur->bc_ag.refc.shape_changes * in xfs_refcount_still_have_space()
890 xfs_allocfree_log_count(cur->bc_mp, 1); in xfs_refcount_still_have_space()
891 overhead *= cur->bc_mp->m_sb.sb_blocksize; in xfs_refcount_still_have_space()
897 if (cur->bc_ag.refc.nr_ops > 2 && in xfs_refcount_still_have_space()
898 XFS_TEST_ERROR(false, cur->bc_mp, in xfs_refcount_still_have_space()
902 if (cur->bc_ag.refc.nr_ops == 0) in xfs_refcount_still_have_space()
904 else if (overhead > cur->bc_tp->t_log_res) in xfs_refcount_still_have_space()
906 return cur->bc_tp->t_log_res - overhead > in xfs_refcount_still_have_space()
907 cur->bc_ag.refc.nr_ops * XFS_REFCOUNT_ITEM_OVERHEAD; in xfs_refcount_still_have_space()
918 struct xfs_btree_cur *cur, in xfs_refcount_adjust_extents() argument
932 error = xfs_refcount_lookup_ge(cur, *agbno, &found_rec); in xfs_refcount_adjust_extents()
936 while (*aglen > 0 && xfs_refcount_still_have_space(cur)) { in xfs_refcount_adjust_extents()
937 error = xfs_refcount_get_rec(cur, &ext, &found_rec); in xfs_refcount_adjust_extents()
941 ext.rc_startblock = cur->bc_mp->m_sb.sb_agblocks; in xfs_refcount_adjust_extents()
956 trace_xfs_refcount_modify_extent(cur->bc_mp, in xfs_refcount_adjust_extents()
957 cur->bc_ag.pag->pag_agno, &tmp); in xfs_refcount_adjust_extents()
964 error = xfs_refcount_insert(cur, &tmp, in xfs_refcount_adjust_extents()
968 if (XFS_IS_CORRUPT(cur->bc_mp, in xfs_refcount_adjust_extents()
973 cur->bc_ag.refc.nr_ops++; in xfs_refcount_adjust_extents()
975 fsbno = XFS_AGB_TO_FSB(cur->bc_mp, in xfs_refcount_adjust_extents()
976 cur->bc_ag.pag->pag_agno, in xfs_refcount_adjust_extents()
978 xfs_free_extent_later(cur->bc_tp, fsbno, in xfs_refcount_adjust_extents()
985 error = xfs_refcount_lookup_ge(cur, *agbno, in xfs_refcount_adjust_extents()
992 if (*aglen == 0 || !xfs_refcount_still_have_space(cur)) in xfs_refcount_adjust_extents()
1002 trace_xfs_refcount_modify_extent(cur->bc_mp, in xfs_refcount_adjust_extents()
1003 cur->bc_ag.pag->pag_agno, &ext); in xfs_refcount_adjust_extents()
1005 error = xfs_refcount_update(cur, &ext); in xfs_refcount_adjust_extents()
1008 cur->bc_ag.refc.nr_ops++; in xfs_refcount_adjust_extents()
1010 error = xfs_refcount_delete(cur, &found_rec); in xfs_refcount_adjust_extents()
1013 if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) { in xfs_refcount_adjust_extents()
1017 cur->bc_ag.refc.nr_ops++; in xfs_refcount_adjust_extents()
1020 fsbno = XFS_AGB_TO_FSB(cur->bc_mp, in xfs_refcount_adjust_extents()
1021 cur->bc_ag.pag->pag_agno, in xfs_refcount_adjust_extents()
1023 xfs_free_extent_later(cur->bc_tp, fsbno, in xfs_refcount_adjust_extents()
1028 error = xfs_btree_increment(cur, 0, &found_rec); in xfs_refcount_adjust_extents()
1039 trace_xfs_refcount_modify_extent_error(cur->bc_mp, in xfs_refcount_adjust_extents()
1040 cur->bc_ag.pag->pag_agno, error, _RET_IP_); in xfs_refcount_adjust_extents()
1047 struct xfs_btree_cur *cur, in xfs_refcount_adjust() argument
1061 trace_xfs_refcount_increase(cur->bc_mp, cur->bc_ag.pag->pag_agno, in xfs_refcount_adjust()
1064 trace_xfs_refcount_decrease(cur->bc_mp, cur->bc_ag.pag->pag_agno, in xfs_refcount_adjust()
1070 error = xfs_refcount_split_extent(cur, agbno, &shape_changed); in xfs_refcount_adjust()
1076 error = xfs_refcount_split_extent(cur, agbno + aglen, &shape_changed); in xfs_refcount_adjust()
1085 error = xfs_refcount_merge_extents(cur, new_agbno, new_aglen, adj, in xfs_refcount_adjust()
1092 cur->bc_ag.refc.shape_changes++; in xfs_refcount_adjust()
1095 error = xfs_refcount_adjust_extents(cur, new_agbno, new_aglen, adj); in xfs_refcount_adjust()
1102 trace_xfs_refcount_adjust_error(cur->bc_mp, cur->bc_ag.pag->pag_agno, in xfs_refcount_adjust()
1287 struct xfs_btree_cur *cur, in xfs_refcount_find_shared() argument
1299 trace_xfs_refcount_find_shared(cur->bc_mp, cur->bc_ag.pag->pag_agno, in xfs_refcount_find_shared()
1307 error = xfs_refcount_lookup_le(cur, agbno, &have); in xfs_refcount_find_shared()
1312 error = xfs_btree_increment(cur, 0, &have); in xfs_refcount_find_shared()
1318 error = xfs_refcount_get_rec(cur, &tmp, &i); in xfs_refcount_find_shared()
1321 if (XFS_IS_CORRUPT(cur->bc_mp, i != 1)) { in xfs_refcount_find_shared()
1328 error = xfs_btree_increment(cur, 0, &have); in xfs_refcount_find_shared()
1333 error = xfs_refcount_get_rec(cur, &tmp, &i); in xfs_refcount_find_shared()
1336 if (XFS_IS_CORRUPT(cur->bc_mp, i != 1)) { in xfs_refcount_find_shared()
1359 error = xfs_btree_increment(cur, 0, &have); in xfs_refcount_find_shared()
1364 error = xfs_refcount_get_rec(cur, &tmp, &i); in xfs_refcount_find_shared()
1367 if (XFS_IS_CORRUPT(cur->bc_mp, i != 1)) { in xfs_refcount_find_shared()
1378 trace_xfs_refcount_find_shared_result(cur->bc_mp, in xfs_refcount_find_shared()
1379 cur->bc_ag.pag->pag_agno, *fbno, *flen); in xfs_refcount_find_shared()
1383 trace_xfs_refcount_find_shared_error(cur->bc_mp, in xfs_refcount_find_shared()
1384 cur->bc_ag.pag->pag_agno, error, _RET_IP_); in xfs_refcount_find_shared()
1442 struct xfs_btree_cur *cur, in xfs_refcount_adjust_cow_extents() argument
1455 error = xfs_refcount_lookup_ge(cur, agbno, &found_rec); in xfs_refcount_adjust_cow_extents()
1458 error = xfs_refcount_get_rec(cur, &ext, &found_rec); in xfs_refcount_adjust_cow_extents()
1462 ext.rc_startblock = cur->bc_mp->m_sb.sb_agblocks + in xfs_refcount_adjust_cow_extents()
1471 if (XFS_IS_CORRUPT(cur->bc_mp, in xfs_refcount_adjust_cow_extents()
1480 trace_xfs_refcount_modify_extent(cur->bc_mp, in xfs_refcount_adjust_cow_extents()
1481 cur->bc_ag.pag->pag_agno, &tmp); in xfs_refcount_adjust_cow_extents()
1483 error = xfs_refcount_insert(cur, &tmp, in xfs_refcount_adjust_cow_extents()
1487 if (XFS_IS_CORRUPT(cur->bc_mp, found_tmp != 1)) { in xfs_refcount_adjust_cow_extents()
1494 if (XFS_IS_CORRUPT(cur->bc_mp, ext.rc_startblock != agbno)) { in xfs_refcount_adjust_cow_extents()
1498 if (XFS_IS_CORRUPT(cur->bc_mp, ext.rc_blockcount != aglen)) { in xfs_refcount_adjust_cow_extents()
1502 if (XFS_IS_CORRUPT(cur->bc_mp, ext.rc_refcount != 1)) { in xfs_refcount_adjust_cow_extents()
1508 trace_xfs_refcount_modify_extent(cur->bc_mp, in xfs_refcount_adjust_cow_extents()
1509 cur->bc_ag.pag->pag_agno, &ext); in xfs_refcount_adjust_cow_extents()
1510 error = xfs_refcount_delete(cur, &found_rec); in xfs_refcount_adjust_cow_extents()
1513 if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) { in xfs_refcount_adjust_cow_extents()
1524 trace_xfs_refcount_modify_extent_error(cur->bc_mp, in xfs_refcount_adjust_cow_extents()
1525 cur->bc_ag.pag->pag_agno, error, _RET_IP_); in xfs_refcount_adjust_cow_extents()
1534 struct xfs_btree_cur *cur, in xfs_refcount_adjust_cow() argument
1547 error = xfs_refcount_split_extent(cur, agbno, &shape_changed); in xfs_refcount_adjust_cow()
1551 error = xfs_refcount_split_extent(cur, agbno + aglen, &shape_changed); in xfs_refcount_adjust_cow()
1558 error = xfs_refcount_merge_extents(cur, &agbno, &aglen, adj, in xfs_refcount_adjust_cow()
1564 error = xfs_refcount_adjust_cow_extents(cur, agbno, aglen, adj); in xfs_refcount_adjust_cow()
1571 trace_xfs_refcount_adjust_cow_error(cur->bc_mp, cur->bc_ag.pag->pag_agno, in xfs_refcount_adjust_cow()
1655 struct xfs_btree_cur *cur, in xfs_refcount_recover_extent() argument
1662 if (XFS_IS_CORRUPT(cur->bc_mp, in xfs_refcount_recover_extent()
1680 struct xfs_btree_cur *cur; in xfs_refcount_recover_cow_leftovers() local
1712 cur = xfs_refcountbt_init_cursor(mp, tp, agbp, pag); in xfs_refcount_recover_cow_leftovers()
1719 error = xfs_btree_query_range(cur, &low, &high, in xfs_refcount_recover_cow_leftovers()
1721 xfs_btree_del_cursor(cur, error); in xfs_refcount_recover_cow_leftovers()
1769 struct xfs_btree_cur *cur, in xfs_refcount_has_record() argument
1782 return xfs_btree_has_record(cur, &low, &high, exists); in xfs_refcount_has_record()