aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/xfs/libxfs/xfs_alloc.c71
-rw-r--r--fs/xfs/libxfs/xfs_bmap.c121
-rw-r--r--fs/xfs/libxfs/xfs_btree.c18
-rw-r--r--fs/xfs/libxfs/xfs_ialloc.c24
-rw-r--r--fs/xfs/xfs_discard.c2
-rw-r--r--fs/xfs/xfs_error.h4
6 files changed, 124 insertions, 116 deletions
diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
index a6fbf4472017..d38d69a64af4 100644
--- a/fs/xfs/libxfs/xfs_alloc.c
+++ b/fs/xfs/libxfs/xfs_alloc.c
@@ -682,7 +682,7 @@ xfs_alloc_ag_vextent_exact(
682 error = xfs_alloc_get_rec(bno_cur, &fbno, &flen, &i); 682 error = xfs_alloc_get_rec(bno_cur, &fbno, &flen, &i);
683 if (error) 683 if (error)
684 goto error0; 684 goto error0;
685 XFS_WANT_CORRUPTED_GOTO(i == 1, error0); 685 XFS_WANT_CORRUPTED_GOTO(args->mp, i == 1, error0);
686 ASSERT(fbno <= args->agbno); 686 ASSERT(fbno <= args->agbno);
687 687
688 /* 688 /*
@@ -783,7 +783,7 @@ xfs_alloc_find_best_extent(
783 error = xfs_alloc_get_rec(*scur, sbno, slen, &i); 783 error = xfs_alloc_get_rec(*scur, sbno, slen, &i);
784 if (error) 784 if (error)
785 goto error0; 785 goto error0;
786 XFS_WANT_CORRUPTED_GOTO(i == 1, error0); 786 XFS_WANT_CORRUPTED_GOTO(args->mp, i == 1, error0);
787 xfs_alloc_compute_aligned(args, *sbno, *slen, sbnoa, slena); 787 xfs_alloc_compute_aligned(args, *sbno, *slen, sbnoa, slena);
788 788
789 /* 789 /*
@@ -946,7 +946,7 @@ restart:
946 if ((error = xfs_alloc_get_rec(cnt_cur, &ltbno, 946 if ((error = xfs_alloc_get_rec(cnt_cur, &ltbno,
947 &ltlen, &i))) 947 &ltlen, &i)))
948 goto error0; 948 goto error0;
949 XFS_WANT_CORRUPTED_GOTO(i == 1, error0); 949 XFS_WANT_CORRUPTED_GOTO(args->mp, i == 1, error0);
950 if (ltlen >= args->minlen) 950 if (ltlen >= args->minlen)
951 break; 951 break;
952 if ((error = xfs_btree_increment(cnt_cur, 0, &i))) 952 if ((error = xfs_btree_increment(cnt_cur, 0, &i)))
@@ -966,7 +966,7 @@ restart:
966 */ 966 */
967 if ((error = xfs_alloc_get_rec(cnt_cur, &ltbno, &ltlen, &i))) 967 if ((error = xfs_alloc_get_rec(cnt_cur, &ltbno, &ltlen, &i)))
968 goto error0; 968 goto error0;
969 XFS_WANT_CORRUPTED_GOTO(i == 1, error0); 969 XFS_WANT_CORRUPTED_GOTO(args->mp, i == 1, error0);
970 xfs_alloc_compute_aligned(args, ltbno, ltlen, 970 xfs_alloc_compute_aligned(args, ltbno, ltlen,
971 &ltbnoa, &ltlena); 971 &ltbnoa, &ltlena);
972 if (ltlena < args->minlen) 972 if (ltlena < args->minlen)
@@ -999,7 +999,7 @@ restart:
999 cnt_cur->bc_ptrs[0] = besti; 999 cnt_cur->bc_ptrs[0] = besti;
1000 if ((error = xfs_alloc_get_rec(cnt_cur, &ltbno, &ltlen, &i))) 1000 if ((error = xfs_alloc_get_rec(cnt_cur, &ltbno, &ltlen, &i)))
1001 goto error0; 1001 goto error0;
1002 XFS_WANT_CORRUPTED_GOTO(i == 1, error0); 1002 XFS_WANT_CORRUPTED_GOTO(args->mp, i == 1, error0);
1003 ASSERT(ltbno + ltlen <= be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_length)); 1003 ASSERT(ltbno + ltlen <= be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_length));
1004 args->len = blen; 1004 args->len = blen;
1005 if (!xfs_alloc_fix_minleft(args)) { 1005 if (!xfs_alloc_fix_minleft(args)) {
@@ -1088,7 +1088,7 @@ restart:
1088 if (bno_cur_lt) { 1088 if (bno_cur_lt) {
1089 if ((error = xfs_alloc_get_rec(bno_cur_lt, &ltbno, &ltlen, &i))) 1089 if ((error = xfs_alloc_get_rec(bno_cur_lt, &ltbno, &ltlen, &i)))
1090 goto error0; 1090 goto error0;
1091 XFS_WANT_CORRUPTED_GOTO(i == 1, error0); 1091 XFS_WANT_CORRUPTED_GOTO(args->mp, i == 1, error0);
1092 xfs_alloc_compute_aligned(args, ltbno, ltlen, 1092 xfs_alloc_compute_aligned(args, ltbno, ltlen,
1093 &ltbnoa, &ltlena); 1093 &ltbnoa, &ltlena);
1094 if (ltlena >= args->minlen) 1094 if (ltlena >= args->minlen)
@@ -1104,7 +1104,7 @@ restart:
1104 if (bno_cur_gt) { 1104 if (bno_cur_gt) {
1105 if ((error = xfs_alloc_get_rec(bno_cur_gt, &gtbno, &gtlen, &i))) 1105 if ((error = xfs_alloc_get_rec(bno_cur_gt, &gtbno, &gtlen, &i)))
1106 goto error0; 1106 goto error0;
1107 XFS_WANT_CORRUPTED_GOTO(i == 1, error0); 1107 XFS_WANT_CORRUPTED_GOTO(args->mp, i == 1, error0);
1108 xfs_alloc_compute_aligned(args, gtbno, gtlen, 1108 xfs_alloc_compute_aligned(args, gtbno, gtlen,
1109 &gtbnoa, &gtlena); 1109 &gtbnoa, &gtlena);
1110 if (gtlena >= args->minlen) 1110 if (gtlena >= args->minlen)
@@ -1303,7 +1303,7 @@ restart:
1303 error = xfs_alloc_get_rec(cnt_cur, &fbno, &flen, &i); 1303 error = xfs_alloc_get_rec(cnt_cur, &fbno, &flen, &i);
1304 if (error) 1304 if (error)
1305 goto error0; 1305 goto error0;
1306 XFS_WANT_CORRUPTED_GOTO(i == 1, error0); 1306 XFS_WANT_CORRUPTED_GOTO(args->mp, i == 1, error0);
1307 1307
1308 xfs_alloc_compute_aligned(args, fbno, flen, 1308 xfs_alloc_compute_aligned(args, fbno, flen,
1309 &rbno, &rlen); 1309 &rbno, &rlen);
@@ -1342,7 +1342,7 @@ restart:
1342 * This can't happen in the second case above. 1342 * This can't happen in the second case above.
1343 */ 1343 */
1344 rlen = XFS_EXTLEN_MIN(args->maxlen, rlen); 1344 rlen = XFS_EXTLEN_MIN(args->maxlen, rlen);
1345 XFS_WANT_CORRUPTED_GOTO(rlen == 0 || 1345 XFS_WANT_CORRUPTED_GOTO(args->mp, rlen == 0 ||
1346 (rlen <= flen && rbno + rlen <= fbno + flen), error0); 1346 (rlen <= flen && rbno + rlen <= fbno + flen), error0);
1347 if (rlen < args->maxlen) { 1347 if (rlen < args->maxlen) {
1348 xfs_agblock_t bestfbno; 1348 xfs_agblock_t bestfbno;
@@ -1362,13 +1362,13 @@ restart:
1362 if ((error = xfs_alloc_get_rec(cnt_cur, &fbno, &flen, 1362 if ((error = xfs_alloc_get_rec(cnt_cur, &fbno, &flen,
1363 &i))) 1363 &i)))
1364 goto error0; 1364 goto error0;
1365 XFS_WANT_CORRUPTED_GOTO(i == 1, error0); 1365 XFS_WANT_CORRUPTED_GOTO(args->mp, i == 1, error0);
1366 if (flen < bestrlen) 1366 if (flen < bestrlen)
1367 break; 1367 break;
1368 xfs_alloc_compute_aligned(args, fbno, flen, 1368 xfs_alloc_compute_aligned(args, fbno, flen,
1369 &rbno, &rlen); 1369 &rbno, &rlen);
1370 rlen = XFS_EXTLEN_MIN(args->maxlen, rlen); 1370 rlen = XFS_EXTLEN_MIN(args->maxlen, rlen);
1371 XFS_WANT_CORRUPTED_GOTO(rlen == 0 || 1371 XFS_WANT_CORRUPTED_GOTO(args->mp, rlen == 0 ||
1372 (rlen <= flen && rbno + rlen <= fbno + flen), 1372 (rlen <= flen && rbno + rlen <= fbno + flen),
1373 error0); 1373 error0);
1374 if (rlen > bestrlen) { 1374 if (rlen > bestrlen) {
@@ -1383,7 +1383,7 @@ restart:
1383 if ((error = xfs_alloc_lookup_eq(cnt_cur, bestfbno, bestflen, 1383 if ((error = xfs_alloc_lookup_eq(cnt_cur, bestfbno, bestflen,
1384 &i))) 1384 &i)))
1385 goto error0; 1385 goto error0;
1386 XFS_WANT_CORRUPTED_GOTO(i == 1, error0); 1386 XFS_WANT_CORRUPTED_GOTO(args->mp, i == 1, error0);
1387 rlen = bestrlen; 1387 rlen = bestrlen;
1388 rbno = bestrbno; 1388 rbno = bestrbno;
1389 flen = bestflen; 1389 flen = bestflen;
@@ -1408,7 +1408,7 @@ restart:
1408 if (!xfs_alloc_fix_minleft(args)) 1408 if (!xfs_alloc_fix_minleft(args))
1409 goto out_nominleft; 1409 goto out_nominleft;
1410 rlen = args->len; 1410 rlen = args->len;
1411 XFS_WANT_CORRUPTED_GOTO(rlen <= flen, error0); 1411 XFS_WANT_CORRUPTED_GOTO(args->mp, rlen <= flen, error0);
1412 /* 1412 /*
1413 * Allocate and initialize a cursor for the by-block tree. 1413 * Allocate and initialize a cursor for the by-block tree.
1414 */ 1414 */
@@ -1422,7 +1422,7 @@ restart:
1422 cnt_cur = bno_cur = NULL; 1422 cnt_cur = bno_cur = NULL;
1423 args->len = rlen; 1423 args->len = rlen;
1424 args->agbno = rbno; 1424 args->agbno = rbno;
1425 XFS_WANT_CORRUPTED_GOTO( 1425 XFS_WANT_CORRUPTED_GOTO(args->mp,
1426 args->agbno + args->len <= 1426 args->agbno + args->len <=
1427 be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_length), 1427 be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_length),
1428 error0); 1428 error0);
@@ -1467,7 +1467,7 @@ xfs_alloc_ag_vextent_small(
1467 if (i) { 1467 if (i) {
1468 if ((error = xfs_alloc_get_rec(ccur, &fbno, &flen, &i))) 1468 if ((error = xfs_alloc_get_rec(ccur, &fbno, &flen, &i)))
1469 goto error0; 1469 goto error0;
1470 XFS_WANT_CORRUPTED_GOTO(i == 1, error0); 1470 XFS_WANT_CORRUPTED_GOTO(args->mp, i == 1, error0);
1471 } 1471 }
1472 /* 1472 /*
1473 * Nothing in the btree, try the freelist. Make sure 1473 * Nothing in the btree, try the freelist. Make sure
@@ -1493,7 +1493,7 @@ xfs_alloc_ag_vextent_small(
1493 } 1493 }
1494 args->len = 1; 1494 args->len = 1;
1495 args->agbno = fbno; 1495 args->agbno = fbno;
1496 XFS_WANT_CORRUPTED_GOTO( 1496 XFS_WANT_CORRUPTED_GOTO(args->mp,
1497 args->agbno + args->len <= 1497 args->agbno + args->len <=
1498 be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_length), 1498 be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_length),
1499 error0); 1499 error0);
@@ -1579,7 +1579,7 @@ xfs_free_ag_extent(
1579 */ 1579 */
1580 if ((error = xfs_alloc_get_rec(bno_cur, &ltbno, &ltlen, &i))) 1580 if ((error = xfs_alloc_get_rec(bno_cur, &ltbno, &ltlen, &i)))
1581 goto error0; 1581 goto error0;
1582 XFS_WANT_CORRUPTED_GOTO(i == 1, error0); 1582 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, error0);
1583 /* 1583 /*
1584 * It's not contiguous, though. 1584 * It's not contiguous, though.
1585 */ 1585 */
@@ -1591,7 +1591,8 @@ xfs_free_ag_extent(
1591 * space was invalid, it's (partly) already free. 1591 * space was invalid, it's (partly) already free.
1592 * Very bad. 1592 * Very bad.
1593 */ 1593 */
1594 XFS_WANT_CORRUPTED_GOTO(ltbno + ltlen <= bno, error0); 1594 XFS_WANT_CORRUPTED_GOTO(mp,
1595 ltbno + ltlen <= bno, error0);
1595 } 1596 }
1596 } 1597 }
1597 /* 1598 /*
@@ -1606,7 +1607,7 @@ xfs_free_ag_extent(
1606 */ 1607 */
1607 if ((error = xfs_alloc_get_rec(bno_cur, &gtbno, &gtlen, &i))) 1608 if ((error = xfs_alloc_get_rec(bno_cur, &gtbno, &gtlen, &i)))
1608 goto error0; 1609 goto error0;
1609 XFS_WANT_CORRUPTED_GOTO(i == 1, error0); 1610 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, error0);
1610 /* 1611 /*
1611 * It's not contiguous, though. 1612 * It's not contiguous, though.
1612 */ 1613 */
@@ -1618,7 +1619,7 @@ xfs_free_ag_extent(
1618 * space was invalid, it's (partly) already free. 1619 * space was invalid, it's (partly) already free.
1619 * Very bad. 1620 * Very bad.
1620 */ 1621 */
1621 XFS_WANT_CORRUPTED_GOTO(gtbno >= bno + len, error0); 1622 XFS_WANT_CORRUPTED_GOTO(mp, gtbno >= bno + len, error0);
1622 } 1623 }
1623 } 1624 }
1624 /* 1625 /*
@@ -1635,31 +1636,31 @@ xfs_free_ag_extent(
1635 */ 1636 */
1636 if ((error = xfs_alloc_lookup_eq(cnt_cur, ltbno, ltlen, &i))) 1637 if ((error = xfs_alloc_lookup_eq(cnt_cur, ltbno, ltlen, &i)))
1637 goto error0; 1638 goto error0;
1638 XFS_WANT_CORRUPTED_GOTO(i == 1, error0); 1639 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, error0);
1639 if ((error = xfs_btree_delete(cnt_cur, &i))) 1640 if ((error = xfs_btree_delete(cnt_cur, &i)))
1640 goto error0; 1641 goto error0;
1641 XFS_WANT_CORRUPTED_GOTO(i == 1, error0); 1642 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, error0);
1642 /* 1643 /*
1643 * Delete the old by-size entry on the right. 1644 * Delete the old by-size entry on the right.
1644 */ 1645 */
1645 if ((error = xfs_alloc_lookup_eq(cnt_cur, gtbno, gtlen, &i))) 1646 if ((error = xfs_alloc_lookup_eq(cnt_cur, gtbno, gtlen, &i)))
1646 goto error0; 1647 goto error0;
1647 XFS_WANT_CORRUPTED_GOTO(i == 1, error0); 1648 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, error0);
1648 if ((error = xfs_btree_delete(cnt_cur, &i))) 1649 if ((error = xfs_btree_delete(cnt_cur, &i)))
1649 goto error0; 1650 goto error0;
1650 XFS_WANT_CORRUPTED_GOTO(i == 1, error0); 1651 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, error0);
1651 /* 1652 /*
1652 * Delete the old by-block entry for the right block. 1653 * Delete the old by-block entry for the right block.
1653 */ 1654 */
1654 if ((error = xfs_btree_delete(bno_cur, &i))) 1655 if ((error = xfs_btree_delete(bno_cur, &i)))
1655 goto error0; 1656 goto error0;
1656 XFS_WANT_CORRUPTED_GOTO(i == 1, error0); 1657 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, error0);
1657 /* 1658 /*
1658 * Move the by-block cursor back to the left neighbor. 1659 * Move the by-block cursor back to the left neighbor.
1659 */ 1660 */
1660 if ((error = xfs_btree_decrement(bno_cur, 0, &i))) 1661 if ((error = xfs_btree_decrement(bno_cur, 0, &i)))
1661 goto error0; 1662 goto error0;
1662 XFS_WANT_CORRUPTED_GOTO(i == 1, error0); 1663 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, error0);
1663#ifdef DEBUG 1664#ifdef DEBUG
1664 /* 1665 /*
1665 * Check that this is the right record: delete didn't 1666 * Check that this is the right record: delete didn't
@@ -1672,7 +1673,7 @@ xfs_free_ag_extent(
1672 if ((error = xfs_alloc_get_rec(bno_cur, &xxbno, &xxlen, 1673 if ((error = xfs_alloc_get_rec(bno_cur, &xxbno, &xxlen,
1673 &i))) 1674 &i)))
1674 goto error0; 1675 goto error0;
1675 XFS_WANT_CORRUPTED_GOTO( 1676 XFS_WANT_CORRUPTED_GOTO(mp,
1676 i == 1 && xxbno == ltbno && xxlen == ltlen, 1677 i == 1 && xxbno == ltbno && xxlen == ltlen,
1677 error0); 1678 error0);
1678 } 1679 }
@@ -1695,17 +1696,17 @@ xfs_free_ag_extent(
1695 */ 1696 */
1696 if ((error = xfs_alloc_lookup_eq(cnt_cur, ltbno, ltlen, &i))) 1697 if ((error = xfs_alloc_lookup_eq(cnt_cur, ltbno, ltlen, &i)))
1697 goto error0; 1698 goto error0;
1698 XFS_WANT_CORRUPTED_GOTO(i == 1, error0); 1699 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, error0);
1699 if ((error = xfs_btree_delete(cnt_cur, &i))) 1700 if ((error = xfs_btree_delete(cnt_cur, &i)))
1700 goto error0; 1701 goto error0;
1701 XFS_WANT_CORRUPTED_GOTO(i == 1, error0); 1702 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, error0);
1702 /* 1703 /*
1703 * Back up the by-block cursor to the left neighbor, and 1704 * Back up the by-block cursor to the left neighbor, and
1704 * update its length. 1705 * update its length.
1705 */ 1706 */
1706 if ((error = xfs_btree_decrement(bno_cur, 0, &i))) 1707 if ((error = xfs_btree_decrement(bno_cur, 0, &i)))
1707 goto error0; 1708 goto error0;
1708 XFS_WANT_CORRUPTED_GOTO(i == 1, error0); 1709 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, error0);
1709 nbno = ltbno; 1710 nbno = ltbno;
1710 nlen = len + ltlen; 1711 nlen = len + ltlen;
1711 if ((error = xfs_alloc_update(bno_cur, nbno, nlen))) 1712 if ((error = xfs_alloc_update(bno_cur, nbno, nlen)))
@@ -1721,10 +1722,10 @@ xfs_free_ag_extent(
1721 */ 1722 */
1722 if ((error = xfs_alloc_lookup_eq(cnt_cur, gtbno, gtlen, &i))) 1723 if ((error = xfs_alloc_lookup_eq(cnt_cur, gtbno, gtlen, &i)))
1723 goto error0; 1724 goto error0;
1724 XFS_WANT_CORRUPTED_GOTO(i == 1, error0); 1725 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, error0);
1725 if ((error = xfs_btree_delete(cnt_cur, &i))) 1726 if ((error = xfs_btree_delete(cnt_cur, &i)))
1726 goto error0; 1727 goto error0;
1727 XFS_WANT_CORRUPTED_GOTO(i == 1, error0); 1728 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, error0);
1728 /* 1729 /*
1729 * Update the starting block and length of the right 1730 * Update the starting block and length of the right
1730 * neighbor in the by-block tree. 1731 * neighbor in the by-block tree.
@@ -1743,7 +1744,7 @@ xfs_free_ag_extent(
1743 nlen = len; 1744 nlen = len;
1744 if ((error = xfs_btree_insert(bno_cur, &i))) 1745 if ((error = xfs_btree_insert(bno_cur, &i)))
1745 goto error0; 1746 goto error0;
1746 XFS_WANT_CORRUPTED_GOTO(i == 1, error0); 1747 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, error0);
1747 } 1748 }
1748 xfs_btree_del_cursor(bno_cur, XFS_BTREE_NOERROR); 1749 xfs_btree_del_cursor(bno_cur, XFS_BTREE_NOERROR);
1749 bno_cur = NULL; 1750 bno_cur = NULL;
@@ -1752,10 +1753,10 @@ xfs_free_ag_extent(
1752 */ 1753 */
1753 if ((error = xfs_alloc_lookup_eq(cnt_cur, nbno, nlen, &i))) 1754 if ((error = xfs_alloc_lookup_eq(cnt_cur, nbno, nlen, &i)))
1754 goto error0; 1755 goto error0;
1755 XFS_WANT_CORRUPTED_GOTO(i == 0, error0); 1756 XFS_WANT_CORRUPTED_GOTO(mp, i == 0, error0);
1756 if ((error = xfs_btree_insert(cnt_cur, &i))) 1757 if ((error = xfs_btree_insert(cnt_cur, &i)))
1757 goto error0; 1758 goto error0;
1758 XFS_WANT_CORRUPTED_GOTO(i == 1, error0); 1759 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, error0);
1759 xfs_btree_del_cursor(cnt_cur, XFS_BTREE_NOERROR); 1760 xfs_btree_del_cursor(cnt_cur, XFS_BTREE_NOERROR);
1760 cnt_cur = NULL; 1761 cnt_cur = NULL;
1761 1762
diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index 61ec015dca16..c52ef579b86c 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -410,7 +410,7 @@ xfs_bmap_check_leaf_extents(
410 goto error_norelse; 410 goto error_norelse;
411 } 411 }
412 block = XFS_BUF_TO_BLOCK(bp); 412 block = XFS_BUF_TO_BLOCK(bp);
413 XFS_WANT_CORRUPTED_GOTO( 413 XFS_WANT_CORRUPTED_GOTO(mp,
414 xfs_bmap_sanity_check(mp, bp, level), 414 xfs_bmap_sanity_check(mp, bp, level),
415 error0); 415 error0);
416 if (level == 0) 416 if (level == 0)
@@ -424,7 +424,8 @@ xfs_bmap_check_leaf_extents(
424 xfs_check_block(block, mp, 0, 0); 424 xfs_check_block(block, mp, 0, 0);
425 pp = XFS_BMBT_PTR_ADDR(mp, block, 1, mp->m_bmap_dmxr[1]); 425 pp = XFS_BMBT_PTR_ADDR(mp, block, 1, mp->m_bmap_dmxr[1]);
426 bno = be64_to_cpu(*pp); 426 bno = be64_to_cpu(*pp);
427 XFS_WANT_CORRUPTED_GOTO(XFS_FSB_SANITY_CHECK(mp, bno), error0); 427 XFS_WANT_CORRUPTED_GOTO(mp,
428 XFS_FSB_SANITY_CHECK(mp, bno), error0);
428 if (bp_release) { 429 if (bp_release) {
429 bp_release = 0; 430 bp_release = 0;
430 xfs_trans_brelse(NULL, bp); 431 xfs_trans_brelse(NULL, bp);
@@ -1029,7 +1030,7 @@ xfs_bmap_add_attrfork_btree(
1029 if ((error = xfs_bmbt_lookup_ge(cur, 0, 0, 0, &stat))) 1030 if ((error = xfs_bmbt_lookup_ge(cur, 0, 0, 0, &stat)))
1030 goto error0; 1031 goto error0;
1031 /* must be at least one entry */ 1032 /* must be at least one entry */
1032 XFS_WANT_CORRUPTED_GOTO(stat == 1, error0); 1033 XFS_WANT_CORRUPTED_GOTO(mp, stat == 1, error0);
1033 if ((error = xfs_btree_new_iroot(cur, flags, &stat))) 1034 if ((error = xfs_btree_new_iroot(cur, flags, &stat)))
1034 goto error0; 1035 goto error0;
1035 if (stat == 0) { 1036 if (stat == 0) {
@@ -1311,14 +1312,14 @@ xfs_bmap_read_extents(
1311 if (error) 1312 if (error)
1312 return error; 1313 return error;
1313 block = XFS_BUF_TO_BLOCK(bp); 1314 block = XFS_BUF_TO_BLOCK(bp);
1314 XFS_WANT_CORRUPTED_GOTO( 1315 XFS_WANT_CORRUPTED_GOTO(mp,
1315 xfs_bmap_sanity_check(mp, bp, level), 1316 xfs_bmap_sanity_check(mp, bp, level), error0);
1316 error0);
1317 if (level == 0) 1317 if (level == 0)
1318 break; 1318 break;
1319 pp = XFS_BMBT_PTR_ADDR(mp, block, 1, mp->m_bmap_dmxr[1]); 1319 pp = XFS_BMBT_PTR_ADDR(mp, block, 1, mp->m_bmap_dmxr[1]);
1320 bno = be64_to_cpu(*pp); 1320 bno = be64_to_cpu(*pp);
1321 XFS_WANT_CORRUPTED_GOTO(XFS_FSB_SANITY_CHECK(mp, bno), error0); 1321 XFS_WANT_CORRUPTED_GOTO(mp,
1322 XFS_FSB_SANITY_CHECK(mp, bno), error0);
1322 xfs_trans_brelse(tp, bp); 1323 xfs_trans_brelse(tp, bp);
1323 } 1324 }
1324 /* 1325 /*
@@ -1345,7 +1346,7 @@ xfs_bmap_read_extents(
1345 XFS_ERRLEVEL_LOW, ip->i_mount, block); 1346 XFS_ERRLEVEL_LOW, ip->i_mount, block);
1346 goto error0; 1347 goto error0;
1347 } 1348 }
1348 XFS_WANT_CORRUPTED_GOTO( 1349 XFS_WANT_CORRUPTED_GOTO(mp,
1349 xfs_bmap_sanity_check(mp, bp, 0), 1350 xfs_bmap_sanity_check(mp, bp, 0),
1350 error0); 1351 error0);
1351 /* 1352 /*
@@ -1755,7 +1756,9 @@ xfs_bmap_add_extent_delay_real(
1755 xfs_filblks_t temp=0; /* value for da_new calculations */ 1756 xfs_filblks_t temp=0; /* value for da_new calculations */
1756 xfs_filblks_t temp2=0;/* value for da_new calculations */ 1757 xfs_filblks_t temp2=0;/* value for da_new calculations */
1757 int tmp_rval; /* partial logging flags */ 1758 int tmp_rval; /* partial logging flags */
1759 struct xfs_mount *mp;
1758 1760
1761 mp = bma->tp ? bma->tp->t_mountp : NULL;
1759 ifp = XFS_IFORK_PTR(bma->ip, XFS_DATA_FORK); 1762 ifp = XFS_IFORK_PTR(bma->ip, XFS_DATA_FORK);
1760 1763
1761 ASSERT(bma->idx >= 0); 1764 ASSERT(bma->idx >= 0);
@@ -1866,15 +1869,15 @@ xfs_bmap_add_extent_delay_real(
1866 RIGHT.br_blockcount, &i); 1869 RIGHT.br_blockcount, &i);
1867 if (error) 1870 if (error)
1868 goto done; 1871 goto done;
1869 XFS_WANT_CORRUPTED_GOTO(i == 1, done); 1872 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
1870 error = xfs_btree_delete(bma->cur, &i); 1873 error = xfs_btree_delete(bma->cur, &i);
1871 if (error) 1874 if (error)
1872 goto done; 1875 goto done;
1873 XFS_WANT_CORRUPTED_GOTO(i == 1, done); 1876 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
1874 error = xfs_btree_decrement(bma->cur, 0, &i); 1877 error = xfs_btree_decrement(bma->cur, 0, &i);
1875 if (error) 1878 if (error)
1876 goto done; 1879 goto done;
1877 XFS_WANT_CORRUPTED_GOTO(i == 1, done); 1880 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
1878 error = xfs_bmbt_update(bma->cur, LEFT.br_startoff, 1881 error = xfs_bmbt_update(bma->cur, LEFT.br_startoff,
1879 LEFT.br_startblock, 1882 LEFT.br_startblock,
1880 LEFT.br_blockcount + 1883 LEFT.br_blockcount +
@@ -1907,7 +1910,7 @@ xfs_bmap_add_extent_delay_real(
1907 &i); 1910 &i);
1908 if (error) 1911 if (error)
1909 goto done; 1912 goto done;
1910 XFS_WANT_CORRUPTED_GOTO(i == 1, done); 1913 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
1911 error = xfs_bmbt_update(bma->cur, LEFT.br_startoff, 1914 error = xfs_bmbt_update(bma->cur, LEFT.br_startoff,
1912 LEFT.br_startblock, 1915 LEFT.br_startblock,
1913 LEFT.br_blockcount + 1916 LEFT.br_blockcount +
@@ -1938,7 +1941,7 @@ xfs_bmap_add_extent_delay_real(
1938 RIGHT.br_blockcount, &i); 1941 RIGHT.br_blockcount, &i);
1939 if (error) 1942 if (error)
1940 goto done; 1943 goto done;
1941 XFS_WANT_CORRUPTED_GOTO(i == 1, done); 1944 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
1942 error = xfs_bmbt_update(bma->cur, PREV.br_startoff, 1945 error = xfs_bmbt_update(bma->cur, PREV.br_startoff,
1943 new->br_startblock, 1946 new->br_startblock,
1944 PREV.br_blockcount + 1947 PREV.br_blockcount +
@@ -1968,12 +1971,12 @@ xfs_bmap_add_extent_delay_real(
1968 &i); 1971 &i);
1969 if (error) 1972 if (error)
1970 goto done; 1973 goto done;
1971 XFS_WANT_CORRUPTED_GOTO(i == 0, done); 1974 XFS_WANT_CORRUPTED_GOTO(mp, i == 0, done);
1972 bma->cur->bc_rec.b.br_state = XFS_EXT_NORM; 1975 bma->cur->bc_rec.b.br_state = XFS_EXT_NORM;
1973 error = xfs_btree_insert(bma->cur, &i); 1976 error = xfs_btree_insert(bma->cur, &i);
1974 if (error) 1977 if (error)
1975 goto done; 1978 goto done;
1976 XFS_WANT_CORRUPTED_GOTO(i == 1, done); 1979 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
1977 } 1980 }
1978 break; 1981 break;
1979 1982
@@ -2001,7 +2004,7 @@ xfs_bmap_add_extent_delay_real(
2001 &i); 2004 &i);
2002 if (error) 2005 if (error)
2003 goto done; 2006 goto done;
2004 XFS_WANT_CORRUPTED_GOTO(i == 1, done); 2007 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
2005 error = xfs_bmbt_update(bma->cur, LEFT.br_startoff, 2008 error = xfs_bmbt_update(bma->cur, LEFT.br_startoff,
2006 LEFT.br_startblock, 2009 LEFT.br_startblock,
2007 LEFT.br_blockcount + 2010 LEFT.br_blockcount +
@@ -2038,12 +2041,12 @@ xfs_bmap_add_extent_delay_real(
2038 &i); 2041 &i);
2039 if (error) 2042 if (error)
2040 goto done; 2043 goto done;
2041 XFS_WANT_CORRUPTED_GOTO(i == 0, done); 2044 XFS_WANT_CORRUPTED_GOTO(mp, i == 0, done);
2042 bma->cur->bc_rec.b.br_state = XFS_EXT_NORM; 2045 bma->cur->bc_rec.b.br_state = XFS_EXT_NORM;
2043 error = xfs_btree_insert(bma->cur, &i); 2046 error = xfs_btree_insert(bma->cur, &i);
2044 if (error) 2047 if (error)
2045 goto done; 2048 goto done;
2046 XFS_WANT_CORRUPTED_GOTO(i == 1, done); 2049 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
2047 } 2050 }
2048 2051
2049 if (xfs_bmap_needs_btree(bma->ip, XFS_DATA_FORK)) { 2052 if (xfs_bmap_needs_btree(bma->ip, XFS_DATA_FORK)) {
@@ -2084,7 +2087,7 @@ xfs_bmap_add_extent_delay_real(
2084 RIGHT.br_blockcount, &i); 2087 RIGHT.br_blockcount, &i);
2085 if (error) 2088 if (error)
2086 goto done; 2089 goto done;
2087 XFS_WANT_CORRUPTED_GOTO(i == 1, done); 2090 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
2088 error = xfs_bmbt_update(bma->cur, new->br_startoff, 2091 error = xfs_bmbt_update(bma->cur, new->br_startoff,
2089 new->br_startblock, 2092 new->br_startblock,
2090 new->br_blockcount + 2093 new->br_blockcount +
@@ -2122,12 +2125,12 @@ xfs_bmap_add_extent_delay_real(
2122 &i); 2125 &i);
2123 if (error) 2126 if (error)
2124 goto done; 2127 goto done;
2125 XFS_WANT_CORRUPTED_GOTO(i == 0, done); 2128 XFS_WANT_CORRUPTED_GOTO(mp, i == 0, done);
2126 bma->cur->bc_rec.b.br_state = XFS_EXT_NORM; 2129 bma->cur->bc_rec.b.br_state = XFS_EXT_NORM;
2127 error = xfs_btree_insert(bma->cur, &i); 2130 error = xfs_btree_insert(bma->cur, &i);
2128 if (error) 2131 if (error)
2129 goto done; 2132 goto done;
2130 XFS_WANT_CORRUPTED_GOTO(i == 1, done); 2133 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
2131 } 2134 }
2132 2135
2133 if (xfs_bmap_needs_btree(bma->ip, XFS_DATA_FORK)) { 2136 if (xfs_bmap_needs_btree(bma->ip, XFS_DATA_FORK)) {
@@ -2191,12 +2194,12 @@ xfs_bmap_add_extent_delay_real(
2191 &i); 2194 &i);
2192 if (error) 2195 if (error)
2193 goto done; 2196 goto done;
2194 XFS_WANT_CORRUPTED_GOTO(i == 0, done); 2197 XFS_WANT_CORRUPTED_GOTO(mp, i == 0, done);
2195 bma->cur->bc_rec.b.br_state = XFS_EXT_NORM; 2198 bma->cur->bc_rec.b.br_state = XFS_EXT_NORM;
2196 error = xfs_btree_insert(bma->cur, &i); 2199 error = xfs_btree_insert(bma->cur, &i);
2197 if (error) 2200 if (error)
2198 goto done; 2201 goto done;
2199 XFS_WANT_CORRUPTED_GOTO(i == 1, done); 2202 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
2200 } 2203 }
2201 2204
2202 if (xfs_bmap_needs_btree(bma->ip, XFS_DATA_FORK)) { 2205 if (xfs_bmap_needs_btree(bma->ip, XFS_DATA_FORK)) {
@@ -2309,6 +2312,7 @@ xfs_bmap_add_extent_unwritten_real(
2309 /* left is 0, right is 1, prev is 2 */ 2312 /* left is 0, right is 1, prev is 2 */
2310 int rval=0; /* return value (logging flags) */ 2313 int rval=0; /* return value (logging flags) */
2311 int state = 0;/* state bits, accessed thru macros */ 2314 int state = 0;/* state bits, accessed thru macros */
2315 struct xfs_mount *mp = tp->t_mountp;
2312 2316
2313 *logflagsp = 0; 2317 *logflagsp = 0;
2314 2318
@@ -2421,19 +2425,19 @@ xfs_bmap_add_extent_unwritten_real(
2421 RIGHT.br_startblock, 2425 RIGHT.br_startblock,
2422 RIGHT.br_blockcount, &i))) 2426 RIGHT.br_blockcount, &i)))
2423 goto done; 2427 goto done;
2424 XFS_WANT_CORRUPTED_GOTO(i == 1, done); 2428 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
2425 if ((error = xfs_btree_delete(cur, &i))) 2429 if ((error = xfs_btree_delete(cur, &i)))
2426 goto done; 2430 goto done;
2427 XFS_WANT_CORRUPTED_GOTO(i == 1, done); 2431 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
2428 if ((error = xfs_btree_decrement(cur, 0, &i))) 2432 if ((error = xfs_btree_decrement(cur, 0, &i)))
2429 goto done; 2433 goto done;
2430 XFS_WANT_CORRUPTED_GOTO(i == 1, done); 2434 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
2431 if ((error = xfs_btree_delete(cur, &i))) 2435 if ((error = xfs_btree_delete(cur, &i)))
2432 goto done; 2436 goto done;
2433 XFS_WANT_CORRUPTED_GOTO(i == 1, done); 2437 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
2434 if ((error = xfs_btree_decrement(cur, 0, &i))) 2438 if ((error = xfs_btree_decrement(cur, 0, &i)))
2435 goto done; 2439 goto done;
2436 XFS_WANT_CORRUPTED_GOTO(i == 1, done); 2440 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
2437 if ((error = xfs_bmbt_update(cur, LEFT.br_startoff, 2441 if ((error = xfs_bmbt_update(cur, LEFT.br_startoff,
2438 LEFT.br_startblock, 2442 LEFT.br_startblock,
2439 LEFT.br_blockcount + PREV.br_blockcount + 2443 LEFT.br_blockcount + PREV.br_blockcount +
@@ -2464,13 +2468,13 @@ xfs_bmap_add_extent_unwritten_real(
2464 PREV.br_startblock, PREV.br_blockcount, 2468 PREV.br_startblock, PREV.br_blockcount,
2465 &i))) 2469 &i)))
2466 goto done; 2470 goto done;
2467 XFS_WANT_CORRUPTED_GOTO(i == 1, done); 2471 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
2468 if ((error = xfs_btree_delete(cur, &i))) 2472 if ((error = xfs_btree_delete(cur, &i)))
2469 goto done; 2473 goto done;
2470 XFS_WANT_CORRUPTED_GOTO(i == 1, done); 2474 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
2471 if ((error = xfs_btree_decrement(cur, 0, &i))) 2475 if ((error = xfs_btree_decrement(cur, 0, &i)))
2472 goto done; 2476 goto done;
2473 XFS_WANT_CORRUPTED_GOTO(i == 1, done); 2477 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
2474 if ((error = xfs_bmbt_update(cur, LEFT.br_startoff, 2478 if ((error = xfs_bmbt_update(cur, LEFT.br_startoff,
2475 LEFT.br_startblock, 2479 LEFT.br_startblock,
2476 LEFT.br_blockcount + PREV.br_blockcount, 2480 LEFT.br_blockcount + PREV.br_blockcount,
@@ -2499,13 +2503,13 @@ xfs_bmap_add_extent_unwritten_real(
2499 RIGHT.br_startblock, 2503 RIGHT.br_startblock,
2500 RIGHT.br_blockcount, &i))) 2504 RIGHT.br_blockcount, &i)))
2501 goto done; 2505 goto done;
2502 XFS_WANT_CORRUPTED_GOTO(i == 1, done); 2506 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
2503 if ((error = xfs_btree_delete(cur, &i))) 2507 if ((error = xfs_btree_delete(cur, &i)))
2504 goto done; 2508 goto done;
2505 XFS_WANT_CORRUPTED_GOTO(i == 1, done); 2509 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
2506 if ((error = xfs_btree_decrement(cur, 0, &i))) 2510 if ((error = xfs_btree_decrement(cur, 0, &i)))
2507 goto done; 2511 goto done;
2508 XFS_WANT_CORRUPTED_GOTO(i == 1, done); 2512 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
2509 if ((error = xfs_bmbt_update(cur, new->br_startoff, 2513 if ((error = xfs_bmbt_update(cur, new->br_startoff,
2510 new->br_startblock, 2514 new->br_startblock,
2511 new->br_blockcount + RIGHT.br_blockcount, 2515 new->br_blockcount + RIGHT.br_blockcount,
@@ -2532,7 +2536,7 @@ xfs_bmap_add_extent_unwritten_real(
2532 new->br_startblock, new->br_blockcount, 2536 new->br_startblock, new->br_blockcount,
2533 &i))) 2537 &i)))
2534 goto done; 2538 goto done;
2535 XFS_WANT_CORRUPTED_GOTO(i == 1, done); 2539 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
2536 if ((error = xfs_bmbt_update(cur, new->br_startoff, 2540 if ((error = xfs_bmbt_update(cur, new->br_startoff,
2537 new->br_startblock, new->br_blockcount, 2541 new->br_startblock, new->br_blockcount,
2538 newext))) 2542 newext)))
@@ -2569,7 +2573,7 @@ xfs_bmap_add_extent_unwritten_real(
2569 PREV.br_startblock, PREV.br_blockcount, 2573 PREV.br_startblock, PREV.br_blockcount,
2570 &i))) 2574 &i)))
2571 goto done; 2575 goto done;
2572 XFS_WANT_CORRUPTED_GOTO(i == 1, done); 2576 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
2573 if ((error = xfs_bmbt_update(cur, 2577 if ((error = xfs_bmbt_update(cur,
2574 PREV.br_startoff + new->br_blockcount, 2578 PREV.br_startoff + new->br_blockcount,
2575 PREV.br_startblock + new->br_blockcount, 2579 PREV.br_startblock + new->br_blockcount,
@@ -2611,7 +2615,7 @@ xfs_bmap_add_extent_unwritten_real(
2611 PREV.br_startblock, PREV.br_blockcount, 2615 PREV.br_startblock, PREV.br_blockcount,
2612 &i))) 2616 &i)))
2613 goto done; 2617 goto done;
2614 XFS_WANT_CORRUPTED_GOTO(i == 1, done); 2618 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
2615 if ((error = xfs_bmbt_update(cur, 2619 if ((error = xfs_bmbt_update(cur,
2616 PREV.br_startoff + new->br_blockcount, 2620 PREV.br_startoff + new->br_blockcount,
2617 PREV.br_startblock + new->br_blockcount, 2621 PREV.br_startblock + new->br_blockcount,
@@ -2621,7 +2625,7 @@ xfs_bmap_add_extent_unwritten_real(
2621 cur->bc_rec.b = *new; 2625 cur->bc_rec.b = *new;
2622 if ((error = xfs_btree_insert(cur, &i))) 2626 if ((error = xfs_btree_insert(cur, &i)))
2623 goto done; 2627 goto done;
2624 XFS_WANT_CORRUPTED_GOTO(i == 1, done); 2628 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
2625 } 2629 }
2626 break; 2630 break;
2627 2631
@@ -2651,7 +2655,7 @@ xfs_bmap_add_extent_unwritten_real(
2651 PREV.br_startblock, 2655 PREV.br_startblock,
2652 PREV.br_blockcount, &i))) 2656 PREV.br_blockcount, &i)))
2653 goto done; 2657 goto done;
2654 XFS_WANT_CORRUPTED_GOTO(i == 1, done); 2658 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
2655 if ((error = xfs_bmbt_update(cur, PREV.br_startoff, 2659 if ((error = xfs_bmbt_update(cur, PREV.br_startoff,
2656 PREV.br_startblock, 2660 PREV.br_startblock,
2657 PREV.br_blockcount - new->br_blockcount, 2661 PREV.br_blockcount - new->br_blockcount,
@@ -2689,7 +2693,7 @@ xfs_bmap_add_extent_unwritten_real(
2689 PREV.br_startblock, PREV.br_blockcount, 2693 PREV.br_startblock, PREV.br_blockcount,
2690 &i))) 2694 &i)))
2691 goto done; 2695 goto done;
2692 XFS_WANT_CORRUPTED_GOTO(i == 1, done); 2696 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
2693 if ((error = xfs_bmbt_update(cur, PREV.br_startoff, 2697 if ((error = xfs_bmbt_update(cur, PREV.br_startoff,
2694 PREV.br_startblock, 2698 PREV.br_startblock,
2695 PREV.br_blockcount - new->br_blockcount, 2699 PREV.br_blockcount - new->br_blockcount,
@@ -2699,11 +2703,11 @@ xfs_bmap_add_extent_unwritten_real(
2699 new->br_startblock, new->br_blockcount, 2703 new->br_startblock, new->br_blockcount,
2700 &i))) 2704 &i)))
2701 goto done; 2705 goto done;
2702 XFS_WANT_CORRUPTED_GOTO(i == 0, done); 2706 XFS_WANT_CORRUPTED_GOTO(mp, i == 0, done);
2703 cur->bc_rec.b.br_state = XFS_EXT_NORM; 2707 cur->bc_rec.b.br_state = XFS_EXT_NORM;
2704 if ((error = xfs_btree_insert(cur, &i))) 2708 if ((error = xfs_btree_insert(cur, &i)))
2705 goto done; 2709 goto done;
2706 XFS_WANT_CORRUPTED_GOTO(i == 1, done); 2710 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
2707 } 2711 }
2708 break; 2712 break;
2709 2713
@@ -2737,7 +2741,7 @@ xfs_bmap_add_extent_unwritten_real(
2737 PREV.br_startblock, PREV.br_blockcount, 2741 PREV.br_startblock, PREV.br_blockcount,
2738 &i))) 2742 &i)))
2739 goto done; 2743 goto done;
2740 XFS_WANT_CORRUPTED_GOTO(i == 1, done); 2744 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
2741 /* new right extent - oldext */ 2745 /* new right extent - oldext */
2742 if ((error = xfs_bmbt_update(cur, r[1].br_startoff, 2746 if ((error = xfs_bmbt_update(cur, r[1].br_startoff,
2743 r[1].br_startblock, r[1].br_blockcount, 2747 r[1].br_startblock, r[1].br_blockcount,
@@ -2749,7 +2753,7 @@ xfs_bmap_add_extent_unwritten_real(
2749 new->br_startoff - PREV.br_startoff; 2753 new->br_startoff - PREV.br_startoff;
2750 if ((error = xfs_btree_insert(cur, &i))) 2754 if ((error = xfs_btree_insert(cur, &i)))
2751 goto done; 2755 goto done;
2752 XFS_WANT_CORRUPTED_GOTO(i == 1, done); 2756 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
2753 /* 2757 /*
2754 * Reset the cursor to the position of the new extent 2758 * Reset the cursor to the position of the new extent
2755 * we are about to insert as we can't trust it after 2759 * we are about to insert as we can't trust it after
@@ -2759,12 +2763,12 @@ xfs_bmap_add_extent_unwritten_real(
2759 new->br_startblock, new->br_blockcount, 2763 new->br_startblock, new->br_blockcount,
2760 &i))) 2764 &i)))
2761 goto done; 2765 goto done;
2762 XFS_WANT_CORRUPTED_GOTO(i == 0, done); 2766 XFS_WANT_CORRUPTED_GOTO(mp, i == 0, done);
2763 /* new middle extent - newext */ 2767 /* new middle extent - newext */
2764 cur->bc_rec.b.br_state = new->br_state; 2768 cur->bc_rec.b.br_state = new->br_state;
2765 if ((error = xfs_btree_insert(cur, &i))) 2769 if ((error = xfs_btree_insert(cur, &i)))
2766 goto done; 2770 goto done;
2767 XFS_WANT_CORRUPTED_GOTO(i == 1, done); 2771 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
2768 } 2772 }
2769 break; 2773 break;
2770 2774
@@ -2968,7 +2972,9 @@ xfs_bmap_add_extent_hole_real(
2968 xfs_bmbt_irec_t right; /* right neighbor extent entry */ 2972 xfs_bmbt_irec_t right; /* right neighbor extent entry */
2969 int rval=0; /* return value (logging flags) */ 2973 int rval=0; /* return value (logging flags) */
2970 int state; /* state bits, accessed thru macros */ 2974 int state; /* state bits, accessed thru macros */
2975 struct xfs_mount *mp;
2971 2976
2977 mp = bma->tp ? bma->tp->t_mountp : NULL;
2972 ifp = XFS_IFORK_PTR(bma->ip, whichfork); 2978 ifp = XFS_IFORK_PTR(bma->ip, whichfork);
2973 2979
2974 ASSERT(bma->idx >= 0); 2980 ASSERT(bma->idx >= 0);
@@ -3056,15 +3062,15 @@ xfs_bmap_add_extent_hole_real(
3056 &i); 3062 &i);
3057 if (error) 3063 if (error)
3058 goto done; 3064 goto done;
3059 XFS_WANT_CORRUPTED_GOTO(i == 1, done); 3065 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
3060 error = xfs_btree_delete(bma->cur, &i); 3066 error = xfs_btree_delete(bma->cur, &i);
3061 if (error) 3067 if (error)
3062 goto done; 3068 goto done;
3063 XFS_WANT_CORRUPTED_GOTO(i == 1, done); 3069 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
3064 error = xfs_btree_decrement(bma->cur, 0, &i); 3070 error = xfs_btree_decrement(bma->cur, 0, &i);
3065 if (error) 3071 if (error)
3066 goto done; 3072 goto done;
3067 XFS_WANT_CORRUPTED_GOTO(i == 1, done); 3073 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
3068 error = xfs_bmbt_update(bma->cur, left.br_startoff, 3074 error = xfs_bmbt_update(bma->cur, left.br_startoff,
3069 left.br_startblock, 3075 left.br_startblock,
3070 left.br_blockcount + 3076 left.br_blockcount +
@@ -3097,7 +3103,7 @@ xfs_bmap_add_extent_hole_real(
3097 &i); 3103 &i);
3098 if (error) 3104 if (error)
3099 goto done; 3105 goto done;
3100 XFS_WANT_CORRUPTED_GOTO(i == 1, done); 3106 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
3101 error = xfs_bmbt_update(bma->cur, left.br_startoff, 3107 error = xfs_bmbt_update(bma->cur, left.br_startoff,
3102 left.br_startblock, 3108 left.br_startblock,
3103 left.br_blockcount + 3109 left.br_blockcount +
@@ -3131,7 +3137,7 @@ xfs_bmap_add_extent_hole_real(
3131 right.br_blockcount, &i); 3137 right.br_blockcount, &i);
3132 if (error) 3138 if (error)
3133 goto done; 3139 goto done;
3134 XFS_WANT_CORRUPTED_GOTO(i == 1, done); 3140 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
3135 error = xfs_bmbt_update(bma->cur, new->br_startoff, 3141 error = xfs_bmbt_update(bma->cur, new->br_startoff,
3136 new->br_startblock, 3142 new->br_startblock,
3137 new->br_blockcount + 3143 new->br_blockcount +
@@ -3161,12 +3167,12 @@ xfs_bmap_add_extent_hole_real(
3161 new->br_blockcount, &i); 3167 new->br_blockcount, &i);
3162 if (error) 3168 if (error)
3163 goto done; 3169 goto done;
3164 XFS_WANT_CORRUPTED_GOTO(i == 0, done); 3170 XFS_WANT_CORRUPTED_GOTO(mp, i == 0, done);
3165 bma->cur->bc_rec.b.br_state = new->br_state; 3171 bma->cur->bc_rec.b.br_state = new->br_state;
3166 error = xfs_btree_insert(bma->cur, &i); 3172 error = xfs_btree_insert(bma->cur, &i);
3167 if (error) 3173 if (error)
3168 goto done; 3174 goto done;
3169 XFS_WANT_CORRUPTED_GOTO(i == 1, done); 3175 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
3170 } 3176 }
3171 break; 3177 break;
3172 } 3178 }
@@ -4801,7 +4807,7 @@ xfs_bmap_del_extent(
4801 got.br_startblock, got.br_blockcount, 4807 got.br_startblock, got.br_blockcount,
4802 &i))) 4808 &i)))
4803 goto done; 4809 goto done;
4804 XFS_WANT_CORRUPTED_GOTO(i == 1, done); 4810 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
4805 } 4811 }
4806 da_old = da_new = 0; 4812 da_old = da_new = 0;
4807 } else { 4813 } else {
@@ -4835,7 +4841,7 @@ xfs_bmap_del_extent(
4835 } 4841 }
4836 if ((error = xfs_btree_delete(cur, &i))) 4842 if ((error = xfs_btree_delete(cur, &i)))
4837 goto done; 4843 goto done;
4838 XFS_WANT_CORRUPTED_GOTO(i == 1, done); 4844 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
4839 break; 4845 break;
4840 4846
4841 case 2: 4847 case 2:
@@ -4935,7 +4941,8 @@ xfs_bmap_del_extent(
4935 got.br_startblock, 4941 got.br_startblock,
4936 temp, &i))) 4942 temp, &i)))
4937 goto done; 4943 goto done;
4938 XFS_WANT_CORRUPTED_GOTO(i == 1, done); 4944 XFS_WANT_CORRUPTED_GOTO(mp,
4945 i == 1, done);
4939 /* 4946 /*
4940 * Update the btree record back 4947 * Update the btree record back
4941 * to the original value. 4948 * to the original value.
@@ -4956,7 +4963,7 @@ xfs_bmap_del_extent(
4956 error = -ENOSPC; 4963 error = -ENOSPC;
4957 goto done; 4964 goto done;
4958 } 4965 }
4959 XFS_WANT_CORRUPTED_GOTO(i == 1, done); 4966 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
4960 } else 4967 } else
4961 flags |= xfs_ilog_fext(whichfork); 4968 flags |= xfs_ilog_fext(whichfork);
4962 XFS_IFORK_NEXT_SET(ip, whichfork, 4969 XFS_IFORK_NEXT_SET(ip, whichfork,
diff --git a/fs/xfs/libxfs/xfs_btree.c b/fs/xfs/libxfs/xfs_btree.c
index 81cad433df85..8c5ce10e65b3 100644
--- a/fs/xfs/libxfs/xfs_btree.c
+++ b/fs/xfs/libxfs/xfs_btree.c
@@ -2285,7 +2285,7 @@ xfs_btree_rshift(
2285 if (error) 2285 if (error)
2286 goto error0; 2286 goto error0;
2287 i = xfs_btree_lastrec(tcur, level); 2287 i = xfs_btree_lastrec(tcur, level);
2288 XFS_WANT_CORRUPTED_GOTO(i == 1, error0); 2288 XFS_WANT_CORRUPTED_GOTO(cur->bc_mp, i == 1, error0);
2289 2289
2290 error = xfs_btree_increment(tcur, level, &i); 2290 error = xfs_btree_increment(tcur, level, &i);
2291 if (error) 2291 if (error)
@@ -3138,7 +3138,7 @@ xfs_btree_insert(
3138 goto error0; 3138 goto error0;
3139 } 3139 }
3140 3140
3141 XFS_WANT_CORRUPTED_GOTO(i == 1, error0); 3141 XFS_WANT_CORRUPTED_GOTO(cur->bc_mp, i == 1, error0);
3142 level++; 3142 level++;
3143 3143
3144 /* 3144 /*
@@ -3582,15 +3582,15 @@ xfs_btree_delrec(
3582 * Actually any entry but the first would suffice. 3582 * Actually any entry but the first would suffice.
3583 */ 3583 */
3584 i = xfs_btree_lastrec(tcur, level); 3584 i = xfs_btree_lastrec(tcur, level);
3585 XFS_WANT_CORRUPTED_GOTO(i == 1, error0); 3585 XFS_WANT_CORRUPTED_GOTO(cur->bc_mp, i == 1, error0);
3586 3586
3587 error = xfs_btree_increment(tcur, level, &i); 3587 error = xfs_btree_increment(tcur, level, &i);
3588 if (error) 3588 if (error)
3589 goto error0; 3589 goto error0;
3590 XFS_WANT_CORRUPTED_GOTO(i == 1, error0); 3590 XFS_WANT_CORRUPTED_GOTO(cur->bc_mp, i == 1, error0);
3591 3591
3592 i = xfs_btree_lastrec(tcur, level); 3592 i = xfs_btree_lastrec(tcur, level);
3593 XFS_WANT_CORRUPTED_GOTO(i == 1, error0); 3593 XFS_WANT_CORRUPTED_GOTO(cur->bc_mp, i == 1, error0);
3594 3594
3595 /* Grab a pointer to the block. */ 3595 /* Grab a pointer to the block. */
3596 right = xfs_btree_get_block(tcur, level, &rbp); 3596 right = xfs_btree_get_block(tcur, level, &rbp);
@@ -3634,12 +3634,12 @@ xfs_btree_delrec(
3634 rrecs = xfs_btree_get_numrecs(right); 3634 rrecs = xfs_btree_get_numrecs(right);
3635 if (!xfs_btree_ptr_is_null(cur, &lptr)) { 3635 if (!xfs_btree_ptr_is_null(cur, &lptr)) {
3636 i = xfs_btree_firstrec(tcur, level); 3636 i = xfs_btree_firstrec(tcur, level);
3637 XFS_WANT_CORRUPTED_GOTO(i == 1, error0); 3637 XFS_WANT_CORRUPTED_GOTO(cur->bc_mp, i == 1, error0);
3638 3638
3639 error = xfs_btree_decrement(tcur, level, &i); 3639 error = xfs_btree_decrement(tcur, level, &i);
3640 if (error) 3640 if (error)
3641 goto error0; 3641 goto error0;
3642 XFS_WANT_CORRUPTED_GOTO(i == 1, error0); 3642 XFS_WANT_CORRUPTED_GOTO(cur->bc_mp, i == 1, error0);
3643 } 3643 }
3644 } 3644 }
3645 3645
@@ -3653,13 +3653,13 @@ xfs_btree_delrec(
3653 * previous block. 3653 * previous block.
3654 */ 3654 */
3655 i = xfs_btree_firstrec(tcur, level); 3655 i = xfs_btree_firstrec(tcur, level);
3656 XFS_WANT_CORRUPTED_GOTO(i == 1, error0); 3656 XFS_WANT_CORRUPTED_GOTO(cur->bc_mp, i == 1, error0);
3657 3657
3658 error = xfs_btree_decrement(tcur, level, &i); 3658 error = xfs_btree_decrement(tcur, level, &i);
3659 if (error) 3659 if (error)
3660 goto error0; 3660 goto error0;
3661 i = xfs_btree_firstrec(tcur, level); 3661 i = xfs_btree_firstrec(tcur, level);
3662 XFS_WANT_CORRUPTED_GOTO(i == 1, error0); 3662 XFS_WANT_CORRUPTED_GOTO(cur->bc_mp, i == 1, error0);
3663 3663
3664 /* Grab a pointer to the block. */ 3664 /* Grab a pointer to the block. */
3665 left = xfs_btree_get_block(tcur, level, &lbp); 3665 left = xfs_btree_get_block(tcur, level, &lbp);
diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c
index 116ef1ddb3e3..f95c4ae46e28 100644
--- a/fs/xfs/libxfs/xfs_ialloc.c
+++ b/fs/xfs/libxfs/xfs_ialloc.c
@@ -783,12 +783,12 @@ xfs_dialloc_ag_inobt(
783 error = xfs_inobt_lookup(cur, pagino, XFS_LOOKUP_LE, &i); 783 error = xfs_inobt_lookup(cur, pagino, XFS_LOOKUP_LE, &i);
784 if (error) 784 if (error)
785 goto error0; 785 goto error0;
786 XFS_WANT_CORRUPTED_GOTO(i == 1, error0); 786 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, error0);
787 787
788 error = xfs_inobt_get_rec(cur, &rec, &j); 788 error = xfs_inobt_get_rec(cur, &rec, &j);
789 if (error) 789 if (error)
790 goto error0; 790 goto error0;
791 XFS_WANT_CORRUPTED_GOTO(j == 1, error0); 791 XFS_WANT_CORRUPTED_GOTO(mp, j == 1, error0);
792 792
793 if (rec.ir_freecount > 0) { 793 if (rec.ir_freecount > 0) {
794 /* 794 /*
@@ -944,19 +944,19 @@ newino:
944 error = xfs_inobt_lookup(cur, 0, XFS_LOOKUP_GE, &i); 944 error = xfs_inobt_lookup(cur, 0, XFS_LOOKUP_GE, &i);
945 if (error) 945 if (error)
946 goto error0; 946 goto error0;
947 XFS_WANT_CORRUPTED_GOTO(i == 1, error0); 947 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, error0);
948 948
949 for (;;) { 949 for (;;) {
950 error = xfs_inobt_get_rec(cur, &rec, &i); 950 error = xfs_inobt_get_rec(cur, &rec, &i);
951 if (error) 951 if (error)
952 goto error0; 952 goto error0;
953 XFS_WANT_CORRUPTED_GOTO(i == 1, error0); 953 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, error0);
954 if (rec.ir_freecount > 0) 954 if (rec.ir_freecount > 0)
955 break; 955 break;
956 error = xfs_btree_increment(cur, 0, &i); 956 error = xfs_btree_increment(cur, 0, &i);
957 if (error) 957 if (error)
958 goto error0; 958 goto error0;
959 XFS_WANT_CORRUPTED_GOTO(i == 1, error0); 959 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, error0);
960 } 960 }
961 961
962alloc_inode: 962alloc_inode:
@@ -1039,10 +1039,10 @@ xfs_dialloc_ag_finobt_near(
1039 error = xfs_inobt_get_rec(rcur, &rrec, &j); 1039 error = xfs_inobt_get_rec(rcur, &rrec, &j);
1040 if (error) 1040 if (error)
1041 goto error_rcur; 1041 goto error_rcur;
1042 XFS_WANT_CORRUPTED_GOTO(j == 1, error_rcur); 1042 XFS_WANT_CORRUPTED_GOTO(lcur->bc_mp, j == 1, error_rcur);
1043 } 1043 }
1044 1044
1045 XFS_WANT_CORRUPTED_GOTO(i == 1 || j == 1, error_rcur); 1045 XFS_WANT_CORRUPTED_GOTO(lcur->bc_mp, i == 1 || j == 1, error_rcur);
1046 if (i == 1 && j == 1) { 1046 if (i == 1 && j == 1) {
1047 /* 1047 /*
1048 * Both the left and right records are valid. Choose the closer 1048 * Both the left and right records are valid. Choose the closer
@@ -1475,14 +1475,14 @@ xfs_difree_inobt(
1475 __func__, error); 1475 __func__, error);
1476 goto error0; 1476 goto error0;
1477 } 1477 }
1478 XFS_WANT_CORRUPTED_GOTO(i == 1, error0); 1478 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, error0);
1479 error = xfs_inobt_get_rec(cur, &rec, &i); 1479 error = xfs_inobt_get_rec(cur, &rec, &i);
1480 if (error) { 1480 if (error) {
1481 xfs_warn(mp, "%s: xfs_inobt_get_rec() returned error %d.", 1481 xfs_warn(mp, "%s: xfs_inobt_get_rec() returned error %d.",
1482 __func__, error); 1482 __func__, error);
1483 goto error0; 1483 goto error0;
1484 } 1484 }
1485 XFS_WANT_CORRUPTED_GOTO(i == 1, error0); 1485 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, error0);
1486 /* 1486 /*
1487 * Get the offset in the inode chunk. 1487 * Get the offset in the inode chunk.
1488 */ 1488 */
@@ -1592,7 +1592,7 @@ xfs_difree_finobt(
1592 * freed an inode in a previously fully allocated chunk. If not, 1592 * freed an inode in a previously fully allocated chunk. If not,
1593 * something is out of sync. 1593 * something is out of sync.
1594 */ 1594 */
1595 XFS_WANT_CORRUPTED_GOTO(ibtrec->ir_freecount == 1, error); 1595 XFS_WANT_CORRUPTED_GOTO(mp, ibtrec->ir_freecount == 1, error);
1596 1596
1597 error = xfs_inobt_insert_rec(cur, ibtrec->ir_freecount, 1597 error = xfs_inobt_insert_rec(cur, ibtrec->ir_freecount,
1598 ibtrec->ir_free, &i); 1598 ibtrec->ir_free, &i);
@@ -1613,12 +1613,12 @@ xfs_difree_finobt(
1613 error = xfs_inobt_get_rec(cur, &rec, &i); 1613 error = xfs_inobt_get_rec(cur, &rec, &i);
1614 if (error) 1614 if (error)
1615 goto error; 1615 goto error;
1616 XFS_WANT_CORRUPTED_GOTO(i == 1, error); 1616 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, error);
1617 1617
1618 rec.ir_free |= XFS_INOBT_MASK(offset); 1618 rec.ir_free |= XFS_INOBT_MASK(offset);
1619 rec.ir_freecount++; 1619 rec.ir_freecount++;
1620 1620
1621 XFS_WANT_CORRUPTED_GOTO((rec.ir_free == ibtrec->ir_free) && 1621 XFS_WANT_CORRUPTED_GOTO(mp, (rec.ir_free == ibtrec->ir_free) &&
1622 (rec.ir_freecount == ibtrec->ir_freecount), 1622 (rec.ir_freecount == ibtrec->ir_freecount),
1623 error); 1623 error);
1624 1624
diff --git a/fs/xfs/xfs_discard.c b/fs/xfs/xfs_discard.c
index 799e5a2d334d..e85a9519a5ae 100644
--- a/fs/xfs/xfs_discard.c
+++ b/fs/xfs/xfs_discard.c
@@ -84,7 +84,7 @@ xfs_trim_extents(
84 error = xfs_alloc_get_rec(cur, &fbno, &flen, &i); 84 error = xfs_alloc_get_rec(cur, &fbno, &flen, &i);
85 if (error) 85 if (error)
86 goto out_del_cursor; 86 goto out_del_cursor;
87 XFS_WANT_CORRUPTED_GOTO(i == 1, out_del_cursor); 87 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, out_del_cursor);
88 ASSERT(flen <= be32_to_cpu(XFS_BUF_TO_AGF(agbp)->agf_longest)); 88 ASSERT(flen <= be32_to_cpu(XFS_BUF_TO_AGF(agbp)->agf_longest));
89 89
90 /* 90 /*
diff --git a/fs/xfs/xfs_error.h b/fs/xfs/xfs_error.h
index 279a76e52791..13eeca300281 100644
--- a/fs/xfs/xfs_error.h
+++ b/fs/xfs/xfs_error.h
@@ -40,13 +40,13 @@ extern void xfs_verifier_error(struct xfs_buf *bp);
40/* 40/*
41 * Macros to set EFSCORRUPTED & return/branch. 41 * Macros to set EFSCORRUPTED & return/branch.
42 */ 42 */
43#define XFS_WANT_CORRUPTED_GOTO(x,l) \ 43#define XFS_WANT_CORRUPTED_GOTO(mp, x, l) \
44 { \ 44 { \
45 int fs_is_ok = (x); \ 45 int fs_is_ok = (x); \
46 ASSERT(fs_is_ok); \ 46 ASSERT(fs_is_ok); \
47 if (unlikely(!fs_is_ok)) { \ 47 if (unlikely(!fs_is_ok)) { \
48 XFS_ERROR_REPORT("XFS_WANT_CORRUPTED_GOTO", \ 48 XFS_ERROR_REPORT("XFS_WANT_CORRUPTED_GOTO", \
49 XFS_ERRLEVEL_LOW, NULL); \ 49 XFS_ERRLEVEL_LOW, mp); \
50 error = -EFSCORRUPTED; \ 50 error = -EFSCORRUPTED; \
51 goto l; \ 51 goto l; \
52 } \ 52 } \