diff options
Diffstat (limited to 'fs/xfs/xfs_bmap.c')
-rw-r--r-- | fs/xfs/xfs_bmap.c | 152 |
1 files changed, 74 insertions, 78 deletions
diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c index 53c259f5a5af..a1aab9275d5a 100644 --- a/fs/xfs/xfs_bmap.c +++ b/fs/xfs/xfs_bmap.c | |||
@@ -384,14 +384,14 @@ xfs_bmap_count_tree( | |||
384 | int levelin, | 384 | int levelin, |
385 | int *count); | 385 | int *count); |
386 | 386 | ||
387 | STATIC int | 387 | STATIC void |
388 | xfs_bmap_count_leaves( | 388 | xfs_bmap_count_leaves( |
389 | xfs_ifork_t *ifp, | 389 | xfs_ifork_t *ifp, |
390 | xfs_extnum_t idx, | 390 | xfs_extnum_t idx, |
391 | int numrecs, | 391 | int numrecs, |
392 | int *count); | 392 | int *count); |
393 | 393 | ||
394 | STATIC int | 394 | STATIC void |
395 | xfs_bmap_disk_count_leaves( | 395 | xfs_bmap_disk_count_leaves( |
396 | xfs_extnum_t idx, | 396 | xfs_extnum_t idx, |
397 | xfs_bmbt_block_t *block, | 397 | xfs_bmbt_block_t *block, |
@@ -428,7 +428,8 @@ xfs_bmap_add_attrfork_btree( | |||
428 | cur->bc_private.b.firstblock = *firstblock; | 428 | cur->bc_private.b.firstblock = *firstblock; |
429 | if ((error = xfs_bmbt_lookup_ge(cur, 0, 0, 0, &stat))) | 429 | if ((error = xfs_bmbt_lookup_ge(cur, 0, 0, 0, &stat))) |
430 | goto error0; | 430 | goto error0; |
431 | ASSERT(stat == 1); /* must be at least one entry */ | 431 | /* must be at least one entry */ |
432 | XFS_WANT_CORRUPTED_GOTO(stat == 1, error0); | ||
432 | if ((error = xfs_bmbt_newroot(cur, flags, &stat))) | 433 | if ((error = xfs_bmbt_newroot(cur, flags, &stat))) |
433 | goto error0; | 434 | goto error0; |
434 | if (stat == 0) { | 435 | if (stat == 0) { |
@@ -816,13 +817,13 @@ xfs_bmap_add_extent_delay_real( | |||
816 | RIGHT.br_startblock, | 817 | RIGHT.br_startblock, |
817 | RIGHT.br_blockcount, &i))) | 818 | RIGHT.br_blockcount, &i))) |
818 | goto done; | 819 | goto done; |
819 | ASSERT(i == 1); | 820 | XFS_WANT_CORRUPTED_GOTO(i == 1, done); |
820 | if ((error = xfs_bmbt_delete(cur, &i))) | 821 | if ((error = xfs_bmbt_delete(cur, &i))) |
821 | goto done; | 822 | goto done; |
822 | ASSERT(i == 1); | 823 | XFS_WANT_CORRUPTED_GOTO(i == 1, done); |
823 | if ((error = xfs_bmbt_decrement(cur, 0, &i))) | 824 | if ((error = xfs_bmbt_decrement(cur, 0, &i))) |
824 | goto done; | 825 | goto done; |
825 | ASSERT(i == 1); | 826 | XFS_WANT_CORRUPTED_GOTO(i == 1, done); |
826 | if ((error = xfs_bmbt_update(cur, LEFT.br_startoff, | 827 | if ((error = xfs_bmbt_update(cur, LEFT.br_startoff, |
827 | LEFT.br_startblock, | 828 | LEFT.br_startblock, |
828 | LEFT.br_blockcount + | 829 | LEFT.br_blockcount + |
@@ -860,7 +861,7 @@ xfs_bmap_add_extent_delay_real( | |||
860 | LEFT.br_startblock, LEFT.br_blockcount, | 861 | LEFT.br_startblock, LEFT.br_blockcount, |
861 | &i))) | 862 | &i))) |
862 | goto done; | 863 | goto done; |
863 | ASSERT(i == 1); | 864 | XFS_WANT_CORRUPTED_GOTO(i == 1, done); |
864 | if ((error = xfs_bmbt_update(cur, LEFT.br_startoff, | 865 | if ((error = xfs_bmbt_update(cur, LEFT.br_startoff, |
865 | LEFT.br_startblock, | 866 | LEFT.br_startblock, |
866 | LEFT.br_blockcount + | 867 | LEFT.br_blockcount + |
@@ -895,7 +896,7 @@ xfs_bmap_add_extent_delay_real( | |||
895 | RIGHT.br_startblock, | 896 | RIGHT.br_startblock, |
896 | RIGHT.br_blockcount, &i))) | 897 | RIGHT.br_blockcount, &i))) |
897 | goto done; | 898 | goto done; |
898 | ASSERT(i == 1); | 899 | XFS_WANT_CORRUPTED_GOTO(i == 1, done); |
899 | if ((error = xfs_bmbt_update(cur, PREV.br_startoff, | 900 | if ((error = xfs_bmbt_update(cur, PREV.br_startoff, |
900 | new->br_startblock, | 901 | new->br_startblock, |
901 | PREV.br_blockcount + | 902 | PREV.br_blockcount + |
@@ -928,11 +929,11 @@ xfs_bmap_add_extent_delay_real( | |||
928 | new->br_startblock, new->br_blockcount, | 929 | new->br_startblock, new->br_blockcount, |
929 | &i))) | 930 | &i))) |
930 | goto done; | 931 | goto done; |
931 | ASSERT(i == 0); | 932 | XFS_WANT_CORRUPTED_GOTO(i == 0, done); |
932 | cur->bc_rec.b.br_state = XFS_EXT_NORM; | 933 | cur->bc_rec.b.br_state = XFS_EXT_NORM; |
933 | if ((error = xfs_bmbt_insert(cur, &i))) | 934 | if ((error = xfs_bmbt_insert(cur, &i))) |
934 | goto done; | 935 | goto done; |
935 | ASSERT(i == 1); | 936 | XFS_WANT_CORRUPTED_GOTO(i == 1, done); |
936 | } | 937 | } |
937 | *dnew = 0; | 938 | *dnew = 0; |
938 | /* DELTA: The in-core extent described by new changed type. */ | 939 | /* DELTA: The in-core extent described by new changed type. */ |
@@ -963,7 +964,7 @@ xfs_bmap_add_extent_delay_real( | |||
963 | LEFT.br_startblock, LEFT.br_blockcount, | 964 | LEFT.br_startblock, LEFT.br_blockcount, |
964 | &i))) | 965 | &i))) |
965 | goto done; | 966 | goto done; |
966 | ASSERT(i == 1); | 967 | XFS_WANT_CORRUPTED_GOTO(i == 1, done); |
967 | if ((error = xfs_bmbt_update(cur, LEFT.br_startoff, | 968 | if ((error = xfs_bmbt_update(cur, LEFT.br_startoff, |
968 | LEFT.br_startblock, | 969 | LEFT.br_startblock, |
969 | LEFT.br_blockcount + | 970 | LEFT.br_blockcount + |
@@ -1004,11 +1005,11 @@ xfs_bmap_add_extent_delay_real( | |||
1004 | new->br_startblock, new->br_blockcount, | 1005 | new->br_startblock, new->br_blockcount, |
1005 | &i))) | 1006 | &i))) |
1006 | goto done; | 1007 | goto done; |
1007 | ASSERT(i == 0); | 1008 | XFS_WANT_CORRUPTED_GOTO(i == 0, done); |
1008 | cur->bc_rec.b.br_state = XFS_EXT_NORM; | 1009 | cur->bc_rec.b.br_state = XFS_EXT_NORM; |
1009 | if ((error = xfs_bmbt_insert(cur, &i))) | 1010 | if ((error = xfs_bmbt_insert(cur, &i))) |
1010 | goto done; | 1011 | goto done; |
1011 | ASSERT(i == 1); | 1012 | XFS_WANT_CORRUPTED_GOTO(i == 1, done); |
1012 | } | 1013 | } |
1013 | if (ip->i_d.di_format == XFS_DINODE_FMT_EXTENTS && | 1014 | if (ip->i_d.di_format == XFS_DINODE_FMT_EXTENTS && |
1014 | ip->i_d.di_nextents > ip->i_df.if_ext_max) { | 1015 | ip->i_d.di_nextents > ip->i_df.if_ext_max) { |
@@ -1054,7 +1055,7 @@ xfs_bmap_add_extent_delay_real( | |||
1054 | RIGHT.br_startblock, | 1055 | RIGHT.br_startblock, |
1055 | RIGHT.br_blockcount, &i))) | 1056 | RIGHT.br_blockcount, &i))) |
1056 | goto done; | 1057 | goto done; |
1057 | ASSERT(i == 1); | 1058 | XFS_WANT_CORRUPTED_GOTO(i == 1, done); |
1058 | if ((error = xfs_bmbt_update(cur, new->br_startoff, | 1059 | if ((error = xfs_bmbt_update(cur, new->br_startoff, |
1059 | new->br_startblock, | 1060 | new->br_startblock, |
1060 | new->br_blockcount + | 1061 | new->br_blockcount + |
@@ -1094,11 +1095,11 @@ xfs_bmap_add_extent_delay_real( | |||
1094 | new->br_startblock, new->br_blockcount, | 1095 | new->br_startblock, new->br_blockcount, |
1095 | &i))) | 1096 | &i))) |
1096 | goto done; | 1097 | goto done; |
1097 | ASSERT(i == 0); | 1098 | XFS_WANT_CORRUPTED_GOTO(i == 0, done); |
1098 | cur->bc_rec.b.br_state = XFS_EXT_NORM; | 1099 | cur->bc_rec.b.br_state = XFS_EXT_NORM; |
1099 | if ((error = xfs_bmbt_insert(cur, &i))) | 1100 | if ((error = xfs_bmbt_insert(cur, &i))) |
1100 | goto done; | 1101 | goto done; |
1101 | ASSERT(i == 1); | 1102 | XFS_WANT_CORRUPTED_GOTO(i == 1, done); |
1102 | } | 1103 | } |
1103 | if (ip->i_d.di_format == XFS_DINODE_FMT_EXTENTS && | 1104 | if (ip->i_d.di_format == XFS_DINODE_FMT_EXTENTS && |
1104 | ip->i_d.di_nextents > ip->i_df.if_ext_max) { | 1105 | ip->i_d.di_nextents > ip->i_df.if_ext_max) { |
@@ -1149,11 +1150,11 @@ xfs_bmap_add_extent_delay_real( | |||
1149 | new->br_startblock, new->br_blockcount, | 1150 | new->br_startblock, new->br_blockcount, |
1150 | &i))) | 1151 | &i))) |
1151 | goto done; | 1152 | goto done; |
1152 | ASSERT(i == 0); | 1153 | XFS_WANT_CORRUPTED_GOTO(i == 0, done); |
1153 | cur->bc_rec.b.br_state = XFS_EXT_NORM; | 1154 | cur->bc_rec.b.br_state = XFS_EXT_NORM; |
1154 | if ((error = xfs_bmbt_insert(cur, &i))) | 1155 | if ((error = xfs_bmbt_insert(cur, &i))) |
1155 | goto done; | 1156 | goto done; |
1156 | ASSERT(i == 1); | 1157 | XFS_WANT_CORRUPTED_GOTO(i == 1, done); |
1157 | } | 1158 | } |
1158 | if (ip->i_d.di_format == XFS_DINODE_FMT_EXTENTS && | 1159 | if (ip->i_d.di_format == XFS_DINODE_FMT_EXTENTS && |
1159 | ip->i_d.di_nextents > ip->i_df.if_ext_max) { | 1160 | ip->i_d.di_nextents > ip->i_df.if_ext_max) { |
@@ -1377,19 +1378,19 @@ xfs_bmap_add_extent_unwritten_real( | |||
1377 | RIGHT.br_startblock, | 1378 | RIGHT.br_startblock, |
1378 | RIGHT.br_blockcount, &i))) | 1379 | RIGHT.br_blockcount, &i))) |
1379 | goto done; | 1380 | goto done; |
1380 | ASSERT(i == 1); | 1381 | XFS_WANT_CORRUPTED_GOTO(i == 1, done); |
1381 | if ((error = xfs_bmbt_delete(cur, &i))) | 1382 | if ((error = xfs_bmbt_delete(cur, &i))) |
1382 | goto done; | 1383 | goto done; |
1383 | ASSERT(i == 1); | 1384 | XFS_WANT_CORRUPTED_GOTO(i == 1, done); |
1384 | if ((error = xfs_bmbt_decrement(cur, 0, &i))) | 1385 | if ((error = xfs_bmbt_decrement(cur, 0, &i))) |
1385 | goto done; | 1386 | goto done; |
1386 | ASSERT(i == 1); | 1387 | XFS_WANT_CORRUPTED_GOTO(i == 1, done); |
1387 | if ((error = xfs_bmbt_delete(cur, &i))) | 1388 | if ((error = xfs_bmbt_delete(cur, &i))) |
1388 | goto done; | 1389 | goto done; |
1389 | ASSERT(i == 1); | 1390 | XFS_WANT_CORRUPTED_GOTO(i == 1, done); |
1390 | if ((error = xfs_bmbt_decrement(cur, 0, &i))) | 1391 | if ((error = xfs_bmbt_decrement(cur, 0, &i))) |
1391 | goto done; | 1392 | goto done; |
1392 | ASSERT(i == 1); | 1393 | XFS_WANT_CORRUPTED_GOTO(i == 1, done); |
1393 | if ((error = xfs_bmbt_update(cur, LEFT.br_startoff, | 1394 | if ((error = xfs_bmbt_update(cur, LEFT.br_startoff, |
1394 | LEFT.br_startblock, | 1395 | LEFT.br_startblock, |
1395 | LEFT.br_blockcount + PREV.br_blockcount + | 1396 | LEFT.br_blockcount + PREV.br_blockcount + |
@@ -1426,13 +1427,13 @@ xfs_bmap_add_extent_unwritten_real( | |||
1426 | PREV.br_startblock, PREV.br_blockcount, | 1427 | PREV.br_startblock, PREV.br_blockcount, |
1427 | &i))) | 1428 | &i))) |
1428 | goto done; | 1429 | goto done; |
1429 | ASSERT(i == 1); | 1430 | XFS_WANT_CORRUPTED_GOTO(i == 1, done); |
1430 | if ((error = xfs_bmbt_delete(cur, &i))) | 1431 | if ((error = xfs_bmbt_delete(cur, &i))) |
1431 | goto done; | 1432 | goto done; |
1432 | ASSERT(i == 1); | 1433 | XFS_WANT_CORRUPTED_GOTO(i == 1, done); |
1433 | if ((error = xfs_bmbt_decrement(cur, 0, &i))) | 1434 | if ((error = xfs_bmbt_decrement(cur, 0, &i))) |
1434 | goto done; | 1435 | goto done; |
1435 | ASSERT(i == 1); | 1436 | XFS_WANT_CORRUPTED_GOTO(i == 1, done); |
1436 | if ((error = xfs_bmbt_update(cur, LEFT.br_startoff, | 1437 | if ((error = xfs_bmbt_update(cur, LEFT.br_startoff, |
1437 | LEFT.br_startblock, | 1438 | LEFT.br_startblock, |
1438 | LEFT.br_blockcount + PREV.br_blockcount, | 1439 | LEFT.br_blockcount + PREV.br_blockcount, |
@@ -1469,13 +1470,13 @@ xfs_bmap_add_extent_unwritten_real( | |||
1469 | RIGHT.br_startblock, | 1470 | RIGHT.br_startblock, |
1470 | RIGHT.br_blockcount, &i))) | 1471 | RIGHT.br_blockcount, &i))) |
1471 | goto done; | 1472 | goto done; |
1472 | ASSERT(i == 1); | 1473 | XFS_WANT_CORRUPTED_GOTO(i == 1, done); |
1473 | if ((error = xfs_bmbt_delete(cur, &i))) | 1474 | if ((error = xfs_bmbt_delete(cur, &i))) |
1474 | goto done; | 1475 | goto done; |
1475 | ASSERT(i == 1); | 1476 | XFS_WANT_CORRUPTED_GOTO(i == 1, done); |
1476 | if ((error = xfs_bmbt_decrement(cur, 0, &i))) | 1477 | if ((error = xfs_bmbt_decrement(cur, 0, &i))) |
1477 | goto done; | 1478 | goto done; |
1478 | ASSERT(i == 1); | 1479 | XFS_WANT_CORRUPTED_GOTO(i == 1, done); |
1479 | if ((error = xfs_bmbt_update(cur, new->br_startoff, | 1480 | if ((error = xfs_bmbt_update(cur, new->br_startoff, |
1480 | new->br_startblock, | 1481 | new->br_startblock, |
1481 | new->br_blockcount + RIGHT.br_blockcount, | 1482 | new->br_blockcount + RIGHT.br_blockcount, |
@@ -1508,7 +1509,7 @@ xfs_bmap_add_extent_unwritten_real( | |||
1508 | new->br_startblock, new->br_blockcount, | 1509 | new->br_startblock, new->br_blockcount, |
1509 | &i))) | 1510 | &i))) |
1510 | goto done; | 1511 | goto done; |
1511 | ASSERT(i == 1); | 1512 | XFS_WANT_CORRUPTED_GOTO(i == 1, done); |
1512 | if ((error = xfs_bmbt_update(cur, new->br_startoff, | 1513 | if ((error = xfs_bmbt_update(cur, new->br_startoff, |
1513 | new->br_startblock, new->br_blockcount, | 1514 | new->br_startblock, new->br_blockcount, |
1514 | newext))) | 1515 | newext))) |
@@ -1549,7 +1550,7 @@ xfs_bmap_add_extent_unwritten_real( | |||
1549 | PREV.br_startblock, PREV.br_blockcount, | 1550 | PREV.br_startblock, PREV.br_blockcount, |
1550 | &i))) | 1551 | &i))) |
1551 | goto done; | 1552 | goto done; |
1552 | ASSERT(i == 1); | 1553 | XFS_WANT_CORRUPTED_GOTO(i == 1, done); |
1553 | if ((error = xfs_bmbt_update(cur, | 1554 | if ((error = xfs_bmbt_update(cur, |
1554 | PREV.br_startoff + new->br_blockcount, | 1555 | PREV.br_startoff + new->br_blockcount, |
1555 | PREV.br_startblock + new->br_blockcount, | 1556 | PREV.br_startblock + new->br_blockcount, |
@@ -1596,7 +1597,7 @@ xfs_bmap_add_extent_unwritten_real( | |||
1596 | PREV.br_startblock, PREV.br_blockcount, | 1597 | PREV.br_startblock, PREV.br_blockcount, |
1597 | &i))) | 1598 | &i))) |
1598 | goto done; | 1599 | goto done; |
1599 | ASSERT(i == 1); | 1600 | XFS_WANT_CORRUPTED_GOTO(i == 1, done); |
1600 | if ((error = xfs_bmbt_update(cur, | 1601 | if ((error = xfs_bmbt_update(cur, |
1601 | PREV.br_startoff + new->br_blockcount, | 1602 | PREV.br_startoff + new->br_blockcount, |
1602 | PREV.br_startblock + new->br_blockcount, | 1603 | PREV.br_startblock + new->br_blockcount, |
@@ -1606,7 +1607,7 @@ xfs_bmap_add_extent_unwritten_real( | |||
1606 | cur->bc_rec.b = *new; | 1607 | cur->bc_rec.b = *new; |
1607 | if ((error = xfs_bmbt_insert(cur, &i))) | 1608 | if ((error = xfs_bmbt_insert(cur, &i))) |
1608 | goto done; | 1609 | goto done; |
1609 | ASSERT(i == 1); | 1610 | XFS_WANT_CORRUPTED_GOTO(i == 1, done); |
1610 | } | 1611 | } |
1611 | /* DELTA: One in-core extent is split in two. */ | 1612 | /* DELTA: One in-core extent is split in two. */ |
1612 | temp = PREV.br_startoff; | 1613 | temp = PREV.br_startoff; |
@@ -1640,7 +1641,7 @@ xfs_bmap_add_extent_unwritten_real( | |||
1640 | PREV.br_startblock, | 1641 | PREV.br_startblock, |
1641 | PREV.br_blockcount, &i))) | 1642 | PREV.br_blockcount, &i))) |
1642 | goto done; | 1643 | goto done; |
1643 | ASSERT(i == 1); | 1644 | XFS_WANT_CORRUPTED_GOTO(i == 1, done); |
1644 | if ((error = xfs_bmbt_update(cur, PREV.br_startoff, | 1645 | if ((error = xfs_bmbt_update(cur, PREV.br_startoff, |
1645 | PREV.br_startblock, | 1646 | PREV.br_startblock, |
1646 | PREV.br_blockcount - new->br_blockcount, | 1647 | PREV.br_blockcount - new->br_blockcount, |
@@ -1682,7 +1683,7 @@ xfs_bmap_add_extent_unwritten_real( | |||
1682 | PREV.br_startblock, PREV.br_blockcount, | 1683 | PREV.br_startblock, PREV.br_blockcount, |
1683 | &i))) | 1684 | &i))) |
1684 | goto done; | 1685 | goto done; |
1685 | ASSERT(i == 1); | 1686 | XFS_WANT_CORRUPTED_GOTO(i == 1, done); |
1686 | if ((error = xfs_bmbt_update(cur, PREV.br_startoff, | 1687 | if ((error = xfs_bmbt_update(cur, PREV.br_startoff, |
1687 | PREV.br_startblock, | 1688 | PREV.br_startblock, |
1688 | PREV.br_blockcount - new->br_blockcount, | 1689 | PREV.br_blockcount - new->br_blockcount, |
@@ -1692,11 +1693,11 @@ xfs_bmap_add_extent_unwritten_real( | |||
1692 | new->br_startblock, new->br_blockcount, | 1693 | new->br_startblock, new->br_blockcount, |
1693 | &i))) | 1694 | &i))) |
1694 | goto done; | 1695 | goto done; |
1695 | ASSERT(i == 0); | 1696 | XFS_WANT_CORRUPTED_GOTO(i == 0, done); |
1696 | cur->bc_rec.b.br_state = XFS_EXT_NORM; | 1697 | cur->bc_rec.b.br_state = XFS_EXT_NORM; |
1697 | if ((error = xfs_bmbt_insert(cur, &i))) | 1698 | if ((error = xfs_bmbt_insert(cur, &i))) |
1698 | goto done; | 1699 | goto done; |
1699 | ASSERT(i == 1); | 1700 | XFS_WANT_CORRUPTED_GOTO(i == 1, done); |
1700 | } | 1701 | } |
1701 | /* DELTA: One in-core extent is split in two. */ | 1702 | /* DELTA: One in-core extent is split in two. */ |
1702 | temp = PREV.br_startoff; | 1703 | temp = PREV.br_startoff; |
@@ -1732,27 +1733,34 @@ xfs_bmap_add_extent_unwritten_real( | |||
1732 | PREV.br_startblock, PREV.br_blockcount, | 1733 | PREV.br_startblock, PREV.br_blockcount, |
1733 | &i))) | 1734 | &i))) |
1734 | goto done; | 1735 | goto done; |
1735 | ASSERT(i == 1); | 1736 | XFS_WANT_CORRUPTED_GOTO(i == 1, done); |
1736 | /* new right extent - oldext */ | 1737 | /* new right extent - oldext */ |
1737 | if ((error = xfs_bmbt_update(cur, r[1].br_startoff, | 1738 | if ((error = xfs_bmbt_update(cur, r[1].br_startoff, |
1738 | r[1].br_startblock, r[1].br_blockcount, | 1739 | r[1].br_startblock, r[1].br_blockcount, |
1739 | r[1].br_state))) | 1740 | r[1].br_state))) |
1740 | goto done; | 1741 | goto done; |
1741 | /* new left extent - oldext */ | 1742 | /* new left extent - oldext */ |
1742 | PREV.br_blockcount = | ||
1743 | new->br_startoff - PREV.br_startoff; | ||
1744 | cur->bc_rec.b = PREV; | 1743 | cur->bc_rec.b = PREV; |
1744 | cur->bc_rec.b.br_blockcount = | ||
1745 | new->br_startoff - PREV.br_startoff; | ||
1745 | if ((error = xfs_bmbt_insert(cur, &i))) | 1746 | if ((error = xfs_bmbt_insert(cur, &i))) |
1746 | goto done; | 1747 | goto done; |
1747 | ASSERT(i == 1); | 1748 | XFS_WANT_CORRUPTED_GOTO(i == 1, done); |
1748 | if ((error = xfs_bmbt_increment(cur, 0, &i))) | 1749 | /* |
1750 | * Reset the cursor to the position of the new extent | ||
1751 | * we are about to insert as we can't trust it after | ||
1752 | * the previous insert. | ||
1753 | */ | ||
1754 | if ((error = xfs_bmbt_lookup_eq(cur, new->br_startoff, | ||
1755 | new->br_startblock, new->br_blockcount, | ||
1756 | &i))) | ||
1749 | goto done; | 1757 | goto done; |
1750 | ASSERT(i == 1); | 1758 | XFS_WANT_CORRUPTED_GOTO(i == 0, done); |
1751 | /* new middle extent - newext */ | 1759 | /* new middle extent - newext */ |
1752 | cur->bc_rec.b = *new; | 1760 | cur->bc_rec.b.br_state = new->br_state; |
1753 | if ((error = xfs_bmbt_insert(cur, &i))) | 1761 | if ((error = xfs_bmbt_insert(cur, &i))) |
1754 | goto done; | 1762 | goto done; |
1755 | ASSERT(i == 1); | 1763 | XFS_WANT_CORRUPTED_GOTO(i == 1, done); |
1756 | } | 1764 | } |
1757 | /* DELTA: One in-core extent is split in three. */ | 1765 | /* DELTA: One in-core extent is split in three. */ |
1758 | temp = PREV.br_startoff; | 1766 | temp = PREV.br_startoff; |
@@ -2097,13 +2105,13 @@ xfs_bmap_add_extent_hole_real( | |||
2097 | right.br_startblock, | 2105 | right.br_startblock, |
2098 | right.br_blockcount, &i))) | 2106 | right.br_blockcount, &i))) |
2099 | goto done; | 2107 | goto done; |
2100 | ASSERT(i == 1); | 2108 | XFS_WANT_CORRUPTED_GOTO(i == 1, done); |
2101 | if ((error = xfs_bmbt_delete(cur, &i))) | 2109 | if ((error = xfs_bmbt_delete(cur, &i))) |
2102 | goto done; | 2110 | goto done; |
2103 | ASSERT(i == 1); | 2111 | XFS_WANT_CORRUPTED_GOTO(i == 1, done); |
2104 | if ((error = xfs_bmbt_decrement(cur, 0, &i))) | 2112 | if ((error = xfs_bmbt_decrement(cur, 0, &i))) |
2105 | goto done; | 2113 | goto done; |
2106 | ASSERT(i == 1); | 2114 | XFS_WANT_CORRUPTED_GOTO(i == 1, done); |
2107 | if ((error = xfs_bmbt_update(cur, left.br_startoff, | 2115 | if ((error = xfs_bmbt_update(cur, left.br_startoff, |
2108 | left.br_startblock, | 2116 | left.br_startblock, |
2109 | left.br_blockcount + | 2117 | left.br_blockcount + |
@@ -2139,7 +2147,7 @@ xfs_bmap_add_extent_hole_real( | |||
2139 | left.br_startblock, | 2147 | left.br_startblock, |
2140 | left.br_blockcount, &i))) | 2148 | left.br_blockcount, &i))) |
2141 | goto done; | 2149 | goto done; |
2142 | ASSERT(i == 1); | 2150 | XFS_WANT_CORRUPTED_GOTO(i == 1, done); |
2143 | if ((error = xfs_bmbt_update(cur, left.br_startoff, | 2151 | if ((error = xfs_bmbt_update(cur, left.br_startoff, |
2144 | left.br_startblock, | 2152 | left.br_startblock, |
2145 | left.br_blockcount + | 2153 | left.br_blockcount + |
@@ -2174,7 +2182,7 @@ xfs_bmap_add_extent_hole_real( | |||
2174 | right.br_startblock, | 2182 | right.br_startblock, |
2175 | right.br_blockcount, &i))) | 2183 | right.br_blockcount, &i))) |
2176 | goto done; | 2184 | goto done; |
2177 | ASSERT(i == 1); | 2185 | XFS_WANT_CORRUPTED_GOTO(i == 1, done); |
2178 | if ((error = xfs_bmbt_update(cur, new->br_startoff, | 2186 | if ((error = xfs_bmbt_update(cur, new->br_startoff, |
2179 | new->br_startblock, | 2187 | new->br_startblock, |
2180 | new->br_blockcount + | 2188 | new->br_blockcount + |
@@ -2208,11 +2216,11 @@ xfs_bmap_add_extent_hole_real( | |||
2208 | new->br_startblock, | 2216 | new->br_startblock, |
2209 | new->br_blockcount, &i))) | 2217 | new->br_blockcount, &i))) |
2210 | goto done; | 2218 | goto done; |
2211 | ASSERT(i == 0); | 2219 | XFS_WANT_CORRUPTED_GOTO(i == 0, done); |
2212 | cur->bc_rec.b.br_state = new->br_state; | 2220 | cur->bc_rec.b.br_state = new->br_state; |
2213 | if ((error = xfs_bmbt_insert(cur, &i))) | 2221 | if ((error = xfs_bmbt_insert(cur, &i))) |
2214 | goto done; | 2222 | goto done; |
2215 | ASSERT(i == 1); | 2223 | XFS_WANT_CORRUPTED_GOTO(i == 1, done); |
2216 | } | 2224 | } |
2217 | /* DELTA: A new extent was added in a hole. */ | 2225 | /* DELTA: A new extent was added in a hole. */ |
2218 | temp = new->br_startoff; | 2226 | temp = new->br_startoff; |
@@ -3131,7 +3139,7 @@ xfs_bmap_del_extent( | |||
3131 | got.br_startblock, got.br_blockcount, | 3139 | got.br_startblock, got.br_blockcount, |
3132 | &i))) | 3140 | &i))) |
3133 | goto done; | 3141 | goto done; |
3134 | ASSERT(i == 1); | 3142 | XFS_WANT_CORRUPTED_GOTO(i == 1, done); |
3135 | } | 3143 | } |
3136 | da_old = da_new = 0; | 3144 | da_old = da_new = 0; |
3137 | } else { | 3145 | } else { |
@@ -3164,7 +3172,7 @@ xfs_bmap_del_extent( | |||
3164 | } | 3172 | } |
3165 | if ((error = xfs_bmbt_delete(cur, &i))) | 3173 | if ((error = xfs_bmbt_delete(cur, &i))) |
3166 | goto done; | 3174 | goto done; |
3167 | ASSERT(i == 1); | 3175 | XFS_WANT_CORRUPTED_GOTO(i == 1, done); |
3168 | break; | 3176 | break; |
3169 | 3177 | ||
3170 | case 2: | 3178 | case 2: |
@@ -3268,7 +3276,7 @@ xfs_bmap_del_extent( | |||
3268 | got.br_startblock, | 3276 | got.br_startblock, |
3269 | temp, &i))) | 3277 | temp, &i))) |
3270 | goto done; | 3278 | goto done; |
3271 | ASSERT(i == 1); | 3279 | XFS_WANT_CORRUPTED_GOTO(i == 1, done); |
3272 | /* | 3280 | /* |
3273 | * Update the btree record back | 3281 | * Update the btree record back |
3274 | * to the original value. | 3282 | * to the original value. |
@@ -3289,7 +3297,7 @@ xfs_bmap_del_extent( | |||
3289 | error = XFS_ERROR(ENOSPC); | 3297 | error = XFS_ERROR(ENOSPC); |
3290 | goto done; | 3298 | goto done; |
3291 | } | 3299 | } |
3292 | ASSERT(i == 1); | 3300 | XFS_WANT_CORRUPTED_GOTO(i == 1, done); |
3293 | } else | 3301 | } else |
3294 | flags |= XFS_ILOG_FEXT(whichfork); | 3302 | flags |= XFS_ILOG_FEXT(whichfork); |
3295 | XFS_IFORK_NEXT_SET(ip, whichfork, | 3303 | XFS_IFORK_NEXT_SET(ip, whichfork, |
@@ -3992,7 +4000,7 @@ xfs_bmap_add_attrfork( | |||
3992 | ip->i_d.di_aformat = XFS_DINODE_FMT_EXTENTS; | 4000 | ip->i_d.di_aformat = XFS_DINODE_FMT_EXTENTS; |
3993 | } | 4001 | } |
3994 | ASSERT(ip->i_d.di_anextents == 0); | 4002 | ASSERT(ip->i_d.di_anextents == 0); |
3995 | VN_HOLD(XFS_ITOV(ip)); | 4003 | IHOLD(ip); |
3996 | xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); | 4004 | xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); |
3997 | xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); | 4005 | xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); |
3998 | switch (ip->i_d.di_format) { | 4006 | switch (ip->i_d.di_format) { |
@@ -5970,7 +5978,7 @@ unlock_and_return: | |||
5970 | xfs_iunlock_map_shared(ip, lock); | 5978 | xfs_iunlock_map_shared(ip, lock); |
5971 | xfs_iunlock(ip, XFS_IOLOCK_SHARED); | 5979 | xfs_iunlock(ip, XFS_IOLOCK_SHARED); |
5972 | 5980 | ||
5973 | kmem_free(map, subnex * sizeof(*map)); | 5981 | kmem_free(map); |
5974 | 5982 | ||
5975 | return error; | 5983 | return error; |
5976 | } | 5984 | } |
@@ -6088,7 +6096,7 @@ xfs_bmap_get_bp( | |||
6088 | tp = cur->bc_tp; | 6096 | tp = cur->bc_tp; |
6089 | licp = &tp->t_items; | 6097 | licp = &tp->t_items; |
6090 | while (!bp && licp != NULL) { | 6098 | while (!bp && licp != NULL) { |
6091 | if (XFS_LIC_ARE_ALL_FREE(licp)) { | 6099 | if (xfs_lic_are_all_free(licp)) { |
6092 | licp = licp->lic_next; | 6100 | licp = licp->lic_next; |
6093 | continue; | 6101 | continue; |
6094 | } | 6102 | } |
@@ -6098,11 +6106,11 @@ xfs_bmap_get_bp( | |||
6098 | xfs_buf_log_item_t *bip; | 6106 | xfs_buf_log_item_t *bip; |
6099 | xfs_buf_t *lbp; | 6107 | xfs_buf_t *lbp; |
6100 | 6108 | ||
6101 | if (XFS_LIC_ISFREE(licp, i)) { | 6109 | if (xfs_lic_isfree(licp, i)) { |
6102 | continue; | 6110 | continue; |
6103 | } | 6111 | } |
6104 | 6112 | ||
6105 | lidp = XFS_LIC_SLOT(licp, i); | 6113 | lidp = xfs_lic_slot(licp, i); |
6106 | lip = lidp->lid_item; | 6114 | lip = lidp->lid_item; |
6107 | if (lip->li_type != XFS_LI_BUF) | 6115 | if (lip->li_type != XFS_LI_BUF) |
6108 | continue; | 6116 | continue; |
@@ -6359,13 +6367,9 @@ xfs_bmap_count_blocks( | |||
6359 | mp = ip->i_mount; | 6367 | mp = ip->i_mount; |
6360 | ifp = XFS_IFORK_PTR(ip, whichfork); | 6368 | ifp = XFS_IFORK_PTR(ip, whichfork); |
6361 | if ( XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_EXTENTS ) { | 6369 | if ( XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_EXTENTS ) { |
6362 | if (unlikely(xfs_bmap_count_leaves(ifp, 0, | 6370 | xfs_bmap_count_leaves(ifp, 0, |
6363 | ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t), | 6371 | ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t), |
6364 | count) < 0)) { | 6372 | count); |
6365 | XFS_ERROR_REPORT("xfs_bmap_count_blocks(1)", | ||
6366 | XFS_ERRLEVEL_LOW, mp); | ||
6367 | return XFS_ERROR(EFSCORRUPTED); | ||
6368 | } | ||
6369 | return 0; | 6373 | return 0; |
6370 | } | 6374 | } |
6371 | 6375 | ||
@@ -6446,13 +6450,7 @@ xfs_bmap_count_tree( | |||
6446 | for (;;) { | 6450 | for (;;) { |
6447 | nextbno = be64_to_cpu(block->bb_rightsib); | 6451 | nextbno = be64_to_cpu(block->bb_rightsib); |
6448 | numrecs = be16_to_cpu(block->bb_numrecs); | 6452 | numrecs = be16_to_cpu(block->bb_numrecs); |
6449 | if (unlikely(xfs_bmap_disk_count_leaves(0, | 6453 | xfs_bmap_disk_count_leaves(0, block, numrecs, count); |
6450 | block, numrecs, count) < 0)) { | ||
6451 | xfs_trans_brelse(tp, bp); | ||
6452 | XFS_ERROR_REPORT("xfs_bmap_count_tree(2)", | ||
6453 | XFS_ERRLEVEL_LOW, mp); | ||
6454 | return XFS_ERROR(EFSCORRUPTED); | ||
6455 | } | ||
6456 | xfs_trans_brelse(tp, bp); | 6454 | xfs_trans_brelse(tp, bp); |
6457 | if (nextbno == NULLFSBLOCK) | 6455 | if (nextbno == NULLFSBLOCK) |
6458 | break; | 6456 | break; |
@@ -6470,7 +6468,7 @@ xfs_bmap_count_tree( | |||
6470 | /* | 6468 | /* |
6471 | * Count leaf blocks given a range of extent records. | 6469 | * Count leaf blocks given a range of extent records. |
6472 | */ | 6470 | */ |
6473 | STATIC int | 6471 | STATIC void |
6474 | xfs_bmap_count_leaves( | 6472 | xfs_bmap_count_leaves( |
6475 | xfs_ifork_t *ifp, | 6473 | xfs_ifork_t *ifp, |
6476 | xfs_extnum_t idx, | 6474 | xfs_extnum_t idx, |
@@ -6483,14 +6481,13 @@ xfs_bmap_count_leaves( | |||
6483 | xfs_bmbt_rec_host_t *frp = xfs_iext_get_ext(ifp, idx + b); | 6481 | xfs_bmbt_rec_host_t *frp = xfs_iext_get_ext(ifp, idx + b); |
6484 | *count += xfs_bmbt_get_blockcount(frp); | 6482 | *count += xfs_bmbt_get_blockcount(frp); |
6485 | } | 6483 | } |
6486 | return 0; | ||
6487 | } | 6484 | } |
6488 | 6485 | ||
6489 | /* | 6486 | /* |
6490 | * Count leaf blocks given a range of extent records originally | 6487 | * Count leaf blocks given a range of extent records originally |
6491 | * in btree format. | 6488 | * in btree format. |
6492 | */ | 6489 | */ |
6493 | STATIC int | 6490 | STATIC void |
6494 | xfs_bmap_disk_count_leaves( | 6491 | xfs_bmap_disk_count_leaves( |
6495 | xfs_extnum_t idx, | 6492 | xfs_extnum_t idx, |
6496 | xfs_bmbt_block_t *block, | 6493 | xfs_bmbt_block_t *block, |
@@ -6504,5 +6501,4 @@ xfs_bmap_disk_count_leaves( | |||
6504 | frp = XFS_BTREE_REC_ADDR(xfs_bmbt, block, idx + b); | 6501 | frp = XFS_BTREE_REC_ADDR(xfs_bmbt, block, idx + b); |
6505 | *count += xfs_bmbt_disk_get_blockcount(frp); | 6502 | *count += xfs_bmbt_disk_get_blockcount(frp); |
6506 | } | 6503 | } |
6507 | return 0; | ||
6508 | } | 6504 | } |