Commit 989d5ec3 authored by Darrick J. Wong's avatar Darrick J. Wong

xfs: report XFS_IS_CORRUPT errors to the health system

Whenever we encounter XFS_IS_CORRUPT failures, we should report that to
the health monitoring system for later reporting.

I started with this semantic patch and massaged everything until it
built:

@@
expression mp, test;
@@

- if (XFS_IS_CORRUPT(mp, test)) return -EFSCORRUPTED;
+ if (XFS_IS_CORRUPT(mp, test)) { xfs_btree_mark_sick(cur); return -EFSCORRUPTED; }

@@
expression mp, test;
identifier label, error;
@@

- if (XFS_IS_CORRUPT(mp, test)) { error = -EFSCORRUPTED; goto label; }
+ if (XFS_IS_CORRUPT(mp, test)) { xfs_btree_mark_sick(cur); error = -EFSCORRUPTED; goto label; }
Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
parent 8368ad49
...@@ -951,8 +951,10 @@ xfs_ag_shrink_space( ...@@ -951,8 +951,10 @@ xfs_ag_shrink_space(
agf = agfbp->b_addr; agf = agfbp->b_addr;
aglen = be32_to_cpu(agi->agi_length); aglen = be32_to_cpu(agi->agi_length);
/* some extra paranoid checks before we shrink the ag */ /* some extra paranoid checks before we shrink the ag */
if (XFS_IS_CORRUPT(mp, agf->agf_length != agi->agi_length)) if (XFS_IS_CORRUPT(mp, agf->agf_length != agi->agi_length)) {
xfs_ag_mark_sick(pag, XFS_SICK_AG_AGF);
return -EFSCORRUPTED; return -EFSCORRUPTED;
}
if (delta >= aglen) if (delta >= aglen)
return -EINVAL; return -EINVAL;
......
...@@ -499,15 +499,19 @@ xfs_alloc_fixup_trees( ...@@ -499,15 +499,19 @@ xfs_alloc_fixup_trees(
if (XFS_IS_CORRUPT(mp, if (XFS_IS_CORRUPT(mp,
i != 1 || i != 1 ||
nfbno1 != fbno || nfbno1 != fbno ||
nflen1 != flen)) nflen1 != flen)) {
xfs_btree_mark_sick(cnt_cur);
return -EFSCORRUPTED; return -EFSCORRUPTED;
}
#endif #endif
} else { } else {
if ((error = xfs_alloc_lookup_eq(cnt_cur, fbno, flen, &i))) if ((error = xfs_alloc_lookup_eq(cnt_cur, fbno, flen, &i)))
return error; return error;
if (XFS_IS_CORRUPT(mp, i != 1)) if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cnt_cur);
return -EFSCORRUPTED; return -EFSCORRUPTED;
} }
}
/* /*
* Look up the record in the by-block tree if necessary. * Look up the record in the by-block tree if necessary.
*/ */
...@@ -518,15 +522,19 @@ xfs_alloc_fixup_trees( ...@@ -518,15 +522,19 @@ xfs_alloc_fixup_trees(
if (XFS_IS_CORRUPT(mp, if (XFS_IS_CORRUPT(mp,
i != 1 || i != 1 ||
nfbno1 != fbno || nfbno1 != fbno ||
nflen1 != flen)) nflen1 != flen)) {
xfs_btree_mark_sick(bno_cur);
return -EFSCORRUPTED; return -EFSCORRUPTED;
}
#endif #endif
} else { } else {
if ((error = xfs_alloc_lookup_eq(bno_cur, fbno, flen, &i))) if ((error = xfs_alloc_lookup_eq(bno_cur, fbno, flen, &i)))
return error; return error;
if (XFS_IS_CORRUPT(mp, i != 1)) if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(bno_cur);
return -EFSCORRUPTED; return -EFSCORRUPTED;
} }
}
#ifdef DEBUG #ifdef DEBUG
if (bno_cur->bc_nlevels == 1 && cnt_cur->bc_nlevels == 1) { if (bno_cur->bc_nlevels == 1 && cnt_cur->bc_nlevels == 1) {
...@@ -538,9 +546,11 @@ xfs_alloc_fixup_trees( ...@@ -538,9 +546,11 @@ xfs_alloc_fixup_trees(
if (XFS_IS_CORRUPT(mp, if (XFS_IS_CORRUPT(mp,
bnoblock->bb_numrecs != bnoblock->bb_numrecs !=
cntblock->bb_numrecs)) cntblock->bb_numrecs)) {
xfs_btree_mark_sick(bno_cur);
return -EFSCORRUPTED; return -EFSCORRUPTED;
} }
}
#endif #endif
/* /*
...@@ -569,31 +579,41 @@ xfs_alloc_fixup_trees( ...@@ -569,31 +579,41 @@ xfs_alloc_fixup_trees(
*/ */
if ((error = xfs_btree_delete(cnt_cur, &i))) if ((error = xfs_btree_delete(cnt_cur, &i)))
return error; return error;
if (XFS_IS_CORRUPT(mp, i != 1)) if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cnt_cur);
return -EFSCORRUPTED; return -EFSCORRUPTED;
}
/* /*
* Add new by-size btree entry(s). * Add new by-size btree entry(s).
*/ */
if (nfbno1 != NULLAGBLOCK) { if (nfbno1 != NULLAGBLOCK) {
if ((error = xfs_alloc_lookup_eq(cnt_cur, nfbno1, nflen1, &i))) if ((error = xfs_alloc_lookup_eq(cnt_cur, nfbno1, nflen1, &i)))
return error; return error;
if (XFS_IS_CORRUPT(mp, i != 0)) if (XFS_IS_CORRUPT(mp, i != 0)) {
xfs_btree_mark_sick(cnt_cur);
return -EFSCORRUPTED; return -EFSCORRUPTED;
}
if ((error = xfs_btree_insert(cnt_cur, &i))) if ((error = xfs_btree_insert(cnt_cur, &i)))
return error; return error;
if (XFS_IS_CORRUPT(mp, i != 1)) if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cnt_cur);
return -EFSCORRUPTED; return -EFSCORRUPTED;
} }
}
if (nfbno2 != NULLAGBLOCK) { if (nfbno2 != NULLAGBLOCK) {
if ((error = xfs_alloc_lookup_eq(cnt_cur, nfbno2, nflen2, &i))) if ((error = xfs_alloc_lookup_eq(cnt_cur, nfbno2, nflen2, &i)))
return error; return error;
if (XFS_IS_CORRUPT(mp, i != 0)) if (XFS_IS_CORRUPT(mp, i != 0)) {
xfs_btree_mark_sick(cnt_cur);
return -EFSCORRUPTED; return -EFSCORRUPTED;
}
if ((error = xfs_btree_insert(cnt_cur, &i))) if ((error = xfs_btree_insert(cnt_cur, &i)))
return error; return error;
if (XFS_IS_CORRUPT(mp, i != 1)) if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cnt_cur);
return -EFSCORRUPTED; return -EFSCORRUPTED;
} }
}
/* /*
* Fix up the by-block btree entry(s). * Fix up the by-block btree entry(s).
*/ */
...@@ -603,8 +623,10 @@ xfs_alloc_fixup_trees( ...@@ -603,8 +623,10 @@ xfs_alloc_fixup_trees(
*/ */
if ((error = xfs_btree_delete(bno_cur, &i))) if ((error = xfs_btree_delete(bno_cur, &i)))
return error; return error;
if (XFS_IS_CORRUPT(mp, i != 1)) if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(bno_cur);
return -EFSCORRUPTED; return -EFSCORRUPTED;
}
} else { } else {
/* /*
* Update the by-block entry to start later|be shorter. * Update the by-block entry to start later|be shorter.
...@@ -618,13 +640,17 @@ xfs_alloc_fixup_trees( ...@@ -618,13 +640,17 @@ xfs_alloc_fixup_trees(
*/ */
if ((error = xfs_alloc_lookup_eq(bno_cur, nfbno2, nflen2, &i))) if ((error = xfs_alloc_lookup_eq(bno_cur, nfbno2, nflen2, &i)))
return error; return error;
if (XFS_IS_CORRUPT(mp, i != 0)) if (XFS_IS_CORRUPT(mp, i != 0)) {
xfs_btree_mark_sick(bno_cur);
return -EFSCORRUPTED; return -EFSCORRUPTED;
}
if ((error = xfs_btree_insert(bno_cur, &i))) if ((error = xfs_btree_insert(bno_cur, &i)))
return error; return error;
if (XFS_IS_CORRUPT(mp, i != 1)) if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(bno_cur);
return -EFSCORRUPTED; return -EFSCORRUPTED;
} }
}
return 0; return 0;
} }
...@@ -896,8 +922,10 @@ xfs_alloc_cur_check( ...@@ -896,8 +922,10 @@ xfs_alloc_cur_check(
error = xfs_alloc_get_rec(cur, &bno, &len, &i); error = xfs_alloc_get_rec(cur, &bno, &len, &i);
if (error) if (error)
return error; return error;
if (XFS_IS_CORRUPT(args->mp, i != 1)) if (XFS_IS_CORRUPT(args->mp, i != 1)) {
xfs_btree_mark_sick(cur);
return -EFSCORRUPTED; return -EFSCORRUPTED;
}
/* /*
* Check minlen and deactivate a cntbt cursor if out of acceptable size * Check minlen and deactivate a cntbt cursor if out of acceptable size
...@@ -1103,6 +1131,7 @@ xfs_alloc_ag_vextent_small( ...@@ -1103,6 +1131,7 @@ xfs_alloc_ag_vextent_small(
if (error) if (error)
goto error; goto error;
if (XFS_IS_CORRUPT(args->mp, i != 1)) { if (XFS_IS_CORRUPT(args->mp, i != 1)) {
xfs_btree_mark_sick(ccur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto error; goto error;
} }
...@@ -1137,6 +1166,7 @@ xfs_alloc_ag_vextent_small( ...@@ -1137,6 +1166,7 @@ xfs_alloc_ag_vextent_small(
*fbnop = args->agbno = fbno; *fbnop = args->agbno = fbno;
*flenp = args->len = 1; *flenp = args->len = 1;
if (XFS_IS_CORRUPT(args->mp, fbno >= be32_to_cpu(agf->agf_length))) { if (XFS_IS_CORRUPT(args->mp, fbno >= be32_to_cpu(agf->agf_length))) {
xfs_btree_mark_sick(ccur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto error; goto error;
} }
...@@ -1223,6 +1253,7 @@ xfs_alloc_ag_vextent_exact( ...@@ -1223,6 +1253,7 @@ xfs_alloc_ag_vextent_exact(
if (error) if (error)
goto error0; goto error0;
if (XFS_IS_CORRUPT(args->mp, i != 1)) { if (XFS_IS_CORRUPT(args->mp, i != 1)) {
xfs_btree_mark_sick(bno_cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto error0; goto error0;
} }
...@@ -1502,8 +1533,10 @@ xfs_alloc_ag_vextent_lastblock( ...@@ -1502,8 +1533,10 @@ xfs_alloc_ag_vextent_lastblock(
error = xfs_alloc_get_rec(acur->cnt, bno, len, &i); error = xfs_alloc_get_rec(acur->cnt, bno, len, &i);
if (error) if (error)
return error; return error;
if (XFS_IS_CORRUPT(args->mp, i != 1)) if (XFS_IS_CORRUPT(args->mp, i != 1)) {
xfs_btree_mark_sick(acur->cnt);
return -EFSCORRUPTED; return -EFSCORRUPTED;
}
if (*len >= args->minlen) if (*len >= args->minlen)
break; break;
error = xfs_btree_increment(acur->cnt, 0, &i); error = xfs_btree_increment(acur->cnt, 0, &i);
...@@ -1715,6 +1748,7 @@ xfs_alloc_ag_vextent_size( ...@@ -1715,6 +1748,7 @@ xfs_alloc_ag_vextent_size(
if (error) if (error)
goto error0; goto error0;
if (XFS_IS_CORRUPT(args->mp, i != 1)) { if (XFS_IS_CORRUPT(args->mp, i != 1)) {
xfs_btree_mark_sick(cnt_cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto error0; goto error0;
} }
...@@ -1761,6 +1795,7 @@ xfs_alloc_ag_vextent_size( ...@@ -1761,6 +1795,7 @@ xfs_alloc_ag_vextent_size(
rlen != 0 && rlen != 0 &&
(rlen > flen || (rlen > flen ||
rbno + rlen > fbno + flen))) { rbno + rlen > fbno + flen))) {
xfs_btree_mark_sick(cnt_cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto error0; goto error0;
} }
...@@ -1783,6 +1818,7 @@ xfs_alloc_ag_vextent_size( ...@@ -1783,6 +1818,7 @@ xfs_alloc_ag_vextent_size(
&i))) &i)))
goto error0; goto error0;
if (XFS_IS_CORRUPT(args->mp, i != 1)) { if (XFS_IS_CORRUPT(args->mp, i != 1)) {
xfs_btree_mark_sick(cnt_cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto error0; goto error0;
} }
...@@ -1795,6 +1831,7 @@ xfs_alloc_ag_vextent_size( ...@@ -1795,6 +1831,7 @@ xfs_alloc_ag_vextent_size(
rlen != 0 && rlen != 0 &&
(rlen > flen || (rlen > flen ||
rbno + rlen > fbno + flen))) { rbno + rlen > fbno + flen))) {
xfs_btree_mark_sick(cnt_cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto error0; goto error0;
} }
...@@ -1811,6 +1848,7 @@ xfs_alloc_ag_vextent_size( ...@@ -1811,6 +1848,7 @@ xfs_alloc_ag_vextent_size(
&i))) &i)))
goto error0; goto error0;
if (XFS_IS_CORRUPT(args->mp, i != 1)) { if (XFS_IS_CORRUPT(args->mp, i != 1)) {
xfs_btree_mark_sick(cnt_cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto error0; goto error0;
} }
...@@ -1849,6 +1887,7 @@ xfs_alloc_ag_vextent_size( ...@@ -1849,6 +1887,7 @@ xfs_alloc_ag_vextent_size(
rlen = args->len; rlen = args->len;
if (XFS_IS_CORRUPT(args->mp, rlen > flen)) { if (XFS_IS_CORRUPT(args->mp, rlen > flen)) {
xfs_btree_mark_sick(cnt_cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto error0; goto error0;
} }
...@@ -1868,6 +1907,7 @@ xfs_alloc_ag_vextent_size( ...@@ -1868,6 +1907,7 @@ xfs_alloc_ag_vextent_size(
if (XFS_IS_CORRUPT(args->mp, if (XFS_IS_CORRUPT(args->mp,
args->agbno + args->len > args->agbno + args->len >
be32_to_cpu(agf->agf_length))) { be32_to_cpu(agf->agf_length))) {
xfs_ag_mark_sick(args->pag, XFS_SICK_AG_BNOBT);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto error0; goto error0;
} }
...@@ -1943,6 +1983,7 @@ xfs_free_ag_extent( ...@@ -1943,6 +1983,7 @@ xfs_free_ag_extent(
if ((error = xfs_alloc_get_rec(bno_cur, &ltbno, &ltlen, &i))) if ((error = xfs_alloc_get_rec(bno_cur, &ltbno, &ltlen, &i)))
goto error0; goto error0;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(bno_cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto error0; goto error0;
} }
...@@ -1958,6 +1999,7 @@ xfs_free_ag_extent( ...@@ -1958,6 +1999,7 @@ xfs_free_ag_extent(
* Very bad. * Very bad.
*/ */
if (XFS_IS_CORRUPT(mp, ltbno + ltlen > bno)) { if (XFS_IS_CORRUPT(mp, ltbno + ltlen > bno)) {
xfs_btree_mark_sick(bno_cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto error0; goto error0;
} }
...@@ -1976,6 +2018,7 @@ xfs_free_ag_extent( ...@@ -1976,6 +2018,7 @@ xfs_free_ag_extent(
if ((error = xfs_alloc_get_rec(bno_cur, &gtbno, &gtlen, &i))) if ((error = xfs_alloc_get_rec(bno_cur, &gtbno, &gtlen, &i)))
goto error0; goto error0;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(bno_cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto error0; goto error0;
} }
...@@ -1991,6 +2034,7 @@ xfs_free_ag_extent( ...@@ -1991,6 +2034,7 @@ xfs_free_ag_extent(
* Very bad. * Very bad.
*/ */
if (XFS_IS_CORRUPT(mp, bno + len > gtbno)) { if (XFS_IS_CORRUPT(mp, bno + len > gtbno)) {
xfs_btree_mark_sick(bno_cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto error0; goto error0;
} }
...@@ -2011,12 +2055,14 @@ xfs_free_ag_extent( ...@@ -2011,12 +2055,14 @@ xfs_free_ag_extent(
if ((error = xfs_alloc_lookup_eq(cnt_cur, ltbno, ltlen, &i))) if ((error = xfs_alloc_lookup_eq(cnt_cur, ltbno, ltlen, &i)))
goto error0; goto error0;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cnt_cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto error0; goto error0;
} }
if ((error = xfs_btree_delete(cnt_cur, &i))) if ((error = xfs_btree_delete(cnt_cur, &i)))
goto error0; goto error0;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cnt_cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto error0; goto error0;
} }
...@@ -2026,12 +2072,14 @@ xfs_free_ag_extent( ...@@ -2026,12 +2072,14 @@ xfs_free_ag_extent(
if ((error = xfs_alloc_lookup_eq(cnt_cur, gtbno, gtlen, &i))) if ((error = xfs_alloc_lookup_eq(cnt_cur, gtbno, gtlen, &i)))
goto error0; goto error0;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cnt_cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto error0; goto error0;
} }
if ((error = xfs_btree_delete(cnt_cur, &i))) if ((error = xfs_btree_delete(cnt_cur, &i)))
goto error0; goto error0;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cnt_cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto error0; goto error0;
} }
...@@ -2041,6 +2089,7 @@ xfs_free_ag_extent( ...@@ -2041,6 +2089,7 @@ xfs_free_ag_extent(
if ((error = xfs_btree_delete(bno_cur, &i))) if ((error = xfs_btree_delete(bno_cur, &i)))
goto error0; goto error0;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(bno_cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto error0; goto error0;
} }
...@@ -2050,6 +2099,7 @@ xfs_free_ag_extent( ...@@ -2050,6 +2099,7 @@ xfs_free_ag_extent(
if ((error = xfs_btree_decrement(bno_cur, 0, &i))) if ((error = xfs_btree_decrement(bno_cur, 0, &i)))
goto error0; goto error0;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(bno_cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto error0; goto error0;
} }
...@@ -2069,6 +2119,7 @@ xfs_free_ag_extent( ...@@ -2069,6 +2119,7 @@ xfs_free_ag_extent(
i != 1 || i != 1 ||
xxbno != ltbno || xxbno != ltbno ||
xxlen != ltlen)) { xxlen != ltlen)) {
xfs_btree_mark_sick(bno_cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto error0; goto error0;
} }
...@@ -2093,12 +2144,14 @@ xfs_free_ag_extent( ...@@ -2093,12 +2144,14 @@ xfs_free_ag_extent(
if ((error = xfs_alloc_lookup_eq(cnt_cur, ltbno, ltlen, &i))) if ((error = xfs_alloc_lookup_eq(cnt_cur, ltbno, ltlen, &i)))
goto error0; goto error0;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cnt_cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto error0; goto error0;
} }
if ((error = xfs_btree_delete(cnt_cur, &i))) if ((error = xfs_btree_delete(cnt_cur, &i)))
goto error0; goto error0;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cnt_cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto error0; goto error0;
} }
...@@ -2109,6 +2162,7 @@ xfs_free_ag_extent( ...@@ -2109,6 +2162,7 @@ xfs_free_ag_extent(
if ((error = xfs_btree_decrement(bno_cur, 0, &i))) if ((error = xfs_btree_decrement(bno_cur, 0, &i)))
goto error0; goto error0;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(bno_cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto error0; goto error0;
} }
...@@ -2128,12 +2182,14 @@ xfs_free_ag_extent( ...@@ -2128,12 +2182,14 @@ xfs_free_ag_extent(
if ((error = xfs_alloc_lookup_eq(cnt_cur, gtbno, gtlen, &i))) if ((error = xfs_alloc_lookup_eq(cnt_cur, gtbno, gtlen, &i)))
goto error0; goto error0;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cnt_cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto error0; goto error0;
} }
if ((error = xfs_btree_delete(cnt_cur, &i))) if ((error = xfs_btree_delete(cnt_cur, &i)))
goto error0; goto error0;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cnt_cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto error0; goto error0;
} }
...@@ -2156,6 +2212,7 @@ xfs_free_ag_extent( ...@@ -2156,6 +2212,7 @@ xfs_free_ag_extent(
if ((error = xfs_btree_insert(bno_cur, &i))) if ((error = xfs_btree_insert(bno_cur, &i)))
goto error0; goto error0;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(bno_cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto error0; goto error0;
} }
...@@ -2168,12 +2225,14 @@ xfs_free_ag_extent( ...@@ -2168,12 +2225,14 @@ xfs_free_ag_extent(
if ((error = xfs_alloc_lookup_eq(cnt_cur, nbno, nlen, &i))) if ((error = xfs_alloc_lookup_eq(cnt_cur, nbno, nlen, &i)))
goto error0; goto error0;
if (XFS_IS_CORRUPT(mp, i != 0)) { if (XFS_IS_CORRUPT(mp, i != 0)) {
xfs_btree_mark_sick(cnt_cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto error0; goto error0;
} }
if ((error = xfs_btree_insert(cnt_cur, &i))) if ((error = xfs_btree_insert(cnt_cur, &i)))
goto error0; goto error0;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cnt_cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto error0; goto error0;
} }
...@@ -3903,17 +3962,23 @@ __xfs_free_extent( ...@@ -3903,17 +3962,23 @@ __xfs_free_extent(
return -EIO; return -EIO;
error = xfs_free_extent_fix_freelist(tp, pag, &agbp); error = xfs_free_extent_fix_freelist(tp, pag, &agbp);
if (error) if (error) {
if (xfs_metadata_is_sick(error))
xfs_ag_mark_sick(pag, XFS_SICK_AG_BNOBT);
return error; return error;
}
agf = agbp->b_addr; agf = agbp->b_addr;
if (XFS_IS_CORRUPT(mp, agbno >= mp->m_sb.sb_agblocks)) { if (XFS_IS_CORRUPT(mp, agbno >= mp->m_sb.sb_agblocks)) {
xfs_ag_mark_sick(pag, XFS_SICK_AG_BNOBT);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto err_release; goto err_release;
} }
/* validate the extent size is legal now we have the agf locked */ /* validate the extent size is legal now we have the agf locked */
if (XFS_IS_CORRUPT(mp, agbno + len > be32_to_cpu(agf->agf_length))) { if (XFS_IS_CORRUPT(mp, agbno + len > be32_to_cpu(agf->agf_length))) {
xfs_ag_mark_sick(pag, XFS_SICK_AG_BNOBT);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto err_release; goto err_release;
} }
......
...@@ -553,8 +553,10 @@ xfs_attr_rmtval_stale( ...@@ -553,8 +553,10 @@ xfs_attr_rmtval_stale(
xfs_assert_ilocked(ip, XFS_ILOCK_EXCL); xfs_assert_ilocked(ip, XFS_ILOCK_EXCL);
if (XFS_IS_CORRUPT(mp, map->br_startblock == DELAYSTARTBLOCK) || if (XFS_IS_CORRUPT(mp, map->br_startblock == DELAYSTARTBLOCK) ||
XFS_IS_CORRUPT(mp, map->br_startblock == HOLESTARTBLOCK)) XFS_IS_CORRUPT(mp, map->br_startblock == HOLESTARTBLOCK)) {
xfs_bmap_mark_sick(ip, XFS_ATTR_FORK);
return -EFSCORRUPTED; return -EFSCORRUPTED;
}
error = xfs_buf_incore(mp->m_ddev_targp, error = xfs_buf_incore(mp->m_ddev_targp,
XFS_FSB_TO_DADDR(mp, map->br_startblock), XFS_FSB_TO_DADDR(mp, map->br_startblock),
...@@ -664,8 +666,10 @@ xfs_attr_rmtval_invalidate( ...@@ -664,8 +666,10 @@ xfs_attr_rmtval_invalidate(
blkcnt, &map, &nmap, XFS_BMAPI_ATTRFORK); blkcnt, &map, &nmap, XFS_BMAPI_ATTRFORK);
if (error) if (error)
return error; return error;
if (XFS_IS_CORRUPT(args->dp->i_mount, nmap != 1)) if (XFS_IS_CORRUPT(args->dp->i_mount, nmap != 1)) {
xfs_bmap_mark_sick(args->dp, XFS_ATTR_FORK);
return -EFSCORRUPTED; return -EFSCORRUPTED;
}
error = xfs_attr_rmtval_stale(args->dp, &map, XBF_TRYLOCK); error = xfs_attr_rmtval_stale(args->dp, &map, XBF_TRYLOCK);
if (error) if (error)
return error; return error;
......
...@@ -386,6 +386,7 @@ xfs_bmap_check_leaf_extents( ...@@ -386,6 +386,7 @@ xfs_bmap_check_leaf_extents(
pp = XFS_BMBT_PTR_ADDR(mp, block, 1, mp->m_bmap_dmxr[1]); pp = XFS_BMBT_PTR_ADDR(mp, block, 1, mp->m_bmap_dmxr[1]);
bno = be64_to_cpu(*pp); bno = be64_to_cpu(*pp);
if (XFS_IS_CORRUPT(mp, !xfs_verify_fsbno(mp, bno))) { if (XFS_IS_CORRUPT(mp, !xfs_verify_fsbno(mp, bno))) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto error0; goto error0;
} }
...@@ -567,8 +568,10 @@ xfs_bmap_btree_to_extents( ...@@ -567,8 +568,10 @@ xfs_bmap_btree_to_extents(
pp = XFS_BMAP_BROOT_PTR_ADDR(mp, rblock, 1, ifp->if_broot_bytes); pp = XFS_BMAP_BROOT_PTR_ADDR(mp, rblock, 1, ifp->if_broot_bytes);
cbno = be64_to_cpu(*pp); cbno = be64_to_cpu(*pp);
#ifdef DEBUG #ifdef DEBUG
if (XFS_IS_CORRUPT(cur->bc_mp, !xfs_btree_check_lptr(cur, cbno, 1))) if (XFS_IS_CORRUPT(cur->bc_mp, !xfs_btree_check_lptr(cur, cbno, 1))) {
xfs_btree_mark_sick(cur);
return -EFSCORRUPTED; return -EFSCORRUPTED;
}
#endif #endif
error = xfs_btree_read_bufl(mp, tp, cbno, &cbp, XFS_BMAP_BTREE_REF, error = xfs_btree_read_bufl(mp, tp, cbno, &cbp, XFS_BMAP_BTREE_REF,
&xfs_bmbt_buf_ops); &xfs_bmbt_buf_ops);
...@@ -885,6 +888,7 @@ xfs_bmap_add_attrfork_btree( ...@@ -885,6 +888,7 @@ xfs_bmap_add_attrfork_btree(
goto error0; goto error0;
/* must be at least one entry */ /* must be at least one entry */
if (XFS_IS_CORRUPT(mp, stat != 1)) { if (XFS_IS_CORRUPT(mp, stat != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto error0; goto error0;
} }
...@@ -1211,6 +1215,7 @@ xfs_iread_extents( ...@@ -1211,6 +1215,7 @@ xfs_iread_extents(
goto out; goto out;
if (XFS_IS_CORRUPT(mp, ir.loaded != ifp->if_nextents)) { if (XFS_IS_CORRUPT(mp, ir.loaded != ifp->if_nextents)) {
xfs_bmap_mark_sick(ip, whichfork);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out; goto out;
} }
...@@ -1401,8 +1406,10 @@ xfs_bmap_last_offset( ...@@ -1401,8 +1406,10 @@ xfs_bmap_last_offset(
if (ifp->if_format == XFS_DINODE_FMT_LOCAL) if (ifp->if_format == XFS_DINODE_FMT_LOCAL)
return 0; return 0;
if (XFS_IS_CORRUPT(ip->i_mount, !xfs_ifork_has_extents(ifp))) if (XFS_IS_CORRUPT(ip->i_mount, !xfs_ifork_has_extents(ifp))) {
xfs_bmap_mark_sick(ip, whichfork);
return -EFSCORRUPTED; return -EFSCORRUPTED;
}
error = xfs_bmap_last_extent(NULL, ip, whichfork, &rec, &is_empty); error = xfs_bmap_last_extent(NULL, ip, whichfork, &rec, &is_empty);
if (error || is_empty) if (error || is_empty)
...@@ -1541,6 +1548,7 @@ xfs_bmap_add_extent_delay_real( ...@@ -1541,6 +1548,7 @@ xfs_bmap_add_extent_delay_real(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(bma->cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -1548,6 +1556,7 @@ xfs_bmap_add_extent_delay_real( ...@@ -1548,6 +1556,7 @@ xfs_bmap_add_extent_delay_real(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(bma->cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -1555,6 +1564,7 @@ xfs_bmap_add_extent_delay_real( ...@@ -1555,6 +1564,7 @@ xfs_bmap_add_extent_delay_real(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(bma->cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -1584,6 +1594,7 @@ xfs_bmap_add_extent_delay_real( ...@@ -1584,6 +1594,7 @@ xfs_bmap_add_extent_delay_real(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(bma->cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -1617,6 +1628,7 @@ xfs_bmap_add_extent_delay_real( ...@@ -1617,6 +1628,7 @@ xfs_bmap_add_extent_delay_real(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(bma->cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -1645,6 +1657,7 @@ xfs_bmap_add_extent_delay_real( ...@@ -1645,6 +1657,7 @@ xfs_bmap_add_extent_delay_real(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 0)) { if (XFS_IS_CORRUPT(mp, i != 0)) {
xfs_btree_mark_sick(bma->cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -1652,6 +1665,7 @@ xfs_bmap_add_extent_delay_real( ...@@ -1652,6 +1665,7 @@ xfs_bmap_add_extent_delay_real(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(bma->cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -1686,6 +1700,7 @@ xfs_bmap_add_extent_delay_real( ...@@ -1686,6 +1700,7 @@ xfs_bmap_add_extent_delay_real(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(bma->cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -1711,6 +1726,7 @@ xfs_bmap_add_extent_delay_real( ...@@ -1711,6 +1726,7 @@ xfs_bmap_add_extent_delay_real(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 0)) { if (XFS_IS_CORRUPT(mp, i != 0)) {
xfs_btree_mark_sick(bma->cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -1718,6 +1734,7 @@ xfs_bmap_add_extent_delay_real( ...@@ -1718,6 +1734,7 @@ xfs_bmap_add_extent_delay_real(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(bma->cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -1762,6 +1779,7 @@ xfs_bmap_add_extent_delay_real( ...@@ -1762,6 +1779,7 @@ xfs_bmap_add_extent_delay_real(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(bma->cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -1798,6 +1816,7 @@ xfs_bmap_add_extent_delay_real( ...@@ -1798,6 +1816,7 @@ xfs_bmap_add_extent_delay_real(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 0)) { if (XFS_IS_CORRUPT(mp, i != 0)) {
xfs_btree_mark_sick(bma->cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -1805,6 +1824,7 @@ xfs_bmap_add_extent_delay_real( ...@@ -1805,6 +1824,7 @@ xfs_bmap_add_extent_delay_real(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(bma->cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -1884,6 +1904,7 @@ xfs_bmap_add_extent_delay_real( ...@@ -1884,6 +1904,7 @@ xfs_bmap_add_extent_delay_real(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 0)) { if (XFS_IS_CORRUPT(mp, i != 0)) {
xfs_btree_mark_sick(bma->cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -1891,6 +1912,7 @@ xfs_bmap_add_extent_delay_real( ...@@ -1891,6 +1912,7 @@ xfs_bmap_add_extent_delay_real(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(bma->cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -2087,30 +2109,35 @@ xfs_bmap_add_extent_unwritten_real( ...@@ -2087,30 +2109,35 @@ xfs_bmap_add_extent_unwritten_real(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
if ((error = xfs_btree_delete(cur, &i))) if ((error = xfs_btree_delete(cur, &i)))
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
if ((error = xfs_btree_decrement(cur, 0, &i))) if ((error = xfs_btree_decrement(cur, 0, &i)))
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
if ((error = xfs_btree_delete(cur, &i))) if ((error = xfs_btree_delete(cur, &i)))
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
if ((error = xfs_btree_decrement(cur, 0, &i))) if ((error = xfs_btree_decrement(cur, 0, &i)))
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -2139,18 +2166,21 @@ xfs_bmap_add_extent_unwritten_real( ...@@ -2139,18 +2166,21 @@ xfs_bmap_add_extent_unwritten_real(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
if ((error = xfs_btree_delete(cur, &i))) if ((error = xfs_btree_delete(cur, &i)))
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
if ((error = xfs_btree_decrement(cur, 0, &i))) if ((error = xfs_btree_decrement(cur, 0, &i)))
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -2182,18 +2212,21 @@ xfs_bmap_add_extent_unwritten_real( ...@@ -2182,18 +2212,21 @@ xfs_bmap_add_extent_unwritten_real(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
if ((error = xfs_btree_delete(cur, &i))) if ((error = xfs_btree_delete(cur, &i)))
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
if ((error = xfs_btree_decrement(cur, 0, &i))) if ((error = xfs_btree_decrement(cur, 0, &i)))
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -2220,6 +2253,7 @@ xfs_bmap_add_extent_unwritten_real( ...@@ -2220,6 +2253,7 @@ xfs_bmap_add_extent_unwritten_real(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -2253,6 +2287,7 @@ xfs_bmap_add_extent_unwritten_real( ...@@ -2253,6 +2287,7 @@ xfs_bmap_add_extent_unwritten_real(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -2290,6 +2325,7 @@ xfs_bmap_add_extent_unwritten_real( ...@@ -2290,6 +2325,7 @@ xfs_bmap_add_extent_unwritten_real(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -2300,6 +2336,7 @@ xfs_bmap_add_extent_unwritten_real( ...@@ -2300,6 +2336,7 @@ xfs_bmap_add_extent_unwritten_real(
if ((error = xfs_btree_insert(cur, &i))) if ((error = xfs_btree_insert(cur, &i)))
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -2330,6 +2367,7 @@ xfs_bmap_add_extent_unwritten_real( ...@@ -2330,6 +2367,7 @@ xfs_bmap_add_extent_unwritten_real(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -2366,6 +2404,7 @@ xfs_bmap_add_extent_unwritten_real( ...@@ -2366,6 +2404,7 @@ xfs_bmap_add_extent_unwritten_real(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -2376,12 +2415,14 @@ xfs_bmap_add_extent_unwritten_real( ...@@ -2376,12 +2415,14 @@ xfs_bmap_add_extent_unwritten_real(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 0)) { if (XFS_IS_CORRUPT(mp, i != 0)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
if ((error = xfs_btree_insert(cur, &i))) if ((error = xfs_btree_insert(cur, &i)))
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -2418,6 +2459,7 @@ xfs_bmap_add_extent_unwritten_real( ...@@ -2418,6 +2459,7 @@ xfs_bmap_add_extent_unwritten_real(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -2430,6 +2472,7 @@ xfs_bmap_add_extent_unwritten_real( ...@@ -2430,6 +2472,7 @@ xfs_bmap_add_extent_unwritten_real(
if ((error = xfs_btree_insert(cur, &i))) if ((error = xfs_btree_insert(cur, &i)))
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -2442,6 +2485,7 @@ xfs_bmap_add_extent_unwritten_real( ...@@ -2442,6 +2485,7 @@ xfs_bmap_add_extent_unwritten_real(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 0)) { if (XFS_IS_CORRUPT(mp, i != 0)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -2449,6 +2493,7 @@ xfs_bmap_add_extent_unwritten_real( ...@@ -2449,6 +2493,7 @@ xfs_bmap_add_extent_unwritten_real(
if ((error = xfs_btree_insert(cur, &i))) if ((error = xfs_btree_insert(cur, &i)))
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -2734,6 +2779,7 @@ xfs_bmap_add_extent_hole_real( ...@@ -2734,6 +2779,7 @@ xfs_bmap_add_extent_hole_real(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -2741,6 +2787,7 @@ xfs_bmap_add_extent_hole_real( ...@@ -2741,6 +2787,7 @@ xfs_bmap_add_extent_hole_real(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -2748,6 +2795,7 @@ xfs_bmap_add_extent_hole_real( ...@@ -2748,6 +2795,7 @@ xfs_bmap_add_extent_hole_real(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -2777,6 +2825,7 @@ xfs_bmap_add_extent_hole_real( ...@@ -2777,6 +2825,7 @@ xfs_bmap_add_extent_hole_real(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -2807,6 +2856,7 @@ xfs_bmap_add_extent_hole_real( ...@@ -2807,6 +2856,7 @@ xfs_bmap_add_extent_hole_real(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -2833,6 +2883,7 @@ xfs_bmap_add_extent_hole_real( ...@@ -2833,6 +2883,7 @@ xfs_bmap_add_extent_hole_real(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 0)) { if (XFS_IS_CORRUPT(mp, i != 0)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -2840,6 +2891,7 @@ xfs_bmap_add_extent_hole_real( ...@@ -2840,6 +2891,7 @@ xfs_bmap_add_extent_hole_real(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -5109,9 +5161,11 @@ xfs_bmap_del_extent_real( ...@@ -5109,9 +5161,11 @@ xfs_bmap_del_extent_real(
error = xfs_bmbt_lookup_eq(cur, &got, &i); error = xfs_bmbt_lookup_eq(cur, &got, &i);
if (error) if (error)
return error; return error;
if (XFS_IS_CORRUPT(mp, i != 1)) if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
return -EFSCORRUPTED; return -EFSCORRUPTED;
} }
}
if (got.br_startoff == del->br_startoff) if (got.br_startoff == del->br_startoff)
state |= BMAP_LEFT_FILLING; state |= BMAP_LEFT_FILLING;
...@@ -5134,8 +5188,10 @@ xfs_bmap_del_extent_real( ...@@ -5134,8 +5188,10 @@ xfs_bmap_del_extent_real(
} }
if ((error = xfs_btree_delete(cur, &i))) if ((error = xfs_btree_delete(cur, &i)))
return error; return error;
if (XFS_IS_CORRUPT(mp, i != 1)) if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
return -EFSCORRUPTED; return -EFSCORRUPTED;
}
break; break;
case BMAP_LEFT_FILLING: case BMAP_LEFT_FILLING:
/* /*
...@@ -5207,8 +5263,10 @@ xfs_bmap_del_extent_real( ...@@ -5207,8 +5263,10 @@ xfs_bmap_del_extent_real(
error = xfs_bmbt_lookup_eq(cur, &got, &i); error = xfs_bmbt_lookup_eq(cur, &got, &i);
if (error) if (error)
return error; return error;
if (XFS_IS_CORRUPT(mp, i != 1)) if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
return -EFSCORRUPTED; return -EFSCORRUPTED;
}
/* /*
* Update the btree record back * Update the btree record back
* to the original value. * to the original value.
...@@ -5224,8 +5282,10 @@ xfs_bmap_del_extent_real( ...@@ -5224,8 +5282,10 @@ xfs_bmap_del_extent_real(
*logflagsp = 0; *logflagsp = 0;
return -ENOSPC; return -ENOSPC;
} }
if (XFS_IS_CORRUPT(mp, i != 1)) if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
return -EFSCORRUPTED; return -EFSCORRUPTED;
}
} else } else
*logflagsp |= xfs_ilog_fext(whichfork); *logflagsp |= xfs_ilog_fext(whichfork);
...@@ -5679,21 +5739,27 @@ xfs_bmse_merge( ...@@ -5679,21 +5739,27 @@ xfs_bmse_merge(
error = xfs_bmbt_lookup_eq(cur, got, &i); error = xfs_bmbt_lookup_eq(cur, got, &i);
if (error) if (error)
return error; return error;
if (XFS_IS_CORRUPT(mp, i != 1)) if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
return -EFSCORRUPTED; return -EFSCORRUPTED;
}
error = xfs_btree_delete(cur, &i); error = xfs_btree_delete(cur, &i);
if (error) if (error)
return error; return error;
if (XFS_IS_CORRUPT(mp, i != 1)) if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
return -EFSCORRUPTED; return -EFSCORRUPTED;
}
/* lookup and update size of the previous extent */ /* lookup and update size of the previous extent */
error = xfs_bmbt_lookup_eq(cur, left, &i); error = xfs_bmbt_lookup_eq(cur, left, &i);
if (error) if (error)
return error; return error;
if (XFS_IS_CORRUPT(mp, i != 1)) if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
return -EFSCORRUPTED; return -EFSCORRUPTED;
}
error = xfs_bmbt_update(cur, &new); error = xfs_bmbt_update(cur, &new);
if (error) if (error)
...@@ -5741,8 +5807,10 @@ xfs_bmap_shift_update_extent( ...@@ -5741,8 +5807,10 @@ xfs_bmap_shift_update_extent(
error = xfs_bmbt_lookup_eq(cur, &prev, &i); error = xfs_bmbt_lookup_eq(cur, &prev, &i);
if (error) if (error)
return error; return error;
if (XFS_IS_CORRUPT(mp, i != 1)) if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
return -EFSCORRUPTED; return -EFSCORRUPTED;
}
error = xfs_bmbt_update(cur, got); error = xfs_bmbt_update(cur, got);
if (error) if (error)
...@@ -5803,6 +5871,7 @@ xfs_bmap_collapse_extents( ...@@ -5803,6 +5871,7 @@ xfs_bmap_collapse_extents(
goto del_cursor; goto del_cursor;
} }
if (XFS_IS_CORRUPT(mp, isnullstartblock(got.br_startblock))) { if (XFS_IS_CORRUPT(mp, isnullstartblock(got.br_startblock))) {
xfs_bmap_mark_sick(ip, whichfork);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto del_cursor; goto del_cursor;
} }
...@@ -5928,11 +5997,13 @@ xfs_bmap_insert_extents( ...@@ -5928,11 +5997,13 @@ xfs_bmap_insert_extents(
} }
} }
if (XFS_IS_CORRUPT(mp, isnullstartblock(got.br_startblock))) { if (XFS_IS_CORRUPT(mp, isnullstartblock(got.br_startblock))) {
xfs_bmap_mark_sick(ip, whichfork);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto del_cursor; goto del_cursor;
} }
if (XFS_IS_CORRUPT(mp, stop_fsb > got.br_startoff)) { if (XFS_IS_CORRUPT(mp, stop_fsb > got.br_startoff)) {
xfs_bmap_mark_sick(ip, whichfork);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto del_cursor; goto del_cursor;
} }
...@@ -6032,6 +6103,7 @@ xfs_bmap_split_extent( ...@@ -6032,6 +6103,7 @@ xfs_bmap_split_extent(
if (error) if (error)
goto del_cursor; goto del_cursor;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto del_cursor; goto del_cursor;
} }
...@@ -6059,6 +6131,7 @@ xfs_bmap_split_extent( ...@@ -6059,6 +6131,7 @@ xfs_bmap_split_extent(
if (error) if (error)
goto del_cursor; goto del_cursor;
if (XFS_IS_CORRUPT(mp, i != 0)) { if (XFS_IS_CORRUPT(mp, i != 0)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto del_cursor; goto del_cursor;
} }
...@@ -6066,6 +6139,7 @@ xfs_bmap_split_extent( ...@@ -6066,6 +6139,7 @@ xfs_bmap_split_extent(
if (error) if (error)
goto del_cursor; goto del_cursor;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto del_cursor; goto del_cursor;
} }
......
...@@ -2026,8 +2026,10 @@ xfs_btree_lookup( ...@@ -2026,8 +2026,10 @@ xfs_btree_lookup(
error = xfs_btree_increment(cur, 0, &i); error = xfs_btree_increment(cur, 0, &i);
if (error) if (error)
goto error0; goto error0;
if (XFS_IS_CORRUPT(cur->bc_mp, i != 1)) if (XFS_IS_CORRUPT(cur->bc_mp, i != 1)) {
xfs_btree_mark_sick(cur);
return -EFSCORRUPTED; return -EFSCORRUPTED;
}
*stat = 1; *stat = 1;
return 0; return 0;
} }
...@@ -2480,6 +2482,7 @@ xfs_btree_lshift( ...@@ -2480,6 +2482,7 @@ xfs_btree_lshift(
goto error0; goto error0;
i = xfs_btree_firstrec(tcur, level); i = xfs_btree_firstrec(tcur, level);
if (XFS_IS_CORRUPT(tcur->bc_mp, i != 1)) { if (XFS_IS_CORRUPT(tcur->bc_mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto error0; goto error0;
} }
...@@ -2650,6 +2653,7 @@ xfs_btree_rshift( ...@@ -2650,6 +2653,7 @@ xfs_btree_rshift(
goto error0; goto error0;
i = xfs_btree_lastrec(tcur, level); i = xfs_btree_lastrec(tcur, level);
if (XFS_IS_CORRUPT(tcur->bc_mp, i != 1)) { if (XFS_IS_CORRUPT(tcur->bc_mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto error0; goto error0;
} }
...@@ -3538,6 +3542,7 @@ xfs_btree_insert( ...@@ -3538,6 +3542,7 @@ xfs_btree_insert(
} }
if (XFS_IS_CORRUPT(cur->bc_mp, i != 1)) { if (XFS_IS_CORRUPT(cur->bc_mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto error0; goto error0;
} }
...@@ -3945,6 +3950,7 @@ xfs_btree_delrec( ...@@ -3945,6 +3950,7 @@ xfs_btree_delrec(
*/ */
i = xfs_btree_lastrec(tcur, level); i = xfs_btree_lastrec(tcur, level);
if (XFS_IS_CORRUPT(cur->bc_mp, i != 1)) { if (XFS_IS_CORRUPT(cur->bc_mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto error0; goto error0;
} }
...@@ -3953,12 +3959,14 @@ xfs_btree_delrec( ...@@ -3953,12 +3959,14 @@ xfs_btree_delrec(
if (error) if (error)
goto error0; goto error0;
if (XFS_IS_CORRUPT(cur->bc_mp, i != 1)) { if (XFS_IS_CORRUPT(cur->bc_mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto error0; goto error0;
} }
i = xfs_btree_lastrec(tcur, level); i = xfs_btree_lastrec(tcur, level);
if (XFS_IS_CORRUPT(cur->bc_mp, i != 1)) { if (XFS_IS_CORRUPT(cur->bc_mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto error0; goto error0;
} }
...@@ -4006,6 +4014,7 @@ xfs_btree_delrec( ...@@ -4006,6 +4014,7 @@ xfs_btree_delrec(
if (!xfs_btree_ptr_is_null(cur, &lptr)) { if (!xfs_btree_ptr_is_null(cur, &lptr)) {
i = xfs_btree_firstrec(tcur, level); i = xfs_btree_firstrec(tcur, level);
if (XFS_IS_CORRUPT(cur->bc_mp, i != 1)) { if (XFS_IS_CORRUPT(cur->bc_mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto error0; goto error0;
} }
...@@ -4014,6 +4023,7 @@ xfs_btree_delrec( ...@@ -4014,6 +4023,7 @@ xfs_btree_delrec(
if (error) if (error)
goto error0; goto error0;
if (XFS_IS_CORRUPT(cur->bc_mp, i != 1)) { if (XFS_IS_CORRUPT(cur->bc_mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto error0; goto error0;
} }
...@@ -4031,6 +4041,7 @@ xfs_btree_delrec( ...@@ -4031,6 +4041,7 @@ xfs_btree_delrec(
*/ */
i = xfs_btree_firstrec(tcur, level); i = xfs_btree_firstrec(tcur, level);
if (XFS_IS_CORRUPT(cur->bc_mp, i != 1)) { if (XFS_IS_CORRUPT(cur->bc_mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto error0; goto error0;
} }
...@@ -4040,6 +4051,7 @@ xfs_btree_delrec( ...@@ -4040,6 +4051,7 @@ xfs_btree_delrec(
goto error0; goto error0;
i = xfs_btree_firstrec(tcur, level); i = xfs_btree_firstrec(tcur, level);
if (XFS_IS_CORRUPT(cur->bc_mp, i != 1)) { if (XFS_IS_CORRUPT(cur->bc_mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto error0; goto error0;
} }
......
...@@ -573,6 +573,7 @@ xfs_inobt_insert_sprec( ...@@ -573,6 +573,7 @@ xfs_inobt_insert_sprec(
if (error) if (error)
goto error; goto error;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto error; goto error;
} }
...@@ -589,10 +590,12 @@ xfs_inobt_insert_sprec( ...@@ -589,10 +590,12 @@ xfs_inobt_insert_sprec(
if (error) if (error)
goto error; goto error;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto error; goto error;
} }
if (XFS_IS_CORRUPT(mp, rec.ir_startino != nrec->ir_startino)) { if (XFS_IS_CORRUPT(mp, rec.ir_startino != nrec->ir_startino)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto error; goto error;
} }
...@@ -602,6 +605,7 @@ xfs_inobt_insert_sprec( ...@@ -602,6 +605,7 @@ xfs_inobt_insert_sprec(
* cannot merge, something is seriously wrong. * cannot merge, something is seriously wrong.
*/ */
if (XFS_IS_CORRUPT(mp, !__xfs_inobt_can_merge(nrec, &rec))) { if (XFS_IS_CORRUPT(mp, !__xfs_inobt_can_merge(nrec, &rec))) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto error; goto error;
} }
...@@ -951,9 +955,11 @@ xfs_ialloc_next_rec( ...@@ -951,9 +955,11 @@ xfs_ialloc_next_rec(
error = xfs_inobt_get_rec(cur, rec, &i); error = xfs_inobt_get_rec(cur, rec, &i);
if (error) if (error)
return error; return error;
if (XFS_IS_CORRUPT(cur->bc_mp, i != 1)) if (XFS_IS_CORRUPT(cur->bc_mp, i != 1)) {
xfs_btree_mark_sick(cur);
return -EFSCORRUPTED; return -EFSCORRUPTED;
} }
}
return 0; return 0;
} }
...@@ -976,9 +982,11 @@ xfs_ialloc_get_rec( ...@@ -976,9 +982,11 @@ xfs_ialloc_get_rec(
error = xfs_inobt_get_rec(cur, rec, &i); error = xfs_inobt_get_rec(cur, rec, &i);
if (error) if (error)
return error; return error;
if (XFS_IS_CORRUPT(cur->bc_mp, i != 1)) if (XFS_IS_CORRUPT(cur->bc_mp, i != 1)) {
xfs_btree_mark_sick(cur);
return -EFSCORRUPTED; return -EFSCORRUPTED;
} }
}
return 0; return 0;
} }
...@@ -1055,6 +1063,7 @@ xfs_dialloc_ag_inobt( ...@@ -1055,6 +1063,7 @@ xfs_dialloc_ag_inobt(
if (error) if (error)
goto error0; goto error0;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto error0; goto error0;
} }
...@@ -1063,6 +1072,7 @@ xfs_dialloc_ag_inobt( ...@@ -1063,6 +1072,7 @@ xfs_dialloc_ag_inobt(
if (error) if (error)
goto error0; goto error0;
if (XFS_IS_CORRUPT(mp, j != 1)) { if (XFS_IS_CORRUPT(mp, j != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto error0; goto error0;
} }
...@@ -1221,6 +1231,7 @@ xfs_dialloc_ag_inobt( ...@@ -1221,6 +1231,7 @@ xfs_dialloc_ag_inobt(
if (error) if (error)
goto error0; goto error0;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto error0; goto error0;
} }
...@@ -1230,6 +1241,7 @@ xfs_dialloc_ag_inobt( ...@@ -1230,6 +1241,7 @@ xfs_dialloc_ag_inobt(
if (error) if (error)
goto error0; goto error0;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto error0; goto error0;
} }
...@@ -1239,6 +1251,7 @@ xfs_dialloc_ag_inobt( ...@@ -1239,6 +1251,7 @@ xfs_dialloc_ag_inobt(
if (error) if (error)
goto error0; goto error0;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto error0; goto error0;
} }
...@@ -1299,8 +1312,10 @@ xfs_dialloc_ag_finobt_near( ...@@ -1299,8 +1312,10 @@ xfs_dialloc_ag_finobt_near(
error = xfs_inobt_get_rec(lcur, rec, &i); error = xfs_inobt_get_rec(lcur, rec, &i);
if (error) if (error)
return error; return error;
if (XFS_IS_CORRUPT(lcur->bc_mp, i != 1)) if (XFS_IS_CORRUPT(lcur->bc_mp, i != 1)) {
xfs_btree_mark_sick(lcur);
return -EFSCORRUPTED; return -EFSCORRUPTED;
}
/* /*
* See if we've landed in the parent inode record. The finobt * See if we've landed in the parent inode record. The finobt
...@@ -1324,12 +1339,14 @@ xfs_dialloc_ag_finobt_near( ...@@ -1324,12 +1339,14 @@ xfs_dialloc_ag_finobt_near(
if (error) if (error)
goto error_rcur; goto error_rcur;
if (XFS_IS_CORRUPT(lcur->bc_mp, j != 1)) { if (XFS_IS_CORRUPT(lcur->bc_mp, j != 1)) {
xfs_btree_mark_sick(lcur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto error_rcur; goto error_rcur;
} }
} }
if (XFS_IS_CORRUPT(lcur->bc_mp, i != 1 && j != 1)) { if (XFS_IS_CORRUPT(lcur->bc_mp, i != 1 && j != 1)) {
xfs_btree_mark_sick(lcur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto error_rcur; goto error_rcur;
} }
...@@ -1385,8 +1402,10 @@ xfs_dialloc_ag_finobt_newino( ...@@ -1385,8 +1402,10 @@ xfs_dialloc_ag_finobt_newino(
error = xfs_inobt_get_rec(cur, rec, &i); error = xfs_inobt_get_rec(cur, rec, &i);
if (error) if (error)
return error; return error;
if (XFS_IS_CORRUPT(cur->bc_mp, i != 1)) if (XFS_IS_CORRUPT(cur->bc_mp, i != 1)) {
xfs_btree_mark_sick(cur);
return -EFSCORRUPTED; return -EFSCORRUPTED;
}
return 0; return 0;
} }
} }
...@@ -1397,14 +1416,18 @@ xfs_dialloc_ag_finobt_newino( ...@@ -1397,14 +1416,18 @@ xfs_dialloc_ag_finobt_newino(
error = xfs_inobt_lookup(cur, 0, XFS_LOOKUP_GE, &i); error = xfs_inobt_lookup(cur, 0, XFS_LOOKUP_GE, &i);
if (error) if (error)
return error; return error;
if (XFS_IS_CORRUPT(cur->bc_mp, i != 1)) if (XFS_IS_CORRUPT(cur->bc_mp, i != 1)) {
xfs_btree_mark_sick(cur);
return -EFSCORRUPTED; return -EFSCORRUPTED;
}
error = xfs_inobt_get_rec(cur, rec, &i); error = xfs_inobt_get_rec(cur, rec, &i);
if (error) if (error)
return error; return error;
if (XFS_IS_CORRUPT(cur->bc_mp, i != 1)) if (XFS_IS_CORRUPT(cur->bc_mp, i != 1)) {
xfs_btree_mark_sick(cur);
return -EFSCORRUPTED; return -EFSCORRUPTED;
}
return 0; return 0;
} }
...@@ -1426,14 +1449,18 @@ xfs_dialloc_ag_update_inobt( ...@@ -1426,14 +1449,18 @@ xfs_dialloc_ag_update_inobt(
error = xfs_inobt_lookup(cur, frec->ir_startino, XFS_LOOKUP_EQ, &i); error = xfs_inobt_lookup(cur, frec->ir_startino, XFS_LOOKUP_EQ, &i);
if (error) if (error)
return error; return error;
if (XFS_IS_CORRUPT(cur->bc_mp, i != 1)) if (XFS_IS_CORRUPT(cur->bc_mp, i != 1)) {
xfs_btree_mark_sick(cur);
return -EFSCORRUPTED; return -EFSCORRUPTED;
}
error = xfs_inobt_get_rec(cur, &rec, &i); error = xfs_inobt_get_rec(cur, &rec, &i);
if (error) if (error)
return error; return error;
if (XFS_IS_CORRUPT(cur->bc_mp, i != 1)) if (XFS_IS_CORRUPT(cur->bc_mp, i != 1)) {
xfs_btree_mark_sick(cur);
return -EFSCORRUPTED; return -EFSCORRUPTED;
}
ASSERT((XFS_AGINO_TO_OFFSET(cur->bc_mp, rec.ir_startino) % ASSERT((XFS_AGINO_TO_OFFSET(cur->bc_mp, rec.ir_startino) %
XFS_INODES_PER_CHUNK) == 0); XFS_INODES_PER_CHUNK) == 0);
...@@ -1442,8 +1469,10 @@ xfs_dialloc_ag_update_inobt( ...@@ -1442,8 +1469,10 @@ xfs_dialloc_ag_update_inobt(
if (XFS_IS_CORRUPT(cur->bc_mp, if (XFS_IS_CORRUPT(cur->bc_mp,
rec.ir_free != frec->ir_free || rec.ir_free != frec->ir_free ||
rec.ir_freecount != frec->ir_freecount)) rec.ir_freecount != frec->ir_freecount)) {
xfs_btree_mark_sick(cur);
return -EFSCORRUPTED; return -EFSCORRUPTED;
}
return xfs_inobt_update(cur, &rec); return xfs_inobt_update(cur, &rec);
} }
...@@ -1960,6 +1989,7 @@ xfs_difree_inobt( ...@@ -1960,6 +1989,7 @@ xfs_difree_inobt(
goto error0; goto error0;
} }
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto error0; goto error0;
} }
...@@ -1970,6 +2000,7 @@ xfs_difree_inobt( ...@@ -1970,6 +2000,7 @@ xfs_difree_inobt(
goto error0; goto error0;
} }
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto error0; goto error0;
} }
...@@ -2082,6 +2113,7 @@ xfs_difree_finobt( ...@@ -2082,6 +2113,7 @@ xfs_difree_finobt(
* something is out of sync. * something is out of sync.
*/ */
if (XFS_IS_CORRUPT(mp, ibtrec->ir_freecount != 1)) { if (XFS_IS_CORRUPT(mp, ibtrec->ir_freecount != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto error; goto error;
} }
...@@ -2108,6 +2140,7 @@ xfs_difree_finobt( ...@@ -2108,6 +2140,7 @@ xfs_difree_finobt(
if (error) if (error)
goto error; goto error;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto error; goto error;
} }
...@@ -2118,6 +2151,7 @@ xfs_difree_finobt( ...@@ -2118,6 +2151,7 @@ xfs_difree_finobt(
if (XFS_IS_CORRUPT(mp, if (XFS_IS_CORRUPT(mp,
rec.ir_free != ibtrec->ir_free || rec.ir_free != ibtrec->ir_free ||
rec.ir_freecount != ibtrec->ir_freecount)) { rec.ir_freecount != ibtrec->ir_freecount)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto error; goto error;
} }
......
...@@ -240,6 +240,7 @@ xfs_refcount_insert( ...@@ -240,6 +240,7 @@ xfs_refcount_insert(
if (error) if (error)
goto out_error; goto out_error;
if (XFS_IS_CORRUPT(cur->bc_mp, *i != 1)) { if (XFS_IS_CORRUPT(cur->bc_mp, *i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out_error; goto out_error;
} }
...@@ -270,12 +271,14 @@ xfs_refcount_delete( ...@@ -270,12 +271,14 @@ xfs_refcount_delete(
if (error) if (error)
goto out_error; goto out_error;
if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) { if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out_error; goto out_error;
} }
trace_xfs_refcount_delete(cur->bc_mp, cur->bc_ag.pag->pag_agno, &irec); trace_xfs_refcount_delete(cur->bc_mp, cur->bc_ag.pag->pag_agno, &irec);
error = xfs_btree_delete(cur, i); error = xfs_btree_delete(cur, i);
if (XFS_IS_CORRUPT(cur->bc_mp, *i != 1)) { if (XFS_IS_CORRUPT(cur->bc_mp, *i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out_error; goto out_error;
} }
...@@ -400,6 +403,7 @@ xfs_refcount_split_extent( ...@@ -400,6 +403,7 @@ xfs_refcount_split_extent(
if (error) if (error)
goto out_error; goto out_error;
if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) { if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out_error; goto out_error;
} }
...@@ -427,6 +431,7 @@ xfs_refcount_split_extent( ...@@ -427,6 +431,7 @@ xfs_refcount_split_extent(
if (error) if (error)
goto out_error; goto out_error;
if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) { if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out_error; goto out_error;
} }
...@@ -472,6 +477,7 @@ xfs_refcount_merge_center_extents( ...@@ -472,6 +477,7 @@ xfs_refcount_merge_center_extents(
if (error) if (error)
goto out_error; goto out_error;
if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) { if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out_error; goto out_error;
} }
...@@ -480,6 +486,7 @@ xfs_refcount_merge_center_extents( ...@@ -480,6 +486,7 @@ xfs_refcount_merge_center_extents(
if (error) if (error)
goto out_error; goto out_error;
if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) { if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out_error; goto out_error;
} }
...@@ -489,6 +496,7 @@ xfs_refcount_merge_center_extents( ...@@ -489,6 +496,7 @@ xfs_refcount_merge_center_extents(
if (error) if (error)
goto out_error; goto out_error;
if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) { if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out_error; goto out_error;
} }
...@@ -500,6 +508,7 @@ xfs_refcount_merge_center_extents( ...@@ -500,6 +508,7 @@ xfs_refcount_merge_center_extents(
if (error) if (error)
goto out_error; goto out_error;
if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) { if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out_error; goto out_error;
} }
...@@ -544,6 +553,7 @@ xfs_refcount_merge_left_extent( ...@@ -544,6 +553,7 @@ xfs_refcount_merge_left_extent(
if (error) if (error)
goto out_error; goto out_error;
if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) { if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out_error; goto out_error;
} }
...@@ -552,6 +562,7 @@ xfs_refcount_merge_left_extent( ...@@ -552,6 +562,7 @@ xfs_refcount_merge_left_extent(
if (error) if (error)
goto out_error; goto out_error;
if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) { if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out_error; goto out_error;
} }
...@@ -563,6 +574,7 @@ xfs_refcount_merge_left_extent( ...@@ -563,6 +574,7 @@ xfs_refcount_merge_left_extent(
if (error) if (error)
goto out_error; goto out_error;
if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) { if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out_error; goto out_error;
} }
...@@ -610,6 +622,7 @@ xfs_refcount_merge_right_extent( ...@@ -610,6 +622,7 @@ xfs_refcount_merge_right_extent(
if (error) if (error)
goto out_error; goto out_error;
if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) { if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out_error; goto out_error;
} }
...@@ -618,6 +631,7 @@ xfs_refcount_merge_right_extent( ...@@ -618,6 +631,7 @@ xfs_refcount_merge_right_extent(
if (error) if (error)
goto out_error; goto out_error;
if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) { if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out_error; goto out_error;
} }
...@@ -629,6 +643,7 @@ xfs_refcount_merge_right_extent( ...@@ -629,6 +643,7 @@ xfs_refcount_merge_right_extent(
if (error) if (error)
goto out_error; goto out_error;
if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) { if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out_error; goto out_error;
} }
...@@ -676,6 +691,7 @@ xfs_refcount_find_left_extents( ...@@ -676,6 +691,7 @@ xfs_refcount_find_left_extents(
if (error) if (error)
goto out_error; goto out_error;
if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) { if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out_error; goto out_error;
} }
...@@ -695,6 +711,7 @@ xfs_refcount_find_left_extents( ...@@ -695,6 +711,7 @@ xfs_refcount_find_left_extents(
if (error) if (error)
goto out_error; goto out_error;
if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) { if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out_error; goto out_error;
} }
...@@ -769,6 +786,7 @@ xfs_refcount_find_right_extents( ...@@ -769,6 +786,7 @@ xfs_refcount_find_right_extents(
if (error) if (error)
goto out_error; goto out_error;
if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) { if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out_error; goto out_error;
} }
...@@ -788,6 +806,7 @@ xfs_refcount_find_right_extents( ...@@ -788,6 +806,7 @@ xfs_refcount_find_right_extents(
if (error) if (error)
goto out_error; goto out_error;
if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) { if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out_error; goto out_error;
} }
...@@ -1144,6 +1163,7 @@ xfs_refcount_adjust_extents( ...@@ -1144,6 +1163,7 @@ xfs_refcount_adjust_extents(
goto out_error; goto out_error;
if (XFS_IS_CORRUPT(cur->bc_mp, if (XFS_IS_CORRUPT(cur->bc_mp,
found_tmp != 1)) { found_tmp != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out_error; goto out_error;
} }
...@@ -1182,6 +1202,7 @@ xfs_refcount_adjust_extents( ...@@ -1182,6 +1202,7 @@ xfs_refcount_adjust_extents(
*/ */
if (XFS_IS_CORRUPT(cur->bc_mp, ext.rc_blockcount == 0) || if (XFS_IS_CORRUPT(cur->bc_mp, ext.rc_blockcount == 0) ||
XFS_IS_CORRUPT(cur->bc_mp, ext.rc_blockcount > *aglen)) { XFS_IS_CORRUPT(cur->bc_mp, ext.rc_blockcount > *aglen)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out_error; goto out_error;
} }
...@@ -1205,6 +1226,7 @@ xfs_refcount_adjust_extents( ...@@ -1205,6 +1226,7 @@ xfs_refcount_adjust_extents(
if (error) if (error)
goto out_error; goto out_error;
if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) { if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out_error; goto out_error;
} }
...@@ -1329,8 +1351,10 @@ xfs_refcount_continue_op( ...@@ -1329,8 +1351,10 @@ xfs_refcount_continue_op(
struct xfs_perag *pag = cur->bc_ag.pag; struct xfs_perag *pag = cur->bc_ag.pag;
if (XFS_IS_CORRUPT(mp, !xfs_verify_agbext(pag, new_agbno, if (XFS_IS_CORRUPT(mp, !xfs_verify_agbext(pag, new_agbno,
ri->ri_blockcount))) ri->ri_blockcount))) {
xfs_btree_mark_sick(cur);
return -EFSCORRUPTED; return -EFSCORRUPTED;
}
ri->ri_startblock = XFS_AGB_TO_FSB(mp, pag->pag_agno, new_agbno); ri->ri_startblock = XFS_AGB_TO_FSB(mp, pag->pag_agno, new_agbno);
...@@ -1537,6 +1561,7 @@ xfs_refcount_find_shared( ...@@ -1537,6 +1561,7 @@ xfs_refcount_find_shared(
if (error) if (error)
goto out_error; goto out_error;
if (XFS_IS_CORRUPT(cur->bc_mp, i != 1)) { if (XFS_IS_CORRUPT(cur->bc_mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out_error; goto out_error;
} }
...@@ -1554,6 +1579,7 @@ xfs_refcount_find_shared( ...@@ -1554,6 +1579,7 @@ xfs_refcount_find_shared(
if (error) if (error)
goto out_error; goto out_error;
if (XFS_IS_CORRUPT(cur->bc_mp, i != 1)) { if (XFS_IS_CORRUPT(cur->bc_mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out_error; goto out_error;
} }
...@@ -1587,6 +1613,7 @@ xfs_refcount_find_shared( ...@@ -1587,6 +1613,7 @@ xfs_refcount_find_shared(
if (error) if (error)
goto out_error; goto out_error;
if (XFS_IS_CORRUPT(cur->bc_mp, i != 1)) { if (XFS_IS_CORRUPT(cur->bc_mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out_error; goto out_error;
} }
...@@ -1684,6 +1711,7 @@ xfs_refcount_adjust_cow_extents( ...@@ -1684,6 +1711,7 @@ xfs_refcount_adjust_cow_extents(
goto out_error; goto out_error;
if (XFS_IS_CORRUPT(cur->bc_mp, found_rec && if (XFS_IS_CORRUPT(cur->bc_mp, found_rec &&
ext.rc_domain != XFS_REFC_DOMAIN_COW)) { ext.rc_domain != XFS_REFC_DOMAIN_COW)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out_error; goto out_error;
} }
...@@ -1699,6 +1727,7 @@ xfs_refcount_adjust_cow_extents( ...@@ -1699,6 +1727,7 @@ xfs_refcount_adjust_cow_extents(
/* Adding a CoW reservation, there should be nothing here. */ /* Adding a CoW reservation, there should be nothing here. */
if (XFS_IS_CORRUPT(cur->bc_mp, if (XFS_IS_CORRUPT(cur->bc_mp,
agbno + aglen > ext.rc_startblock)) { agbno + aglen > ext.rc_startblock)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out_error; goto out_error;
} }
...@@ -1716,6 +1745,7 @@ xfs_refcount_adjust_cow_extents( ...@@ -1716,6 +1745,7 @@ xfs_refcount_adjust_cow_extents(
if (error) if (error)
goto out_error; goto out_error;
if (XFS_IS_CORRUPT(cur->bc_mp, found_tmp != 1)) { if (XFS_IS_CORRUPT(cur->bc_mp, found_tmp != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out_error; goto out_error;
} }
...@@ -1723,14 +1753,17 @@ xfs_refcount_adjust_cow_extents( ...@@ -1723,14 +1753,17 @@ xfs_refcount_adjust_cow_extents(
case XFS_REFCOUNT_ADJUST_COW_FREE: case XFS_REFCOUNT_ADJUST_COW_FREE:
/* Removing a CoW reservation, there should be one extent. */ /* Removing a CoW reservation, there should be one extent. */
if (XFS_IS_CORRUPT(cur->bc_mp, ext.rc_startblock != agbno)) { if (XFS_IS_CORRUPT(cur->bc_mp, ext.rc_startblock != agbno)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out_error; goto out_error;
} }
if (XFS_IS_CORRUPT(cur->bc_mp, ext.rc_blockcount != aglen)) { if (XFS_IS_CORRUPT(cur->bc_mp, ext.rc_blockcount != aglen)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out_error; goto out_error;
} }
if (XFS_IS_CORRUPT(cur->bc_mp, ext.rc_refcount != 1)) { if (XFS_IS_CORRUPT(cur->bc_mp, ext.rc_refcount != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out_error; goto out_error;
} }
...@@ -1742,6 +1775,7 @@ xfs_refcount_adjust_cow_extents( ...@@ -1742,6 +1775,7 @@ xfs_refcount_adjust_cow_extents(
if (error) if (error)
goto out_error; goto out_error;
if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) { if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out_error; goto out_error;
} }
...@@ -1904,6 +1938,7 @@ xfs_refcount_recover_extent( ...@@ -1904,6 +1938,7 @@ xfs_refcount_recover_extent(
if (xfs_refcount_check_irec(cur->bc_ag.pag, &rr->rr_rrec) != NULL || if (xfs_refcount_check_irec(cur->bc_ag.pag, &rr->rr_rrec) != NULL ||
XFS_IS_CORRUPT(cur->bc_mp, XFS_IS_CORRUPT(cur->bc_mp,
rr->rr_rrec.rc_domain != XFS_REFC_DOMAIN_COW)) { rr->rr_rrec.rc_domain != XFS_REFC_DOMAIN_COW)) {
xfs_btree_mark_sick(cur);
kfree(rr); kfree(rr);
return -EFSCORRUPTED; return -EFSCORRUPTED;
} }
......
...@@ -135,6 +135,7 @@ xfs_rmap_insert( ...@@ -135,6 +135,7 @@ xfs_rmap_insert(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(rcur->bc_mp, i != 0)) { if (XFS_IS_CORRUPT(rcur->bc_mp, i != 0)) {
xfs_btree_mark_sick(rcur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -148,6 +149,7 @@ xfs_rmap_insert( ...@@ -148,6 +149,7 @@ xfs_rmap_insert(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(rcur->bc_mp, i != 1)) { if (XFS_IS_CORRUPT(rcur->bc_mp, i != 1)) {
xfs_btree_mark_sick(rcur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -177,6 +179,7 @@ xfs_rmap_delete( ...@@ -177,6 +179,7 @@ xfs_rmap_delete(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(rcur->bc_mp, i != 1)) { if (XFS_IS_CORRUPT(rcur->bc_mp, i != 1)) {
xfs_btree_mark_sick(rcur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -185,6 +188,7 @@ xfs_rmap_delete( ...@@ -185,6 +188,7 @@ xfs_rmap_delete(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(rcur->bc_mp, i != 1)) { if (XFS_IS_CORRUPT(rcur->bc_mp, i != 1)) {
xfs_btree_mark_sick(rcur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -516,7 +520,7 @@ xfs_rmap_lookup_le_range( ...@@ -516,7 +520,7 @@ xfs_rmap_lookup_le_range(
*/ */
static int static int
xfs_rmap_free_check_owner( xfs_rmap_free_check_owner(
struct xfs_mount *mp, struct xfs_btree_cur *cur,
uint64_t ltoff, uint64_t ltoff,
struct xfs_rmap_irec *rec, struct xfs_rmap_irec *rec,
xfs_filblks_t len, xfs_filblks_t len,
...@@ -524,6 +528,7 @@ xfs_rmap_free_check_owner( ...@@ -524,6 +528,7 @@ xfs_rmap_free_check_owner(
uint64_t offset, uint64_t offset,
unsigned int flags) unsigned int flags)
{ {
struct xfs_mount *mp = cur->bc_mp;
int error = 0; int error = 0;
if (owner == XFS_RMAP_OWN_UNKNOWN) if (owner == XFS_RMAP_OWN_UNKNOWN)
...@@ -533,12 +538,14 @@ xfs_rmap_free_check_owner( ...@@ -533,12 +538,14 @@ xfs_rmap_free_check_owner(
if (XFS_IS_CORRUPT(mp, if (XFS_IS_CORRUPT(mp,
(flags & XFS_RMAP_UNWRITTEN) != (flags & XFS_RMAP_UNWRITTEN) !=
(rec->rm_flags & XFS_RMAP_UNWRITTEN))) { (rec->rm_flags & XFS_RMAP_UNWRITTEN))) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out; goto out;
} }
/* Make sure the owner matches what we expect to find in the tree. */ /* Make sure the owner matches what we expect to find in the tree. */
if (XFS_IS_CORRUPT(mp, owner != rec->rm_owner)) { if (XFS_IS_CORRUPT(mp, owner != rec->rm_owner)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out; goto out;
} }
...@@ -550,16 +557,19 @@ xfs_rmap_free_check_owner( ...@@ -550,16 +557,19 @@ xfs_rmap_free_check_owner(
if (flags & XFS_RMAP_BMBT_BLOCK) { if (flags & XFS_RMAP_BMBT_BLOCK) {
if (XFS_IS_CORRUPT(mp, if (XFS_IS_CORRUPT(mp,
!(rec->rm_flags & XFS_RMAP_BMBT_BLOCK))) { !(rec->rm_flags & XFS_RMAP_BMBT_BLOCK))) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out; goto out;
} }
} else { } else {
if (XFS_IS_CORRUPT(mp, rec->rm_offset > offset)) { if (XFS_IS_CORRUPT(mp, rec->rm_offset > offset)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out; goto out;
} }
if (XFS_IS_CORRUPT(mp, if (XFS_IS_CORRUPT(mp,
offset + len > ltoff + rec->rm_blockcount)) { offset + len > ltoff + rec->rm_blockcount)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out; goto out;
} }
...@@ -622,6 +632,7 @@ xfs_rmap_unmap( ...@@ -622,6 +632,7 @@ xfs_rmap_unmap(
if (error) if (error)
goto out_error; goto out_error;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out_error; goto out_error;
} }
...@@ -643,6 +654,7 @@ xfs_rmap_unmap( ...@@ -643,6 +654,7 @@ xfs_rmap_unmap(
if (XFS_IS_CORRUPT(mp, if (XFS_IS_CORRUPT(mp,
bno < bno <
ltrec.rm_startblock + ltrec.rm_blockcount)) { ltrec.rm_startblock + ltrec.rm_blockcount)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out_error; goto out_error;
} }
...@@ -669,6 +681,7 @@ xfs_rmap_unmap( ...@@ -669,6 +681,7 @@ xfs_rmap_unmap(
if (error) if (error)
goto out_error; goto out_error;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out_error; goto out_error;
} }
...@@ -681,12 +694,13 @@ xfs_rmap_unmap( ...@@ -681,12 +694,13 @@ xfs_rmap_unmap(
ltrec.rm_startblock > bno || ltrec.rm_startblock > bno ||
ltrec.rm_startblock + ltrec.rm_blockcount < ltrec.rm_startblock + ltrec.rm_blockcount <
bno + len)) { bno + len)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out_error; goto out_error;
} }
/* Check owner information. */ /* Check owner information. */
error = xfs_rmap_free_check_owner(mp, ltoff, &ltrec, len, owner, error = xfs_rmap_free_check_owner(cur, ltoff, &ltrec, len, owner,
offset, flags); offset, flags);
if (error) if (error)
goto out_error; goto out_error;
...@@ -701,6 +715,7 @@ xfs_rmap_unmap( ...@@ -701,6 +715,7 @@ xfs_rmap_unmap(
if (error) if (error)
goto out_error; goto out_error;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out_error; goto out_error;
} }
...@@ -904,6 +919,7 @@ xfs_rmap_map( ...@@ -904,6 +919,7 @@ xfs_rmap_map(
if (XFS_IS_CORRUPT(mp, if (XFS_IS_CORRUPT(mp,
have_lt != 0 && have_lt != 0 &&
ltrec.rm_startblock + ltrec.rm_blockcount > bno)) { ltrec.rm_startblock + ltrec.rm_blockcount > bno)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out_error; goto out_error;
} }
...@@ -921,10 +937,12 @@ xfs_rmap_map( ...@@ -921,10 +937,12 @@ xfs_rmap_map(
if (error) if (error)
goto out_error; goto out_error;
if (XFS_IS_CORRUPT(mp, have_gt != 1)) { if (XFS_IS_CORRUPT(mp, have_gt != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out_error; goto out_error;
} }
if (XFS_IS_CORRUPT(mp, bno + len > gtrec.rm_startblock)) { if (XFS_IS_CORRUPT(mp, bno + len > gtrec.rm_startblock)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out_error; goto out_error;
} }
...@@ -978,6 +996,7 @@ xfs_rmap_map( ...@@ -978,6 +996,7 @@ xfs_rmap_map(
if (error) if (error)
goto out_error; goto out_error;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out_error; goto out_error;
} }
...@@ -1025,6 +1044,7 @@ xfs_rmap_map( ...@@ -1025,6 +1044,7 @@ xfs_rmap_map(
if (error) if (error)
goto out_error; goto out_error;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out_error; goto out_error;
} }
...@@ -1120,6 +1140,7 @@ xfs_rmap_convert( ...@@ -1120,6 +1140,7 @@ xfs_rmap_convert(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -1157,12 +1178,14 @@ xfs_rmap_convert( ...@@ -1157,12 +1178,14 @@ xfs_rmap_convert(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
if (XFS_IS_CORRUPT(mp, if (XFS_IS_CORRUPT(mp,
LEFT.rm_startblock + LEFT.rm_blockcount > LEFT.rm_startblock + LEFT.rm_blockcount >
bno)) { bno)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -1185,6 +1208,7 @@ xfs_rmap_convert( ...@@ -1185,6 +1208,7 @@ xfs_rmap_convert(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -1197,10 +1221,12 @@ xfs_rmap_convert( ...@@ -1197,10 +1221,12 @@ xfs_rmap_convert(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
if (XFS_IS_CORRUPT(mp, bno + len > RIGHT.rm_startblock)) { if (XFS_IS_CORRUPT(mp, bno + len > RIGHT.rm_startblock)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -1231,6 +1257,7 @@ xfs_rmap_convert( ...@@ -1231,6 +1257,7 @@ xfs_rmap_convert(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -1250,6 +1277,7 @@ xfs_rmap_convert( ...@@ -1250,6 +1277,7 @@ xfs_rmap_convert(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -1261,6 +1289,7 @@ xfs_rmap_convert( ...@@ -1261,6 +1289,7 @@ xfs_rmap_convert(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -1268,6 +1297,7 @@ xfs_rmap_convert( ...@@ -1268,6 +1297,7 @@ xfs_rmap_convert(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -1279,6 +1309,7 @@ xfs_rmap_convert( ...@@ -1279,6 +1309,7 @@ xfs_rmap_convert(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -1286,6 +1317,7 @@ xfs_rmap_convert( ...@@ -1286,6 +1317,7 @@ xfs_rmap_convert(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -1309,6 +1341,7 @@ xfs_rmap_convert( ...@@ -1309,6 +1341,7 @@ xfs_rmap_convert(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -1316,6 +1349,7 @@ xfs_rmap_convert( ...@@ -1316,6 +1349,7 @@ xfs_rmap_convert(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -1335,6 +1369,7 @@ xfs_rmap_convert( ...@@ -1335,6 +1369,7 @@ xfs_rmap_convert(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -1346,6 +1381,7 @@ xfs_rmap_convert( ...@@ -1346,6 +1381,7 @@ xfs_rmap_convert(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -1353,6 +1389,7 @@ xfs_rmap_convert( ...@@ -1353,6 +1389,7 @@ xfs_rmap_convert(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -1423,6 +1460,7 @@ xfs_rmap_convert( ...@@ -1423,6 +1460,7 @@ xfs_rmap_convert(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -1465,6 +1503,7 @@ xfs_rmap_convert( ...@@ -1465,6 +1503,7 @@ xfs_rmap_convert(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 0)) { if (XFS_IS_CORRUPT(mp, i != 0)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -1480,6 +1519,7 @@ xfs_rmap_convert( ...@@ -1480,6 +1519,7 @@ xfs_rmap_convert(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -1513,6 +1553,7 @@ xfs_rmap_convert( ...@@ -1513,6 +1553,7 @@ xfs_rmap_convert(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -1526,6 +1567,7 @@ xfs_rmap_convert( ...@@ -1526,6 +1567,7 @@ xfs_rmap_convert(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 0)) { if (XFS_IS_CORRUPT(mp, i != 0)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -1538,6 +1580,7 @@ xfs_rmap_convert( ...@@ -1538,6 +1580,7 @@ xfs_rmap_convert(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -1610,6 +1653,7 @@ xfs_rmap_convert_shared( ...@@ -1610,6 +1653,7 @@ xfs_rmap_convert_shared(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -1638,6 +1682,7 @@ xfs_rmap_convert_shared( ...@@ -1638,6 +1682,7 @@ xfs_rmap_convert_shared(
if (XFS_IS_CORRUPT(mp, if (XFS_IS_CORRUPT(mp,
LEFT.rm_startblock + LEFT.rm_blockcount > LEFT.rm_startblock + LEFT.rm_blockcount >
bno)) { bno)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -1656,10 +1701,12 @@ xfs_rmap_convert_shared( ...@@ -1656,10 +1701,12 @@ xfs_rmap_convert_shared(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
if (XFS_IS_CORRUPT(mp, bno + len > RIGHT.rm_startblock)) { if (XFS_IS_CORRUPT(mp, bno + len > RIGHT.rm_startblock)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -1710,6 +1757,7 @@ xfs_rmap_convert_shared( ...@@ -1710,6 +1757,7 @@ xfs_rmap_convert_shared(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -1736,6 +1784,7 @@ xfs_rmap_convert_shared( ...@@ -1736,6 +1784,7 @@ xfs_rmap_convert_shared(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -1762,6 +1811,7 @@ xfs_rmap_convert_shared( ...@@ -1762,6 +1811,7 @@ xfs_rmap_convert_shared(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -1785,6 +1835,7 @@ xfs_rmap_convert_shared( ...@@ -1785,6 +1835,7 @@ xfs_rmap_convert_shared(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -1820,6 +1871,7 @@ xfs_rmap_convert_shared( ...@@ -1820,6 +1871,7 @@ xfs_rmap_convert_shared(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -1865,6 +1917,7 @@ xfs_rmap_convert_shared( ...@@ -1865,6 +1917,7 @@ xfs_rmap_convert_shared(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -1900,6 +1953,7 @@ xfs_rmap_convert_shared( ...@@ -1900,6 +1953,7 @@ xfs_rmap_convert_shared(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -1938,6 +1992,7 @@ xfs_rmap_convert_shared( ...@@ -1938,6 +1992,7 @@ xfs_rmap_convert_shared(
if (error) if (error)
goto done; goto done;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto done; goto done;
} }
...@@ -2027,6 +2082,7 @@ xfs_rmap_unmap_shared( ...@@ -2027,6 +2082,7 @@ xfs_rmap_unmap_shared(
if (error) if (error)
goto out_error; goto out_error;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out_error; goto out_error;
} }
...@@ -2037,12 +2093,14 @@ xfs_rmap_unmap_shared( ...@@ -2037,12 +2093,14 @@ xfs_rmap_unmap_shared(
ltrec.rm_startblock > bno || ltrec.rm_startblock > bno ||
ltrec.rm_startblock + ltrec.rm_blockcount < ltrec.rm_startblock + ltrec.rm_blockcount <
bno + len)) { bno + len)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out_error; goto out_error;
} }
/* Make sure the owner matches what we expect to find in the tree. */ /* Make sure the owner matches what we expect to find in the tree. */
if (XFS_IS_CORRUPT(mp, owner != ltrec.rm_owner)) { if (XFS_IS_CORRUPT(mp, owner != ltrec.rm_owner)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out_error; goto out_error;
} }
...@@ -2051,16 +2109,19 @@ xfs_rmap_unmap_shared( ...@@ -2051,16 +2109,19 @@ xfs_rmap_unmap_shared(
if (XFS_IS_CORRUPT(mp, if (XFS_IS_CORRUPT(mp,
(flags & XFS_RMAP_UNWRITTEN) != (flags & XFS_RMAP_UNWRITTEN) !=
(ltrec.rm_flags & XFS_RMAP_UNWRITTEN))) { (ltrec.rm_flags & XFS_RMAP_UNWRITTEN))) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out_error; goto out_error;
} }
/* Check the offset. */ /* Check the offset. */
if (XFS_IS_CORRUPT(mp, ltrec.rm_offset > offset)) { if (XFS_IS_CORRUPT(mp, ltrec.rm_offset > offset)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out_error; goto out_error;
} }
if (XFS_IS_CORRUPT(mp, offset > ltoff + ltrec.rm_blockcount)) { if (XFS_IS_CORRUPT(mp, offset > ltoff + ltrec.rm_blockcount)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out_error; goto out_error;
} }
...@@ -2117,6 +2178,7 @@ xfs_rmap_unmap_shared( ...@@ -2117,6 +2178,7 @@ xfs_rmap_unmap_shared(
if (error) if (error)
goto out_error; goto out_error;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out_error; goto out_error;
} }
...@@ -2146,6 +2208,7 @@ xfs_rmap_unmap_shared( ...@@ -2146,6 +2208,7 @@ xfs_rmap_unmap_shared(
if (error) if (error)
goto out_error; goto out_error;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out_error; goto out_error;
} }
...@@ -2225,6 +2288,7 @@ xfs_rmap_map_shared( ...@@ -2225,6 +2288,7 @@ xfs_rmap_map_shared(
if (error) if (error)
goto out_error; goto out_error;
if (XFS_IS_CORRUPT(mp, have_gt != 1)) { if (XFS_IS_CORRUPT(mp, have_gt != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out_error; goto out_error;
} }
...@@ -2277,6 +2341,7 @@ xfs_rmap_map_shared( ...@@ -2277,6 +2341,7 @@ xfs_rmap_map_shared(
if (error) if (error)
goto out_error; goto out_error;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out_error; goto out_error;
} }
...@@ -2480,10 +2545,14 @@ xfs_rmap_finish_one( ...@@ -2480,10 +2545,14 @@ xfs_rmap_finish_one(
* allocate blocks. * allocate blocks.
*/ */
error = xfs_free_extent_fix_freelist(tp, ri->ri_pag, &agbp); error = xfs_free_extent_fix_freelist(tp, ri->ri_pag, &agbp);
if (error) if (error) {
xfs_ag_mark_sick(ri->ri_pag, XFS_SICK_AG_AGFL);
return error; return error;
if (XFS_IS_CORRUPT(tp->t_mountp, !agbp)) }
if (XFS_IS_CORRUPT(tp->t_mountp, !agbp)) {
xfs_ag_mark_sick(ri->ri_pag, XFS_SICK_AG_AGFL);
return -EFSCORRUPTED; return -EFSCORRUPTED;
}
rcur = xfs_rmapbt_init_cursor(mp, tp, agbp, ri->ri_pag); rcur = xfs_rmapbt_init_cursor(mp, tp, agbp, ri->ri_pag);
} }
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "xfs_refcount_btree.h" #include "xfs_refcount_btree.h"
#include "xfs_error.h" #include "xfs_error.h"
#include "xfs_ag.h" #include "xfs_ag.h"
#include "xfs_health.h"
#include "scrub/xfs_scrub.h" #include "scrub/xfs_scrub.h"
#include "scrub/scrub.h" #include "scrub/scrub.h"
#include "scrub/common.h" #include "scrub/common.h"
...@@ -253,8 +254,10 @@ xrep_refc_walk_rmaps( ...@@ -253,8 +254,10 @@ xrep_refc_walk_rmaps(
error = xfs_rmap_get_rec(cur, &rmap, &have_gt); error = xfs_rmap_get_rec(cur, &rmap, &have_gt);
if (error) if (error)
return error; return error;
if (XFS_IS_CORRUPT(mp, !have_gt)) if (XFS_IS_CORRUPT(mp, !have_gt)) {
xfs_btree_mark_sick(cur);
return -EFSCORRUPTED; return -EFSCORRUPTED;
}
if (rmap.rm_owner == XFS_RMAP_OWN_COW) { if (rmap.rm_owner == XFS_RMAP_OWN_COW) {
error = xrep_refc_stash_cow(rr, rmap.rm_startblock, error = xrep_refc_stash_cow(rr, rmap.rm_startblock,
...@@ -425,8 +428,10 @@ xrep_refc_push_rmaps_at( ...@@ -425,8 +428,10 @@ xrep_refc_push_rmaps_at(
error = xfs_btree_decrement(sc->sa.rmap_cur, 0, &have_gt); error = xfs_btree_decrement(sc->sa.rmap_cur, 0, &have_gt);
if (error) if (error)
return error; return error;
if (XFS_IS_CORRUPT(sc->mp, !have_gt)) if (XFS_IS_CORRUPT(sc->mp, !have_gt)) {
xfs_btree_mark_sick(sc->sa.rmap_cur);
return -EFSCORRUPTED; return -EFSCORRUPTED;
}
return 0; return 0;
} }
......
...@@ -83,8 +83,10 @@ xfs_attr_shortform_list( ...@@ -83,8 +83,10 @@ xfs_attr_shortform_list(
for (i = 0, sfe = xfs_attr_sf_firstentry(sf); i < sf->count; i++) { for (i = 0, sfe = xfs_attr_sf_firstentry(sf); i < sf->count; i++) {
if (XFS_IS_CORRUPT(context->dp->i_mount, if (XFS_IS_CORRUPT(context->dp->i_mount,
!xfs_attr_namecheck(sfe->nameval, !xfs_attr_namecheck(sfe->nameval,
sfe->namelen))) sfe->namelen))) {
xfs_dirattr_mark_sick(context->dp, XFS_ATTR_FORK);
return -EFSCORRUPTED; return -EFSCORRUPTED;
}
context->put_listent(context, context->put_listent(context,
sfe->flags, sfe->flags,
sfe->nameval, sfe->nameval,
...@@ -177,6 +179,7 @@ xfs_attr_shortform_list( ...@@ -177,6 +179,7 @@ xfs_attr_shortform_list(
if (XFS_IS_CORRUPT(context->dp->i_mount, if (XFS_IS_CORRUPT(context->dp->i_mount,
!xfs_attr_namecheck(sbp->name, !xfs_attr_namecheck(sbp->name,
sbp->namelen))) { sbp->namelen))) {
xfs_dirattr_mark_sick(context->dp, XFS_ATTR_FORK);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out; goto out;
} }
...@@ -471,8 +474,10 @@ xfs_attr3_leaf_list_int( ...@@ -471,8 +474,10 @@ xfs_attr3_leaf_list_int(
} }
if (XFS_IS_CORRUPT(context->dp->i_mount, if (XFS_IS_CORRUPT(context->dp->i_mount,
!xfs_attr_namecheck(name, namelen))) !xfs_attr_namecheck(name, namelen))) {
xfs_dirattr_mark_sick(context->dp, XFS_ATTR_FORK);
return -EFSCORRUPTED; return -EFSCORRUPTED;
}
context->put_listent(context, entry->flags, context->put_listent(context, entry->flags,
name, namelen, valuelen); name, namelen, valuelen);
if (context->seen_enough) if (context->seen_enough)
......
...@@ -118,8 +118,10 @@ xfs_dir2_sf_getdents( ...@@ -118,8 +118,10 @@ xfs_dir2_sf_getdents(
ctx->pos = off & 0x7fffffff; ctx->pos = off & 0x7fffffff;
if (XFS_IS_CORRUPT(dp->i_mount, if (XFS_IS_CORRUPT(dp->i_mount,
!xfs_dir2_namecheck(sfep->name, !xfs_dir2_namecheck(sfep->name,
sfep->namelen))) sfep->namelen))) {
xfs_dirattr_mark_sick(dp, XFS_DATA_FORK);
return -EFSCORRUPTED; return -EFSCORRUPTED;
}
if (!dir_emit(ctx, (char *)sfep->name, sfep->namelen, ino, if (!dir_emit(ctx, (char *)sfep->name, sfep->namelen, ino,
xfs_dir3_get_dtype(mp, filetype))) xfs_dir3_get_dtype(mp, filetype)))
return 0; return 0;
...@@ -211,6 +213,7 @@ xfs_dir2_block_getdents( ...@@ -211,6 +213,7 @@ xfs_dir2_block_getdents(
if (XFS_IS_CORRUPT(dp->i_mount, if (XFS_IS_CORRUPT(dp->i_mount,
!xfs_dir2_namecheck(dep->name, !xfs_dir2_namecheck(dep->name,
dep->namelen))) { dep->namelen))) {
xfs_dirattr_mark_sick(dp, XFS_DATA_FORK);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out_rele; goto out_rele;
} }
...@@ -465,6 +468,7 @@ xfs_dir2_leaf_getdents( ...@@ -465,6 +468,7 @@ xfs_dir2_leaf_getdents(
if (XFS_IS_CORRUPT(dp->i_mount, if (XFS_IS_CORRUPT(dp->i_mount,
!xfs_dir2_namecheck(dep->name, !xfs_dir2_namecheck(dep->name,
dep->namelen))) { dep->namelen))) {
xfs_dirattr_mark_sick(dp, XFS_DATA_FORK);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
break; break;
} }
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "xfs_trace.h" #include "xfs_trace.h"
#include "xfs_log.h" #include "xfs_log.h"
#include "xfs_ag.h" #include "xfs_ag.h"
#include "xfs_health.h"
/* /*
* Notes on an efficient, low latency fstrim algorithm * Notes on an efficient, low latency fstrim algorithm
...@@ -210,6 +211,7 @@ xfs_trim_gather_extents( ...@@ -210,6 +211,7 @@ xfs_trim_gather_extents(
if (error) if (error)
break; break;
if (XFS_IS_CORRUPT(mp, i != 1)) { if (XFS_IS_CORRUPT(mp, i != 1)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
break; break;
} }
......
...@@ -297,8 +297,10 @@ xfs_iwalk_ag_start( ...@@ -297,8 +297,10 @@ xfs_iwalk_ag_start(
error = xfs_inobt_get_rec(*curpp, irec, has_more); error = xfs_inobt_get_rec(*curpp, irec, has_more);
if (error) if (error)
return error; return error;
if (XFS_IS_CORRUPT(mp, *has_more != 1)) if (XFS_IS_CORRUPT(mp, *has_more != 1)) {
xfs_btree_mark_sick(*curpp);
return -EFSCORRUPTED; return -EFSCORRUPTED;
}
iwag->lastino = XFS_AGINO_TO_INO(mp, pag->pag_agno, iwag->lastino = XFS_AGINO_TO_INO(mp, pag->pag_agno,
irec->ir_startino + XFS_INODES_PER_CHUNK - 1); irec->ir_startino + XFS_INODES_PER_CHUNK - 1);
...@@ -425,6 +427,7 @@ xfs_iwalk_ag( ...@@ -425,6 +427,7 @@ xfs_iwalk_ag(
rec_fsino = XFS_AGINO_TO_INO(mp, pag->pag_agno, irec->ir_startino); rec_fsino = XFS_AGINO_TO_INO(mp, pag->pag_agno, irec->ir_startino);
if (iwag->lastino != NULLFSINO && if (iwag->lastino != NULLFSINO &&
XFS_IS_CORRUPT(mp, iwag->lastino >= rec_fsino)) { XFS_IS_CORRUPT(mp, iwag->lastino >= rec_fsino)) {
xfs_btree_mark_sick(cur);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out; goto out;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment