xfs: kill the XFS_WANT_CORRUPT_* macros
The XFS_WANT_CORRUPT_* macros conceal subtle side effects such as the creation of local variables and redirections of the code flow. This is pretty ugly, so replace them with explicit XFS_IS_CORRUPT tests that remove both of those ugly points. The change was performed with the following coccinelle script: @@ expression mp, test; identifier label; @@ - XFS_WANT_CORRUPTED_GOTO(mp, test, label); + if (XFS_IS_CORRUPT(mp, !test)) { error = -EFSCORRUPTED; goto label; } @@ expression mp, test; @@ - XFS_WANT_CORRUPTED_RETURN(mp, test); + if (XFS_IS_CORRUPT(mp, !test)) return -EFSCORRUPTED; @@ expression mp, lval, rval; @@ - XFS_IS_CORRUPT(mp, !(lval == rval)) + XFS_IS_CORRUPT(mp, lval != rval) @@ expression mp, e1, e2; @@ - XFS_IS_CORRUPT(mp, !(e1 && e2)) + XFS_IS_CORRUPT(mp, !e1 || !e2) @@ expression e1, e2; @@ - !(e1 == e2) + e1 != e2 @@ expression e1, e2, e3, e4, e5, e6; @@ - !(e1 == e2 && e3 == e4) || e5 != e6 + e1 != e2 || e3 != e4 || e5 != e6 @@ expression e1, e2, e3, e4, e5, e6; @@ - !(e1 == e2 || (e3 <= e4 && e5 <= e6)) + e1 != e2 && (e3 > e4 || e5 > e6) @@ expression mp, e1, e2; @@ - XFS_IS_CORRUPT(mp, !(e1 <= e2)) + XFS_IS_CORRUPT(mp, e1 > e2) @@ expression mp, e1, e2; @@ - XFS_IS_CORRUPT(mp, !(e1 < e2)) + XFS_IS_CORRUPT(mp, e1 >= e2) @@ expression mp, e1; @@ - XFS_IS_CORRUPT(mp, !!e1) + XFS_IS_CORRUPT(mp, e1) @@ expression mp, e1, e2; @@ - XFS_IS_CORRUPT(mp, !(e1 || e2)) + XFS_IS_CORRUPT(mp, !e1 && !e2) @@ expression mp, e1, e2, e3, e4; @@ - XFS_IS_CORRUPT(mp, !(e1 == e2) && !(e3 == e4)) + XFS_IS_CORRUPT(mp, e1 != e2 && e3 != e4) @@ expression mp, e1, e2, e3, e4; @@ - XFS_IS_CORRUPT(mp, !(e1 <= e2) || !(e3 >= e4)) + XFS_IS_CORRUPT(mp, e1 > e2 || e3 < e4) @@ expression mp, e1, e2, e3, e4; @@ - XFS_IS_CORRUPT(mp, !(e1 == e2) && !(e3 <= e4)) + XFS_IS_CORRUPT(mp, e1 != e2 && e3 > e4) Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Christoph Hellwig <hch@lst.de>
This commit is contained in:
Родитель
1ec28615d2
Коммит
f9e0370648
|
@ -451,13 +451,17 @@ xfs_alloc_fixup_trees(
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if ((error = xfs_alloc_get_rec(cnt_cur, &nfbno1, &nflen1, &i)))
|
if ((error = xfs_alloc_get_rec(cnt_cur, &nfbno1, &nflen1, &i)))
|
||||||
return error;
|
return error;
|
||||||
XFS_WANT_CORRUPTED_RETURN(mp,
|
if (XFS_IS_CORRUPT(mp,
|
||||||
i == 1 && nfbno1 == fbno && nflen1 == flen);
|
i != 1 ||
|
||||||
|
nfbno1 != fbno ||
|
||||||
|
nflen1 != flen))
|
||||||
|
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;
|
||||||
XFS_WANT_CORRUPTED_RETURN(mp, i == 1);
|
if (XFS_IS_CORRUPT(mp, i != 1))
|
||||||
|
return -EFSCORRUPTED;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Look up the record in the by-block tree if necessary.
|
* Look up the record in the by-block tree if necessary.
|
||||||
|
@ -466,13 +470,17 @@ xfs_alloc_fixup_trees(
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if ((error = xfs_alloc_get_rec(bno_cur, &nfbno1, &nflen1, &i)))
|
if ((error = xfs_alloc_get_rec(bno_cur, &nfbno1, &nflen1, &i)))
|
||||||
return error;
|
return error;
|
||||||
XFS_WANT_CORRUPTED_RETURN(mp,
|
if (XFS_IS_CORRUPT(mp,
|
||||||
i == 1 && nfbno1 == fbno && nflen1 == flen);
|
i != 1 ||
|
||||||
|
nfbno1 != fbno ||
|
||||||
|
nflen1 != flen))
|
||||||
|
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;
|
||||||
XFS_WANT_CORRUPTED_RETURN(mp, i == 1);
|
if (XFS_IS_CORRUPT(mp, i != 1))
|
||||||
|
return -EFSCORRUPTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
@ -483,8 +491,10 @@ xfs_alloc_fixup_trees(
|
||||||
bnoblock = XFS_BUF_TO_BLOCK(bno_cur->bc_bufs[0]);
|
bnoblock = XFS_BUF_TO_BLOCK(bno_cur->bc_bufs[0]);
|
||||||
cntblock = XFS_BUF_TO_BLOCK(cnt_cur->bc_bufs[0]);
|
cntblock = XFS_BUF_TO_BLOCK(cnt_cur->bc_bufs[0]);
|
||||||
|
|
||||||
XFS_WANT_CORRUPTED_RETURN(mp,
|
if (XFS_IS_CORRUPT(mp,
|
||||||
bnoblock->bb_numrecs == cntblock->bb_numrecs);
|
bnoblock->bb_numrecs !=
|
||||||
|
cntblock->bb_numrecs))
|
||||||
|
return -EFSCORRUPTED;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -514,25 +524,30 @@ xfs_alloc_fixup_trees(
|
||||||
*/
|
*/
|
||||||
if ((error = xfs_btree_delete(cnt_cur, &i)))
|
if ((error = xfs_btree_delete(cnt_cur, &i)))
|
||||||
return error;
|
return error;
|
||||||
XFS_WANT_CORRUPTED_RETURN(mp, i == 1);
|
if (XFS_IS_CORRUPT(mp, i != 1))
|
||||||
|
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;
|
||||||
XFS_WANT_CORRUPTED_RETURN(mp, i == 0);
|
if (XFS_IS_CORRUPT(mp, i != 0))
|
||||||
|
return -EFSCORRUPTED;
|
||||||
if ((error = xfs_btree_insert(cnt_cur, &i)))
|
if ((error = xfs_btree_insert(cnt_cur, &i)))
|
||||||
return error;
|
return error;
|
||||||
XFS_WANT_CORRUPTED_RETURN(mp, i == 1);
|
if (XFS_IS_CORRUPT(mp, i != 1))
|
||||||
|
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;
|
||||||
XFS_WANT_CORRUPTED_RETURN(mp, i == 0);
|
if (XFS_IS_CORRUPT(mp, i != 0))
|
||||||
|
return -EFSCORRUPTED;
|
||||||
if ((error = xfs_btree_insert(cnt_cur, &i)))
|
if ((error = xfs_btree_insert(cnt_cur, &i)))
|
||||||
return error;
|
return error;
|
||||||
XFS_WANT_CORRUPTED_RETURN(mp, i == 1);
|
if (XFS_IS_CORRUPT(mp, i != 1))
|
||||||
|
return -EFSCORRUPTED;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Fix up the by-block btree entry(s).
|
* Fix up the by-block btree entry(s).
|
||||||
|
@ -543,7 +558,8 @@ xfs_alloc_fixup_trees(
|
||||||
*/
|
*/
|
||||||
if ((error = xfs_btree_delete(bno_cur, &i)))
|
if ((error = xfs_btree_delete(bno_cur, &i)))
|
||||||
return error;
|
return error;
|
||||||
XFS_WANT_CORRUPTED_RETURN(mp, i == 1);
|
if (XFS_IS_CORRUPT(mp, i != 1))
|
||||||
|
return -EFSCORRUPTED;
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* Update the by-block entry to start later|be shorter.
|
* Update the by-block entry to start later|be shorter.
|
||||||
|
@ -557,10 +573,12 @@ 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;
|
||||||
XFS_WANT_CORRUPTED_RETURN(mp, i == 0);
|
if (XFS_IS_CORRUPT(mp, i != 0))
|
||||||
|
return -EFSCORRUPTED;
|
||||||
if ((error = xfs_btree_insert(bno_cur, &i)))
|
if ((error = xfs_btree_insert(bno_cur, &i)))
|
||||||
return error;
|
return error;
|
||||||
XFS_WANT_CORRUPTED_RETURN(mp, i == 1);
|
if (XFS_IS_CORRUPT(mp, i != 1))
|
||||||
|
return -EFSCORRUPTED;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -821,7 +839,8 @@ 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;
|
||||||
XFS_WANT_CORRUPTED_RETURN(args->mp, i == 1);
|
if (XFS_IS_CORRUPT(args->mp, i != 1))
|
||||||
|
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
|
||||||
|
@ -1026,7 +1045,10 @@ xfs_alloc_ag_vextent_small(
|
||||||
error = xfs_alloc_get_rec(ccur, &fbno, &flen, &i);
|
error = xfs_alloc_get_rec(ccur, &fbno, &flen, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto error;
|
goto error;
|
||||||
XFS_WANT_CORRUPTED_GOTO(args->mp, i == 1, error);
|
if (XFS_IS_CORRUPT(args->mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1058,9 +1080,12 @@ xfs_alloc_ag_vextent_small(
|
||||||
}
|
}
|
||||||
*fbnop = args->agbno = fbno;
|
*fbnop = args->agbno = fbno;
|
||||||
*flenp = args->len = 1;
|
*flenp = args->len = 1;
|
||||||
XFS_WANT_CORRUPTED_GOTO(args->mp,
|
if (XFS_IS_CORRUPT(args->mp,
|
||||||
fbno < be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_length),
|
fbno >= be32_to_cpu(
|
||||||
error);
|
XFS_BUF_TO_AGF(args->agbp)->agf_length))) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
args->wasfromfl = 1;
|
args->wasfromfl = 1;
|
||||||
trace_xfs_alloc_small_freelist(args);
|
trace_xfs_alloc_small_freelist(args);
|
||||||
|
|
||||||
|
@ -1215,7 +1240,10 @@ xfs_alloc_ag_vextent_exact(
|
||||||
error = xfs_alloc_get_rec(bno_cur, &fbno, &flen, &i);
|
error = xfs_alloc_get_rec(bno_cur, &fbno, &flen, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto error0;
|
goto error0;
|
||||||
XFS_WANT_CORRUPTED_GOTO(args->mp, i == 1, error0);
|
if (XFS_IS_CORRUPT(args->mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto error0;
|
||||||
|
}
|
||||||
ASSERT(fbno <= args->agbno);
|
ASSERT(fbno <= args->agbno);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1494,7 +1522,8 @@ 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;
|
||||||
XFS_WANT_CORRUPTED_RETURN(args->mp, i == 1);
|
if (XFS_IS_CORRUPT(args->mp, i != 1))
|
||||||
|
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);
|
||||||
|
@ -1688,7 +1717,10 @@ restart:
|
||||||
error = xfs_alloc_get_rec(cnt_cur, &fbno, &flen, &i);
|
error = xfs_alloc_get_rec(cnt_cur, &fbno, &flen, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto error0;
|
goto error0;
|
||||||
XFS_WANT_CORRUPTED_GOTO(args->mp, i == 1, error0);
|
if (XFS_IS_CORRUPT(args->mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto error0;
|
||||||
|
}
|
||||||
|
|
||||||
busy = xfs_alloc_compute_aligned(args, fbno, flen,
|
busy = xfs_alloc_compute_aligned(args, fbno, flen,
|
||||||
&rbno, &rlen, &busy_gen);
|
&rbno, &rlen, &busy_gen);
|
||||||
|
@ -1722,8 +1754,13 @@ restart:
|
||||||
* This can't happen in the second case above.
|
* This can't happen in the second case above.
|
||||||
*/
|
*/
|
||||||
rlen = XFS_EXTLEN_MIN(args->maxlen, rlen);
|
rlen = XFS_EXTLEN_MIN(args->maxlen, rlen);
|
||||||
XFS_WANT_CORRUPTED_GOTO(args->mp, rlen == 0 ||
|
if (XFS_IS_CORRUPT(args->mp,
|
||||||
(rlen <= flen && rbno + rlen <= fbno + flen), error0);
|
rlen != 0 &&
|
||||||
|
(rlen > flen ||
|
||||||
|
rbno + rlen > fbno + flen))) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto error0;
|
||||||
|
}
|
||||||
if (rlen < args->maxlen) {
|
if (rlen < args->maxlen) {
|
||||||
xfs_agblock_t bestfbno;
|
xfs_agblock_t bestfbno;
|
||||||
xfs_extlen_t bestflen;
|
xfs_extlen_t bestflen;
|
||||||
|
@ -1742,15 +1779,22 @@ restart:
|
||||||
if ((error = xfs_alloc_get_rec(cnt_cur, &fbno, &flen,
|
if ((error = xfs_alloc_get_rec(cnt_cur, &fbno, &flen,
|
||||||
&i)))
|
&i)))
|
||||||
goto error0;
|
goto error0;
|
||||||
XFS_WANT_CORRUPTED_GOTO(args->mp, i == 1, error0);
|
if (XFS_IS_CORRUPT(args->mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto error0;
|
||||||
|
}
|
||||||
if (flen < bestrlen)
|
if (flen < bestrlen)
|
||||||
break;
|
break;
|
||||||
busy = xfs_alloc_compute_aligned(args, fbno, flen,
|
busy = xfs_alloc_compute_aligned(args, fbno, flen,
|
||||||
&rbno, &rlen, &busy_gen);
|
&rbno, &rlen, &busy_gen);
|
||||||
rlen = XFS_EXTLEN_MIN(args->maxlen, rlen);
|
rlen = XFS_EXTLEN_MIN(args->maxlen, rlen);
|
||||||
XFS_WANT_CORRUPTED_GOTO(args->mp, rlen == 0 ||
|
if (XFS_IS_CORRUPT(args->mp,
|
||||||
(rlen <= flen && rbno + rlen <= fbno + flen),
|
rlen != 0 &&
|
||||||
error0);
|
(rlen > flen ||
|
||||||
|
rbno + rlen > fbno + flen))) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto error0;
|
||||||
|
}
|
||||||
if (rlen > bestrlen) {
|
if (rlen > bestrlen) {
|
||||||
bestrlen = rlen;
|
bestrlen = rlen;
|
||||||
bestrbno = rbno;
|
bestrbno = rbno;
|
||||||
|
@ -1763,7 +1807,10 @@ restart:
|
||||||
if ((error = xfs_alloc_lookup_eq(cnt_cur, bestfbno, bestflen,
|
if ((error = xfs_alloc_lookup_eq(cnt_cur, bestfbno, bestflen,
|
||||||
&i)))
|
&i)))
|
||||||
goto error0;
|
goto error0;
|
||||||
XFS_WANT_CORRUPTED_GOTO(args->mp, i == 1, error0);
|
if (XFS_IS_CORRUPT(args->mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto error0;
|
||||||
|
}
|
||||||
rlen = bestrlen;
|
rlen = bestrlen;
|
||||||
rbno = bestrbno;
|
rbno = bestrbno;
|
||||||
flen = bestflen;
|
flen = bestflen;
|
||||||
|
@ -1786,7 +1833,10 @@ restart:
|
||||||
xfs_alloc_fix_len(args);
|
xfs_alloc_fix_len(args);
|
||||||
|
|
||||||
rlen = args->len;
|
rlen = args->len;
|
||||||
XFS_WANT_CORRUPTED_GOTO(args->mp, rlen <= flen, error0);
|
if (XFS_IS_CORRUPT(args->mp, rlen > flen)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto error0;
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* Allocate and initialize a cursor for the by-block tree.
|
* Allocate and initialize a cursor for the by-block tree.
|
||||||
*/
|
*/
|
||||||
|
@ -1800,10 +1850,13 @@ restart:
|
||||||
cnt_cur = bno_cur = NULL;
|
cnt_cur = bno_cur = NULL;
|
||||||
args->len = rlen;
|
args->len = rlen;
|
||||||
args->agbno = rbno;
|
args->agbno = rbno;
|
||||||
XFS_WANT_CORRUPTED_GOTO(args->mp,
|
if (XFS_IS_CORRUPT(args->mp,
|
||||||
args->agbno + args->len <=
|
args->agbno + args->len >
|
||||||
be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_length),
|
be32_to_cpu(
|
||||||
error0);
|
XFS_BUF_TO_AGF(args->agbp)->agf_length))) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto error0;
|
||||||
|
}
|
||||||
trace_xfs_alloc_size_done(args);
|
trace_xfs_alloc_size_done(args);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -1875,7 +1928,10 @@ xfs_free_ag_extent(
|
||||||
*/
|
*/
|
||||||
if ((error = xfs_alloc_get_rec(bno_cur, <bno, <len, &i)))
|
if ((error = xfs_alloc_get_rec(bno_cur, <bno, <len, &i)))
|
||||||
goto error0;
|
goto error0;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, error0);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto error0;
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* It's not contiguous, though.
|
* It's not contiguous, though.
|
||||||
*/
|
*/
|
||||||
|
@ -1887,8 +1943,10 @@ xfs_free_ag_extent(
|
||||||
* space was invalid, it's (partly) already free.
|
* space was invalid, it's (partly) already free.
|
||||||
* Very bad.
|
* Very bad.
|
||||||
*/
|
*/
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp,
|
if (XFS_IS_CORRUPT(mp, ltbno + ltlen > bno)) {
|
||||||
ltbno + ltlen <= bno, error0);
|
error = -EFSCORRUPTED;
|
||||||
|
goto error0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
@ -1903,7 +1961,10 @@ xfs_free_ag_extent(
|
||||||
*/
|
*/
|
||||||
if ((error = xfs_alloc_get_rec(bno_cur, >bno, >len, &i)))
|
if ((error = xfs_alloc_get_rec(bno_cur, >bno, >len, &i)))
|
||||||
goto error0;
|
goto error0;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, error0);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto error0;
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* It's not contiguous, though.
|
* It's not contiguous, though.
|
||||||
*/
|
*/
|
||||||
|
@ -1915,7 +1976,10 @@ xfs_free_ag_extent(
|
||||||
* space was invalid, it's (partly) already free.
|
* space was invalid, it's (partly) already free.
|
||||||
* Very bad.
|
* Very bad.
|
||||||
*/
|
*/
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, gtbno >= bno + len, error0);
|
if (XFS_IS_CORRUPT(mp, bno + len > gtbno)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto error0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
@ -1932,31 +1996,49 @@ 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;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, error0);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto error0;
|
||||||
|
}
|
||||||
if ((error = xfs_btree_delete(cnt_cur, &i)))
|
if ((error = xfs_btree_delete(cnt_cur, &i)))
|
||||||
goto error0;
|
goto error0;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, error0);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto error0;
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* Delete the old by-size entry on the right.
|
* Delete the old by-size entry on the right.
|
||||||
*/
|
*/
|
||||||
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;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, error0);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto error0;
|
||||||
|
}
|
||||||
if ((error = xfs_btree_delete(cnt_cur, &i)))
|
if ((error = xfs_btree_delete(cnt_cur, &i)))
|
||||||
goto error0;
|
goto error0;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, error0);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto error0;
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* Delete the old by-block entry for the right block.
|
* Delete the old by-block entry for the right block.
|
||||||
*/
|
*/
|
||||||
if ((error = xfs_btree_delete(bno_cur, &i)))
|
if ((error = xfs_btree_delete(bno_cur, &i)))
|
||||||
goto error0;
|
goto error0;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, error0);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto error0;
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* Move the by-block cursor back to the left neighbor.
|
* Move the by-block cursor back to the left neighbor.
|
||||||
*/
|
*/
|
||||||
if ((error = xfs_btree_decrement(bno_cur, 0, &i)))
|
if ((error = xfs_btree_decrement(bno_cur, 0, &i)))
|
||||||
goto error0;
|
goto error0;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, error0);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto error0;
|
||||||
|
}
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
/*
|
/*
|
||||||
* Check that this is the right record: delete didn't
|
* Check that this is the right record: delete didn't
|
||||||
|
@ -1969,9 +2051,13 @@ xfs_free_ag_extent(
|
||||||
if ((error = xfs_alloc_get_rec(bno_cur, &xxbno, &xxlen,
|
if ((error = xfs_alloc_get_rec(bno_cur, &xxbno, &xxlen,
|
||||||
&i)))
|
&i)))
|
||||||
goto error0;
|
goto error0;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp,
|
if (XFS_IS_CORRUPT(mp,
|
||||||
i == 1 && xxbno == ltbno && xxlen == ltlen,
|
i != 1 ||
|
||||||
error0);
|
xxbno != ltbno ||
|
||||||
|
xxlen != ltlen)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto error0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
/*
|
/*
|
||||||
|
@ -1992,17 +2078,26 @@ 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;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, error0);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto error0;
|
||||||
|
}
|
||||||
if ((error = xfs_btree_delete(cnt_cur, &i)))
|
if ((error = xfs_btree_delete(cnt_cur, &i)))
|
||||||
goto error0;
|
goto error0;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, error0);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto error0;
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* Back up the by-block cursor to the left neighbor, and
|
* Back up the by-block cursor to the left neighbor, and
|
||||||
* update its length.
|
* update its length.
|
||||||
*/
|
*/
|
||||||
if ((error = xfs_btree_decrement(bno_cur, 0, &i)))
|
if ((error = xfs_btree_decrement(bno_cur, 0, &i)))
|
||||||
goto error0;
|
goto error0;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, error0);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto error0;
|
||||||
|
}
|
||||||
nbno = ltbno;
|
nbno = ltbno;
|
||||||
nlen = len + ltlen;
|
nlen = len + ltlen;
|
||||||
if ((error = xfs_alloc_update(bno_cur, nbno, nlen)))
|
if ((error = xfs_alloc_update(bno_cur, nbno, nlen)))
|
||||||
|
@ -2018,10 +2113,16 @@ 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;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, error0);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto error0;
|
||||||
|
}
|
||||||
if ((error = xfs_btree_delete(cnt_cur, &i)))
|
if ((error = xfs_btree_delete(cnt_cur, &i)))
|
||||||
goto error0;
|
goto error0;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, error0);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto error0;
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* Update the starting block and length of the right
|
* Update the starting block and length of the right
|
||||||
* neighbor in the by-block tree.
|
* neighbor in the by-block tree.
|
||||||
|
@ -2040,7 +2141,10 @@ xfs_free_ag_extent(
|
||||||
nlen = len;
|
nlen = len;
|
||||||
if ((error = xfs_btree_insert(bno_cur, &i)))
|
if ((error = xfs_btree_insert(bno_cur, &i)))
|
||||||
goto error0;
|
goto error0;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, error0);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto error0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
xfs_btree_del_cursor(bno_cur, XFS_BTREE_NOERROR);
|
xfs_btree_del_cursor(bno_cur, XFS_BTREE_NOERROR);
|
||||||
bno_cur = NULL;
|
bno_cur = NULL;
|
||||||
|
@ -2049,10 +2153,16 @@ 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;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 0, error0);
|
if (XFS_IS_CORRUPT(mp, i != 0)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto error0;
|
||||||
|
}
|
||||||
if ((error = xfs_btree_insert(cnt_cur, &i)))
|
if ((error = xfs_btree_insert(cnt_cur, &i)))
|
||||||
goto error0;
|
goto error0;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, error0);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto error0;
|
||||||
|
}
|
||||||
xfs_btree_del_cursor(cnt_cur, XFS_BTREE_NOERROR);
|
xfs_btree_del_cursor(cnt_cur, XFS_BTREE_NOERROR);
|
||||||
cnt_cur = NULL;
|
cnt_cur = NULL;
|
||||||
|
|
||||||
|
@ -3177,12 +3287,18 @@ __xfs_free_extent(
|
||||||
if (error)
|
if (error)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, agbno < mp->m_sb.sb_agblocks, err);
|
if (XFS_IS_CORRUPT(mp, agbno >= mp->m_sb.sb_agblocks)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
/* validate the extent size is legal now we have the agf locked */
|
/* validate the extent size is legal now we have the agf locked */
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp,
|
if (XFS_IS_CORRUPT(mp,
|
||||||
agbno + len <= be32_to_cpu(XFS_BUF_TO_AGF(agbp)->agf_length),
|
agbno + len >
|
||||||
err);
|
be32_to_cpu(XFS_BUF_TO_AGF(agbp)->agf_length))) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
error = xfs_free_ag_extent(tp, agbp, agno, agbno, len, oinfo, type);
|
error = xfs_free_ag_extent(tp, agbp, agno, agbno, len, oinfo, type);
|
||||||
if (error)
|
if (error)
|
||||||
|
|
|
@ -384,8 +384,10 @@ xfs_bmap_check_leaf_extents(
|
||||||
xfs_check_block(block, mp, 0, 0);
|
xfs_check_block(block, mp, 0, 0);
|
||||||
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);
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp,
|
if (XFS_IS_CORRUPT(mp, !xfs_verify_fsbno(mp, bno))) {
|
||||||
xfs_verify_fsbno(mp, bno), error0);
|
error = -EFSCORRUPTED;
|
||||||
|
goto error0;
|
||||||
|
}
|
||||||
if (bp_release) {
|
if (bp_release) {
|
||||||
bp_release = 0;
|
bp_release = 0;
|
||||||
xfs_trans_brelse(NULL, bp);
|
xfs_trans_brelse(NULL, bp);
|
||||||
|
@ -612,8 +614,8 @@ 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
|
||||||
XFS_WANT_CORRUPTED_RETURN(cur->bc_mp,
|
if (XFS_IS_CORRUPT(cur->bc_mp, !xfs_btree_check_lptr(cur, cbno, 1)))
|
||||||
xfs_btree_check_lptr(cur, cbno, 1));
|
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);
|
||||||
|
@ -938,7 +940,10 @@ xfs_bmap_add_attrfork_btree(
|
||||||
if (error)
|
if (error)
|
||||||
goto error0;
|
goto error0;
|
||||||
/* must be at least one entry */
|
/* must be at least one entry */
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, stat == 1, error0);
|
if (XFS_IS_CORRUPT(mp, stat != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto error0;
|
||||||
|
}
|
||||||
if ((error = xfs_btree_new_iroot(cur, flags, &stat)))
|
if ((error = xfs_btree_new_iroot(cur, flags, &stat)))
|
||||||
goto error0;
|
goto error0;
|
||||||
if (stat == 0) {
|
if (stat == 0) {
|
||||||
|
@ -1619,15 +1624,24 @@ xfs_bmap_add_extent_delay_real(
|
||||||
error = xfs_bmbt_lookup_eq(bma->cur, &RIGHT, &i);
|
error = xfs_bmbt_lookup_eq(bma->cur, &RIGHT, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
error = xfs_btree_delete(bma->cur, &i);
|
error = xfs_btree_delete(bma->cur, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
error = xfs_btree_decrement(bma->cur, 0, &i);
|
error = xfs_btree_decrement(bma->cur, 0, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
error = xfs_bmbt_update(bma->cur, &LEFT);
|
error = xfs_bmbt_update(bma->cur, &LEFT);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
|
@ -1653,7 +1667,10 @@ xfs_bmap_add_extent_delay_real(
|
||||||
error = xfs_bmbt_lookup_eq(bma->cur, &old, &i);
|
error = xfs_bmbt_lookup_eq(bma->cur, &old, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
error = xfs_bmbt_update(bma->cur, &LEFT);
|
error = xfs_bmbt_update(bma->cur, &LEFT);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
|
@ -1683,7 +1700,10 @@ xfs_bmap_add_extent_delay_real(
|
||||||
error = xfs_bmbt_lookup_eq(bma->cur, &RIGHT, &i);
|
error = xfs_bmbt_lookup_eq(bma->cur, &RIGHT, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
error = xfs_bmbt_update(bma->cur, &PREV);
|
error = xfs_bmbt_update(bma->cur, &PREV);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
|
@ -1708,11 +1728,17 @@ xfs_bmap_add_extent_delay_real(
|
||||||
error = xfs_bmbt_lookup_eq(bma->cur, new, &i);
|
error = xfs_bmbt_lookup_eq(bma->cur, new, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 0, done);
|
if (XFS_IS_CORRUPT(mp, i != 0)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
error = xfs_btree_insert(bma->cur, &i);
|
error = xfs_btree_insert(bma->cur, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1743,7 +1769,10 @@ xfs_bmap_add_extent_delay_real(
|
||||||
error = xfs_bmbt_lookup_eq(bma->cur, &old, &i);
|
error = xfs_bmbt_lookup_eq(bma->cur, &old, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
error = xfs_bmbt_update(bma->cur, &LEFT);
|
error = xfs_bmbt_update(bma->cur, &LEFT);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
|
@ -1764,11 +1793,17 @@ xfs_bmap_add_extent_delay_real(
|
||||||
error = xfs_bmbt_lookup_eq(bma->cur, new, &i);
|
error = xfs_bmbt_lookup_eq(bma->cur, new, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 0, done);
|
if (XFS_IS_CORRUPT(mp, i != 0)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
error = xfs_btree_insert(bma->cur, &i);
|
error = xfs_btree_insert(bma->cur, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xfs_bmap_needs_btree(bma->ip, whichfork)) {
|
if (xfs_bmap_needs_btree(bma->ip, whichfork)) {
|
||||||
|
@ -1809,7 +1844,10 @@ xfs_bmap_add_extent_delay_real(
|
||||||
error = xfs_bmbt_lookup_eq(bma->cur, &old, &i);
|
error = xfs_bmbt_lookup_eq(bma->cur, &old, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
error = xfs_bmbt_update(bma->cur, &RIGHT);
|
error = xfs_bmbt_update(bma->cur, &RIGHT);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
|
@ -1841,11 +1879,17 @@ xfs_bmap_add_extent_delay_real(
|
||||||
error = xfs_bmbt_lookup_eq(bma->cur, new, &i);
|
error = xfs_bmbt_lookup_eq(bma->cur, new, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 0, done);
|
if (XFS_IS_CORRUPT(mp, i != 0)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
error = xfs_btree_insert(bma->cur, &i);
|
error = xfs_btree_insert(bma->cur, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xfs_bmap_needs_btree(bma->ip, whichfork)) {
|
if (xfs_bmap_needs_btree(bma->ip, whichfork)) {
|
||||||
|
@ -1921,11 +1965,17 @@ xfs_bmap_add_extent_delay_real(
|
||||||
error = xfs_bmbt_lookup_eq(bma->cur, new, &i);
|
error = xfs_bmbt_lookup_eq(bma->cur, new, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 0, done);
|
if (XFS_IS_CORRUPT(mp, i != 0)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
error = xfs_btree_insert(bma->cur, &i);
|
error = xfs_btree_insert(bma->cur, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xfs_bmap_needs_btree(bma->ip, whichfork)) {
|
if (xfs_bmap_needs_btree(bma->ip, whichfork)) {
|
||||||
|
@ -2119,19 +2169,34 @@ xfs_bmap_add_extent_unwritten_real(
|
||||||
error = xfs_bmbt_lookup_eq(cur, &RIGHT, &i);
|
error = xfs_bmbt_lookup_eq(cur, &RIGHT, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
if ((error = xfs_btree_delete(cur, &i)))
|
if ((error = xfs_btree_delete(cur, &i)))
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
if ((error = xfs_btree_decrement(cur, 0, &i)))
|
if ((error = xfs_btree_decrement(cur, 0, &i)))
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
if ((error = xfs_btree_delete(cur, &i)))
|
if ((error = xfs_btree_delete(cur, &i)))
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
if ((error = xfs_btree_decrement(cur, 0, &i)))
|
if ((error = xfs_btree_decrement(cur, 0, &i)))
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
error = xfs_bmbt_update(cur, &LEFT);
|
error = xfs_bmbt_update(cur, &LEFT);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
|
@ -2157,13 +2222,22 @@ xfs_bmap_add_extent_unwritten_real(
|
||||||
error = xfs_bmbt_lookup_eq(cur, &PREV, &i);
|
error = xfs_bmbt_lookup_eq(cur, &PREV, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
if ((error = xfs_btree_delete(cur, &i)))
|
if ((error = xfs_btree_delete(cur, &i)))
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
if ((error = xfs_btree_decrement(cur, 0, &i)))
|
if ((error = xfs_btree_decrement(cur, 0, &i)))
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
error = xfs_bmbt_update(cur, &LEFT);
|
error = xfs_bmbt_update(cur, &LEFT);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
|
@ -2192,13 +2266,22 @@ xfs_bmap_add_extent_unwritten_real(
|
||||||
error = xfs_bmbt_lookup_eq(cur, &RIGHT, &i);
|
error = xfs_bmbt_lookup_eq(cur, &RIGHT, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
if ((error = xfs_btree_delete(cur, &i)))
|
if ((error = xfs_btree_delete(cur, &i)))
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
if ((error = xfs_btree_decrement(cur, 0, &i)))
|
if ((error = xfs_btree_decrement(cur, 0, &i)))
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
error = xfs_bmbt_update(cur, &PREV);
|
error = xfs_bmbt_update(cur, &PREV);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
|
@ -2221,7 +2304,10 @@ xfs_bmap_add_extent_unwritten_real(
|
||||||
error = xfs_bmbt_lookup_eq(cur, new, &i);
|
error = xfs_bmbt_lookup_eq(cur, new, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
error = xfs_bmbt_update(cur, &PREV);
|
error = xfs_bmbt_update(cur, &PREV);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
|
@ -2251,7 +2337,10 @@ xfs_bmap_add_extent_unwritten_real(
|
||||||
error = xfs_bmbt_lookup_eq(cur, &old, &i);
|
error = xfs_bmbt_lookup_eq(cur, &old, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
error = xfs_bmbt_update(cur, &PREV);
|
error = xfs_bmbt_update(cur, &PREV);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
|
@ -2285,14 +2374,20 @@ xfs_bmap_add_extent_unwritten_real(
|
||||||
error = xfs_bmbt_lookup_eq(cur, &old, &i);
|
error = xfs_bmbt_lookup_eq(cur, &old, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
error = xfs_bmbt_update(cur, &PREV);
|
error = xfs_bmbt_update(cur, &PREV);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
cur->bc_rec.b = *new;
|
cur->bc_rec.b = *new;
|
||||||
if ((error = xfs_btree_insert(cur, &i)))
|
if ((error = xfs_btree_insert(cur, &i)))
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -2319,7 +2414,10 @@ xfs_bmap_add_extent_unwritten_real(
|
||||||
error = xfs_bmbt_lookup_eq(cur, &old, &i);
|
error = xfs_bmbt_lookup_eq(cur, &old, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
error = xfs_bmbt_update(cur, &PREV);
|
error = xfs_bmbt_update(cur, &PREV);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
|
@ -2353,17 +2451,26 @@ xfs_bmap_add_extent_unwritten_real(
|
||||||
error = xfs_bmbt_lookup_eq(cur, &old, &i);
|
error = xfs_bmbt_lookup_eq(cur, &old, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
error = xfs_bmbt_update(cur, &PREV);
|
error = xfs_bmbt_update(cur, &PREV);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
error = xfs_bmbt_lookup_eq(cur, new, &i);
|
error = xfs_bmbt_lookup_eq(cur, new, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 0, done);
|
if (XFS_IS_CORRUPT(mp, i != 0)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
if ((error = xfs_btree_insert(cur, &i)))
|
if ((error = xfs_btree_insert(cur, &i)))
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -2397,7 +2504,10 @@ xfs_bmap_add_extent_unwritten_real(
|
||||||
error = xfs_bmbt_lookup_eq(cur, &old, &i);
|
error = xfs_bmbt_lookup_eq(cur, &old, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
/* new right extent - oldext */
|
/* new right extent - oldext */
|
||||||
error = xfs_bmbt_update(cur, &r[1]);
|
error = xfs_bmbt_update(cur, &r[1]);
|
||||||
if (error)
|
if (error)
|
||||||
|
@ -2406,7 +2516,10 @@ xfs_bmap_add_extent_unwritten_real(
|
||||||
cur->bc_rec.b = PREV;
|
cur->bc_rec.b = PREV;
|
||||||
if ((error = xfs_btree_insert(cur, &i)))
|
if ((error = xfs_btree_insert(cur, &i)))
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* Reset the cursor to the position of the new extent
|
* Reset the cursor to the position of the new extent
|
||||||
* we are about to insert as we can't trust it after
|
* we are about to insert as we can't trust it after
|
||||||
|
@ -2415,11 +2528,17 @@ xfs_bmap_add_extent_unwritten_real(
|
||||||
error = xfs_bmbt_lookup_eq(cur, new, &i);
|
error = xfs_bmbt_lookup_eq(cur, new, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 0, done);
|
if (XFS_IS_CORRUPT(mp, i != 0)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
/* new middle extent - newext */
|
/* new middle extent - newext */
|
||||||
if ((error = xfs_btree_insert(cur, &i)))
|
if ((error = xfs_btree_insert(cur, &i)))
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -2702,15 +2821,24 @@ xfs_bmap_add_extent_hole_real(
|
||||||
error = xfs_bmbt_lookup_eq(cur, &right, &i);
|
error = xfs_bmbt_lookup_eq(cur, &right, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
error = xfs_btree_delete(cur, &i);
|
error = xfs_btree_delete(cur, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
error = xfs_btree_decrement(cur, 0, &i);
|
error = xfs_btree_decrement(cur, 0, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
error = xfs_bmbt_update(cur, &left);
|
error = xfs_bmbt_update(cur, &left);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
|
@ -2736,7 +2864,10 @@ xfs_bmap_add_extent_hole_real(
|
||||||
error = xfs_bmbt_lookup_eq(cur, &old, &i);
|
error = xfs_bmbt_lookup_eq(cur, &old, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
error = xfs_bmbt_update(cur, &left);
|
error = xfs_bmbt_update(cur, &left);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
|
@ -2763,7 +2894,10 @@ xfs_bmap_add_extent_hole_real(
|
||||||
error = xfs_bmbt_lookup_eq(cur, &old, &i);
|
error = xfs_bmbt_lookup_eq(cur, &old, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
error = xfs_bmbt_update(cur, &right);
|
error = xfs_bmbt_update(cur, &right);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
|
@ -2786,11 +2920,17 @@ xfs_bmap_add_extent_hole_real(
|
||||||
error = xfs_bmbt_lookup_eq(cur, new, &i);
|
error = xfs_bmbt_lookup_eq(cur, new, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 0, done);
|
if (XFS_IS_CORRUPT(mp, i != 0)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
error = xfs_btree_insert(cur, &i);
|
error = xfs_btree_insert(cur, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -4980,7 +5120,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)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (got.br_startoff == del->br_startoff)
|
if (got.br_startoff == del->br_startoff)
|
||||||
|
@ -5004,7 +5147,10 @@ xfs_bmap_del_extent_real(
|
||||||
}
|
}
|
||||||
if ((error = xfs_btree_delete(cur, &i)))
|
if ((error = xfs_btree_delete(cur, &i)))
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case BMAP_LEFT_FILLING:
|
case BMAP_LEFT_FILLING:
|
||||||
/*
|
/*
|
||||||
|
@ -5075,7 +5221,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)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* Update the btree record back
|
* Update the btree record back
|
||||||
* to the original value.
|
* to the original value.
|
||||||
|
@ -5092,7 +5241,10 @@ xfs_bmap_del_extent_real(
|
||||||
error = -ENOSPC;
|
error = -ENOSPC;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
} else
|
} else
|
||||||
flags |= xfs_ilog_fext(whichfork);
|
flags |= xfs_ilog_fext(whichfork);
|
||||||
XFS_IFORK_NEXT_SET(ip, whichfork,
|
XFS_IFORK_NEXT_SET(ip, whichfork,
|
||||||
|
@ -5575,18 +5727,21 @@ 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;
|
||||||
XFS_WANT_CORRUPTED_RETURN(mp, i == 1);
|
if (XFS_IS_CORRUPT(mp, i != 1))
|
||||||
|
return -EFSCORRUPTED;
|
||||||
|
|
||||||
error = xfs_btree_delete(cur, &i);
|
error = xfs_btree_delete(cur, &i);
|
||||||
if (error)
|
if (error)
|
||||||
return error;
|
return error;
|
||||||
XFS_WANT_CORRUPTED_RETURN(mp, i == 1);
|
if (XFS_IS_CORRUPT(mp, i != 1))
|
||||||
|
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;
|
||||||
XFS_WANT_CORRUPTED_RETURN(mp, i == 1);
|
if (XFS_IS_CORRUPT(mp, i != 1))
|
||||||
|
return -EFSCORRUPTED;
|
||||||
|
|
||||||
error = xfs_bmbt_update(cur, &new);
|
error = xfs_bmbt_update(cur, &new);
|
||||||
if (error)
|
if (error)
|
||||||
|
@ -5634,7 +5789,8 @@ 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;
|
||||||
XFS_WANT_CORRUPTED_RETURN(mp, i == 1);
|
if (XFS_IS_CORRUPT(mp, i != 1))
|
||||||
|
return -EFSCORRUPTED;
|
||||||
|
|
||||||
error = xfs_bmbt_update(cur, got);
|
error = xfs_bmbt_update(cur, got);
|
||||||
if (error)
|
if (error)
|
||||||
|
@ -5697,8 +5853,10 @@ xfs_bmap_collapse_extents(
|
||||||
*done = true;
|
*done = true;
|
||||||
goto del_cursor;
|
goto del_cursor;
|
||||||
}
|
}
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, !isnullstartblock(got.br_startblock),
|
if (XFS_IS_CORRUPT(mp, isnullstartblock(got.br_startblock))) {
|
||||||
del_cursor);
|
error = -EFSCORRUPTED;
|
||||||
|
goto del_cursor;
|
||||||
|
}
|
||||||
|
|
||||||
new_startoff = got.br_startoff - offset_shift_fsb;
|
new_startoff = got.br_startoff - offset_shift_fsb;
|
||||||
if (xfs_iext_peek_prev_extent(ifp, &icur, &prev)) {
|
if (xfs_iext_peek_prev_extent(ifp, &icur, &prev)) {
|
||||||
|
@ -5823,8 +5981,10 @@ xfs_bmap_insert_extents(
|
||||||
goto del_cursor;
|
goto del_cursor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, !isnullstartblock(got.br_startblock),
|
if (XFS_IS_CORRUPT(mp, isnullstartblock(got.br_startblock))) {
|
||||||
del_cursor);
|
error = -EFSCORRUPTED;
|
||||||
|
goto del_cursor;
|
||||||
|
}
|
||||||
|
|
||||||
if (stop_fsb >= got.br_startoff + got.br_blockcount) {
|
if (stop_fsb >= got.br_startoff + got.br_blockcount) {
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
|
@ -5931,7 +6091,10 @@ xfs_bmap_split_extent_at(
|
||||||
error = xfs_bmbt_lookup_eq(cur, &got, &i);
|
error = xfs_bmbt_lookup_eq(cur, &got, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto del_cursor;
|
goto del_cursor;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, del_cursor);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto del_cursor;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
got.br_blockcount = gotblkcnt;
|
got.br_blockcount = gotblkcnt;
|
||||||
|
@ -5956,11 +6119,17 @@ xfs_bmap_split_extent_at(
|
||||||
error = xfs_bmbt_lookup_eq(cur, &new, &i);
|
error = xfs_bmbt_lookup_eq(cur, &new, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto del_cursor;
|
goto del_cursor;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 0, del_cursor);
|
if (XFS_IS_CORRUPT(mp, i != 0)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto del_cursor;
|
||||||
|
}
|
||||||
error = xfs_btree_insert(cur, &i);
|
error = xfs_btree_insert(cur, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto del_cursor;
|
goto del_cursor;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, del_cursor);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto del_cursor;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -1971,7 +1971,8 @@ 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;
|
||||||
XFS_WANT_CORRUPTED_RETURN(cur->bc_mp, i == 1);
|
if (XFS_IS_CORRUPT(cur->bc_mp, i != 1))
|
||||||
|
return -EFSCORRUPTED;
|
||||||
*stat = 1;
|
*stat = 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -2426,7 +2427,10 @@ xfs_btree_lshift(
|
||||||
if (error)
|
if (error)
|
||||||
goto error0;
|
goto error0;
|
||||||
i = xfs_btree_firstrec(tcur, level);
|
i = xfs_btree_firstrec(tcur, level);
|
||||||
XFS_WANT_CORRUPTED_GOTO(tcur->bc_mp, i == 1, error0);
|
if (XFS_IS_CORRUPT(tcur->bc_mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto error0;
|
||||||
|
}
|
||||||
|
|
||||||
error = xfs_btree_decrement(tcur, level, &i);
|
error = xfs_btree_decrement(tcur, level, &i);
|
||||||
if (error)
|
if (error)
|
||||||
|
@ -2593,7 +2597,10 @@ xfs_btree_rshift(
|
||||||
if (error)
|
if (error)
|
||||||
goto error0;
|
goto error0;
|
||||||
i = xfs_btree_lastrec(tcur, level);
|
i = xfs_btree_lastrec(tcur, level);
|
||||||
XFS_WANT_CORRUPTED_GOTO(tcur->bc_mp, i == 1, error0);
|
if (XFS_IS_CORRUPT(tcur->bc_mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto error0;
|
||||||
|
}
|
||||||
|
|
||||||
error = xfs_btree_increment(tcur, level, &i);
|
error = xfs_btree_increment(tcur, level, &i);
|
||||||
if (error)
|
if (error)
|
||||||
|
@ -3447,7 +3454,10 @@ xfs_btree_insert(
|
||||||
goto error0;
|
goto error0;
|
||||||
}
|
}
|
||||||
|
|
||||||
XFS_WANT_CORRUPTED_GOTO(cur->bc_mp, i == 1, error0);
|
if (XFS_IS_CORRUPT(cur->bc_mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto error0;
|
||||||
|
}
|
||||||
level++;
|
level++;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -3851,15 +3861,24 @@ xfs_btree_delrec(
|
||||||
* Actually any entry but the first would suffice.
|
* Actually any entry but the first would suffice.
|
||||||
*/
|
*/
|
||||||
i = xfs_btree_lastrec(tcur, level);
|
i = xfs_btree_lastrec(tcur, level);
|
||||||
XFS_WANT_CORRUPTED_GOTO(cur->bc_mp, i == 1, error0);
|
if (XFS_IS_CORRUPT(cur->bc_mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto error0;
|
||||||
|
}
|
||||||
|
|
||||||
error = xfs_btree_increment(tcur, level, &i);
|
error = xfs_btree_increment(tcur, level, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto error0;
|
goto error0;
|
||||||
XFS_WANT_CORRUPTED_GOTO(cur->bc_mp, i == 1, error0);
|
if (XFS_IS_CORRUPT(cur->bc_mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto error0;
|
||||||
|
}
|
||||||
|
|
||||||
i = xfs_btree_lastrec(tcur, level);
|
i = xfs_btree_lastrec(tcur, level);
|
||||||
XFS_WANT_CORRUPTED_GOTO(cur->bc_mp, i == 1, error0);
|
if (XFS_IS_CORRUPT(cur->bc_mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto error0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Grab a pointer to the block. */
|
/* Grab a pointer to the block. */
|
||||||
right = xfs_btree_get_block(tcur, level, &rbp);
|
right = xfs_btree_get_block(tcur, level, &rbp);
|
||||||
|
@ -3903,12 +3922,18 @@ xfs_btree_delrec(
|
||||||
rrecs = xfs_btree_get_numrecs(right);
|
rrecs = xfs_btree_get_numrecs(right);
|
||||||
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);
|
||||||
XFS_WANT_CORRUPTED_GOTO(cur->bc_mp, i == 1, error0);
|
if (XFS_IS_CORRUPT(cur->bc_mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto error0;
|
||||||
|
}
|
||||||
|
|
||||||
error = xfs_btree_decrement(tcur, level, &i);
|
error = xfs_btree_decrement(tcur, level, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto error0;
|
goto error0;
|
||||||
XFS_WANT_CORRUPTED_GOTO(cur->bc_mp, i == 1, error0);
|
if (XFS_IS_CORRUPT(cur->bc_mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto error0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3922,13 +3947,19 @@ xfs_btree_delrec(
|
||||||
* previous block.
|
* previous block.
|
||||||
*/
|
*/
|
||||||
i = xfs_btree_firstrec(tcur, level);
|
i = xfs_btree_firstrec(tcur, level);
|
||||||
XFS_WANT_CORRUPTED_GOTO(cur->bc_mp, i == 1, error0);
|
if (XFS_IS_CORRUPT(cur->bc_mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto error0;
|
||||||
|
}
|
||||||
|
|
||||||
error = xfs_btree_decrement(tcur, level, &i);
|
error = xfs_btree_decrement(tcur, level, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto error0;
|
goto error0;
|
||||||
i = xfs_btree_firstrec(tcur, level);
|
i = xfs_btree_firstrec(tcur, level);
|
||||||
XFS_WANT_CORRUPTED_GOTO(cur->bc_mp, i == 1, error0);
|
if (XFS_IS_CORRUPT(cur->bc_mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto error0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Grab a pointer to the block. */
|
/* Grab a pointer to the block. */
|
||||||
left = xfs_btree_get_block(tcur, level, &lbp);
|
left = xfs_btree_get_block(tcur, level, &lbp);
|
||||||
|
|
|
@ -544,7 +544,10 @@ xfs_inobt_insert_sprec(
|
||||||
nrec->ir_free, &i);
|
nrec->ir_free, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto error;
|
goto error;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, error);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
@ -557,17 +560,23 @@ xfs_inobt_insert_sprec(
|
||||||
error = xfs_inobt_get_rec(cur, &rec, &i);
|
error = xfs_inobt_get_rec(cur, &rec, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto error;
|
goto error;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, error);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp,
|
error = -EFSCORRUPTED;
|
||||||
rec.ir_startino == nrec->ir_startino,
|
goto error;
|
||||||
error);
|
}
|
||||||
|
if (XFS_IS_CORRUPT(mp, rec.ir_startino != nrec->ir_startino)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This should never fail. If we have coexisting records that
|
* This should never fail. If we have coexisting records that
|
||||||
* cannot merge, something is seriously wrong.
|
* cannot merge, something is seriously wrong.
|
||||||
*/
|
*/
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, __xfs_inobt_can_merge(nrec, &rec),
|
if (XFS_IS_CORRUPT(mp, !__xfs_inobt_can_merge(nrec, &rec))) {
|
||||||
error);
|
error = -EFSCORRUPTED;
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
trace_xfs_irec_merge_pre(mp, agno, rec.ir_startino,
|
trace_xfs_irec_merge_pre(mp, agno, rec.ir_startino,
|
||||||
rec.ir_holemask, nrec->ir_startino,
|
rec.ir_holemask, nrec->ir_startino,
|
||||||
|
@ -1057,7 +1066,8 @@ 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;
|
||||||
XFS_WANT_CORRUPTED_RETURN(cur->bc_mp, i == 1);
|
if (XFS_IS_CORRUPT(cur->bc_mp, i != 1))
|
||||||
|
return -EFSCORRUPTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1081,7 +1091,8 @@ 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;
|
||||||
XFS_WANT_CORRUPTED_RETURN(cur->bc_mp, i == 1);
|
if (XFS_IS_CORRUPT(cur->bc_mp, i != 1))
|
||||||
|
return -EFSCORRUPTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1161,12 +1172,18 @@ xfs_dialloc_ag_inobt(
|
||||||
error = xfs_inobt_lookup(cur, pagino, XFS_LOOKUP_LE, &i);
|
error = xfs_inobt_lookup(cur, pagino, XFS_LOOKUP_LE, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto error0;
|
goto error0;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, error0);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto error0;
|
||||||
|
}
|
||||||
|
|
||||||
error = xfs_inobt_get_rec(cur, &rec, &j);
|
error = xfs_inobt_get_rec(cur, &rec, &j);
|
||||||
if (error)
|
if (error)
|
||||||
goto error0;
|
goto error0;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, j == 1, error0);
|
if (XFS_IS_CORRUPT(mp, j != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto error0;
|
||||||
|
}
|
||||||
|
|
||||||
if (rec.ir_freecount > 0) {
|
if (rec.ir_freecount > 0) {
|
||||||
/*
|
/*
|
||||||
|
@ -1321,19 +1338,28 @@ xfs_dialloc_ag_inobt(
|
||||||
error = xfs_inobt_lookup(cur, 0, XFS_LOOKUP_GE, &i);
|
error = xfs_inobt_lookup(cur, 0, XFS_LOOKUP_GE, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto error0;
|
goto error0;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, error0);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto error0;
|
||||||
|
}
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
error = xfs_inobt_get_rec(cur, &rec, &i);
|
error = xfs_inobt_get_rec(cur, &rec, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto error0;
|
goto error0;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, error0);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto error0;
|
||||||
|
}
|
||||||
if (rec.ir_freecount > 0)
|
if (rec.ir_freecount > 0)
|
||||||
break;
|
break;
|
||||||
error = xfs_btree_increment(cur, 0, &i);
|
error = xfs_btree_increment(cur, 0, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto error0;
|
goto error0;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, error0);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto error0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
alloc_inode:
|
alloc_inode:
|
||||||
|
@ -1393,7 +1419,8 @@ 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;
|
||||||
XFS_WANT_CORRUPTED_RETURN(lcur->bc_mp, i == 1);
|
if (XFS_IS_CORRUPT(lcur->bc_mp, i != 1))
|
||||||
|
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
|
||||||
|
@ -1416,10 +1443,16 @@ xfs_dialloc_ag_finobt_near(
|
||||||
error = xfs_inobt_get_rec(rcur, &rrec, &j);
|
error = xfs_inobt_get_rec(rcur, &rrec, &j);
|
||||||
if (error)
|
if (error)
|
||||||
goto error_rcur;
|
goto error_rcur;
|
||||||
XFS_WANT_CORRUPTED_GOTO(lcur->bc_mp, j == 1, error_rcur);
|
if (XFS_IS_CORRUPT(lcur->bc_mp, j != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto error_rcur;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
XFS_WANT_CORRUPTED_GOTO(lcur->bc_mp, i == 1 || j == 1, error_rcur);
|
if (XFS_IS_CORRUPT(lcur->bc_mp, i != 1 && j != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto error_rcur;
|
||||||
|
}
|
||||||
if (i == 1 && j == 1) {
|
if (i == 1 && j == 1) {
|
||||||
/*
|
/*
|
||||||
* Both the left and right records are valid. Choose the closer
|
* Both the left and right records are valid. Choose the closer
|
||||||
|
@ -1472,7 +1505,8 @@ 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;
|
||||||
XFS_WANT_CORRUPTED_RETURN(cur->bc_mp, i == 1);
|
if (XFS_IS_CORRUPT(cur->bc_mp, i != 1))
|
||||||
|
return -EFSCORRUPTED;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1483,12 +1517,14 @@ 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;
|
||||||
XFS_WANT_CORRUPTED_RETURN(cur->bc_mp, i == 1);
|
if (XFS_IS_CORRUPT(cur->bc_mp, i != 1))
|
||||||
|
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;
|
||||||
XFS_WANT_CORRUPTED_RETURN(cur->bc_mp, i == 1);
|
if (XFS_IS_CORRUPT(cur->bc_mp, i != 1))
|
||||||
|
return -EFSCORRUPTED;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1510,20 +1546,24 @@ 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;
|
||||||
XFS_WANT_CORRUPTED_RETURN(cur->bc_mp, i == 1);
|
if (XFS_IS_CORRUPT(cur->bc_mp, i != 1))
|
||||||
|
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;
|
||||||
XFS_WANT_CORRUPTED_RETURN(cur->bc_mp, i == 1);
|
if (XFS_IS_CORRUPT(cur->bc_mp, i != 1))
|
||||||
|
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);
|
||||||
|
|
||||||
rec.ir_free &= ~XFS_INOBT_MASK(offset);
|
rec.ir_free &= ~XFS_INOBT_MASK(offset);
|
||||||
rec.ir_freecount--;
|
rec.ir_freecount--;
|
||||||
|
|
||||||
XFS_WANT_CORRUPTED_RETURN(cur->bc_mp, (rec.ir_free == frec->ir_free) &&
|
if (XFS_IS_CORRUPT(cur->bc_mp,
|
||||||
(rec.ir_freecount == frec->ir_freecount));
|
rec.ir_free != frec->ir_free ||
|
||||||
|
rec.ir_freecount != frec->ir_freecount))
|
||||||
|
return -EFSCORRUPTED;
|
||||||
|
|
||||||
return xfs_inobt_update(cur, &rec);
|
return xfs_inobt_update(cur, &rec);
|
||||||
}
|
}
|
||||||
|
@ -1933,14 +1973,20 @@ xfs_difree_inobt(
|
||||||
__func__, error);
|
__func__, error);
|
||||||
goto error0;
|
goto error0;
|
||||||
}
|
}
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, error0);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto error0;
|
||||||
|
}
|
||||||
error = xfs_inobt_get_rec(cur, &rec, &i);
|
error = xfs_inobt_get_rec(cur, &rec, &i);
|
||||||
if (error) {
|
if (error) {
|
||||||
xfs_warn(mp, "%s: xfs_inobt_get_rec() returned error %d.",
|
xfs_warn(mp, "%s: xfs_inobt_get_rec() returned error %d.",
|
||||||
__func__, error);
|
__func__, error);
|
||||||
goto error0;
|
goto error0;
|
||||||
}
|
}
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, error0);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto error0;
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* Get the offset in the inode chunk.
|
* Get the offset in the inode chunk.
|
||||||
*/
|
*/
|
||||||
|
@ -2052,7 +2098,10 @@ xfs_difree_finobt(
|
||||||
* freed an inode in a previously fully allocated chunk. If not,
|
* freed an inode in a previously fully allocated chunk. If not,
|
||||||
* something is out of sync.
|
* something is out of sync.
|
||||||
*/
|
*/
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, ibtrec->ir_freecount == 1, error);
|
if (XFS_IS_CORRUPT(mp, ibtrec->ir_freecount != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
error = xfs_inobt_insert_rec(cur, ibtrec->ir_holemask,
|
error = xfs_inobt_insert_rec(cur, ibtrec->ir_holemask,
|
||||||
ibtrec->ir_count,
|
ibtrec->ir_count,
|
||||||
|
@ -2075,14 +2124,20 @@ xfs_difree_finobt(
|
||||||
error = xfs_inobt_get_rec(cur, &rec, &i);
|
error = xfs_inobt_get_rec(cur, &rec, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto error;
|
goto error;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, error);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
rec.ir_free |= XFS_INOBT_MASK(offset);
|
rec.ir_free |= XFS_INOBT_MASK(offset);
|
||||||
rec.ir_freecount++;
|
rec.ir_freecount++;
|
||||||
|
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, (rec.ir_free == ibtrec->ir_free) &&
|
if (XFS_IS_CORRUPT(mp,
|
||||||
(rec.ir_freecount == ibtrec->ir_freecount),
|
rec.ir_free != ibtrec->ir_free ||
|
||||||
error);
|
rec.ir_freecount != ibtrec->ir_freecount)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The content of inobt records should always match between the inobt
|
* The content of inobt records should always match between the inobt
|
||||||
|
|
|
@ -200,7 +200,10 @@ xfs_refcount_insert(
|
||||||
error = xfs_btree_insert(cur, i);
|
error = xfs_btree_insert(cur, i);
|
||||||
if (error)
|
if (error)
|
||||||
goto out_error;
|
goto out_error;
|
||||||
XFS_WANT_CORRUPTED_GOTO(cur->bc_mp, *i == 1, out_error);
|
if (XFS_IS_CORRUPT(cur->bc_mp, *i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto out_error;
|
||||||
|
}
|
||||||
|
|
||||||
out_error:
|
out_error:
|
||||||
if (error)
|
if (error)
|
||||||
|
@ -227,10 +230,16 @@ xfs_refcount_delete(
|
||||||
error = xfs_refcount_get_rec(cur, &irec, &found_rec);
|
error = xfs_refcount_get_rec(cur, &irec, &found_rec);
|
||||||
if (error)
|
if (error)
|
||||||
goto out_error;
|
goto out_error;
|
||||||
XFS_WANT_CORRUPTED_GOTO(cur->bc_mp, found_rec == 1, out_error);
|
if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto out_error;
|
||||||
|
}
|
||||||
trace_xfs_refcount_delete(cur->bc_mp, cur->bc_private.a.agno, &irec);
|
trace_xfs_refcount_delete(cur->bc_mp, cur->bc_private.a.agno, &irec);
|
||||||
error = xfs_btree_delete(cur, i);
|
error = xfs_btree_delete(cur, i);
|
||||||
XFS_WANT_CORRUPTED_GOTO(cur->bc_mp, *i == 1, out_error);
|
if (XFS_IS_CORRUPT(cur->bc_mp, *i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto out_error;
|
||||||
|
}
|
||||||
if (error)
|
if (error)
|
||||||
goto out_error;
|
goto out_error;
|
||||||
error = xfs_refcount_lookup_ge(cur, irec.rc_startblock, &found_rec);
|
error = xfs_refcount_lookup_ge(cur, irec.rc_startblock, &found_rec);
|
||||||
|
@ -349,7 +358,10 @@ xfs_refcount_split_extent(
|
||||||
error = xfs_refcount_get_rec(cur, &rcext, &found_rec);
|
error = xfs_refcount_get_rec(cur, &rcext, &found_rec);
|
||||||
if (error)
|
if (error)
|
||||||
goto out_error;
|
goto out_error;
|
||||||
XFS_WANT_CORRUPTED_GOTO(cur->bc_mp, found_rec == 1, out_error);
|
if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto out_error;
|
||||||
|
}
|
||||||
if (rcext.rc_startblock == agbno || xfs_refc_next(&rcext) <= agbno)
|
if (rcext.rc_startblock == agbno || xfs_refc_next(&rcext) <= agbno)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -371,7 +383,10 @@ xfs_refcount_split_extent(
|
||||||
error = xfs_refcount_insert(cur, &tmp, &found_rec);
|
error = xfs_refcount_insert(cur, &tmp, &found_rec);
|
||||||
if (error)
|
if (error)
|
||||||
goto out_error;
|
goto out_error;
|
||||||
XFS_WANT_CORRUPTED_GOTO(cur->bc_mp, found_rec == 1, out_error);
|
if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto out_error;
|
||||||
|
}
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
out_error:
|
out_error:
|
||||||
|
@ -410,19 +425,27 @@ xfs_refcount_merge_center_extents(
|
||||||
&found_rec);
|
&found_rec);
|
||||||
if (error)
|
if (error)
|
||||||
goto out_error;
|
goto out_error;
|
||||||
XFS_WANT_CORRUPTED_GOTO(cur->bc_mp, found_rec == 1, out_error);
|
if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto out_error;
|
||||||
|
}
|
||||||
|
|
||||||
error = xfs_refcount_delete(cur, &found_rec);
|
error = xfs_refcount_delete(cur, &found_rec);
|
||||||
if (error)
|
if (error)
|
||||||
goto out_error;
|
goto out_error;
|
||||||
XFS_WANT_CORRUPTED_GOTO(cur->bc_mp, found_rec == 1, out_error);
|
if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto out_error;
|
||||||
|
}
|
||||||
|
|
||||||
if (center->rc_refcount > 1) {
|
if (center->rc_refcount > 1) {
|
||||||
error = xfs_refcount_delete(cur, &found_rec);
|
error = xfs_refcount_delete(cur, &found_rec);
|
||||||
if (error)
|
if (error)
|
||||||
goto out_error;
|
goto out_error;
|
||||||
XFS_WANT_CORRUPTED_GOTO(cur->bc_mp, found_rec == 1,
|
if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) {
|
||||||
out_error);
|
error = -EFSCORRUPTED;
|
||||||
|
goto out_error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Enlarge the left extent. */
|
/* Enlarge the left extent. */
|
||||||
|
@ -430,7 +453,10 @@ xfs_refcount_merge_center_extents(
|
||||||
&found_rec);
|
&found_rec);
|
||||||
if (error)
|
if (error)
|
||||||
goto out_error;
|
goto out_error;
|
||||||
XFS_WANT_CORRUPTED_GOTO(cur->bc_mp, found_rec == 1, out_error);
|
if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto out_error;
|
||||||
|
}
|
||||||
|
|
||||||
left->rc_blockcount = extlen;
|
left->rc_blockcount = extlen;
|
||||||
error = xfs_refcount_update(cur, left);
|
error = xfs_refcount_update(cur, left);
|
||||||
|
@ -469,14 +495,18 @@ xfs_refcount_merge_left_extent(
|
||||||
&found_rec);
|
&found_rec);
|
||||||
if (error)
|
if (error)
|
||||||
goto out_error;
|
goto out_error;
|
||||||
XFS_WANT_CORRUPTED_GOTO(cur->bc_mp, found_rec == 1,
|
if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) {
|
||||||
out_error);
|
error = -EFSCORRUPTED;
|
||||||
|
goto out_error;
|
||||||
|
}
|
||||||
|
|
||||||
error = xfs_refcount_delete(cur, &found_rec);
|
error = xfs_refcount_delete(cur, &found_rec);
|
||||||
if (error)
|
if (error)
|
||||||
goto out_error;
|
goto out_error;
|
||||||
XFS_WANT_CORRUPTED_GOTO(cur->bc_mp, found_rec == 1,
|
if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) {
|
||||||
out_error);
|
error = -EFSCORRUPTED;
|
||||||
|
goto out_error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Enlarge the left extent. */
|
/* Enlarge the left extent. */
|
||||||
|
@ -484,7 +514,10 @@ xfs_refcount_merge_left_extent(
|
||||||
&found_rec);
|
&found_rec);
|
||||||
if (error)
|
if (error)
|
||||||
goto out_error;
|
goto out_error;
|
||||||
XFS_WANT_CORRUPTED_GOTO(cur->bc_mp, found_rec == 1, out_error);
|
if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto out_error;
|
||||||
|
}
|
||||||
|
|
||||||
left->rc_blockcount += cleft->rc_blockcount;
|
left->rc_blockcount += cleft->rc_blockcount;
|
||||||
error = xfs_refcount_update(cur, left);
|
error = xfs_refcount_update(cur, left);
|
||||||
|
@ -526,14 +559,18 @@ xfs_refcount_merge_right_extent(
|
||||||
&found_rec);
|
&found_rec);
|
||||||
if (error)
|
if (error)
|
||||||
goto out_error;
|
goto out_error;
|
||||||
XFS_WANT_CORRUPTED_GOTO(cur->bc_mp, found_rec == 1,
|
if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) {
|
||||||
out_error);
|
error = -EFSCORRUPTED;
|
||||||
|
goto out_error;
|
||||||
|
}
|
||||||
|
|
||||||
error = xfs_refcount_delete(cur, &found_rec);
|
error = xfs_refcount_delete(cur, &found_rec);
|
||||||
if (error)
|
if (error)
|
||||||
goto out_error;
|
goto out_error;
|
||||||
XFS_WANT_CORRUPTED_GOTO(cur->bc_mp, found_rec == 1,
|
if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) {
|
||||||
out_error);
|
error = -EFSCORRUPTED;
|
||||||
|
goto out_error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Enlarge the right extent. */
|
/* Enlarge the right extent. */
|
||||||
|
@ -541,7 +578,10 @@ xfs_refcount_merge_right_extent(
|
||||||
&found_rec);
|
&found_rec);
|
||||||
if (error)
|
if (error)
|
||||||
goto out_error;
|
goto out_error;
|
||||||
XFS_WANT_CORRUPTED_GOTO(cur->bc_mp, found_rec == 1, out_error);
|
if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto out_error;
|
||||||
|
}
|
||||||
|
|
||||||
right->rc_startblock -= cright->rc_blockcount;
|
right->rc_startblock -= cright->rc_blockcount;
|
||||||
right->rc_blockcount += cright->rc_blockcount;
|
right->rc_blockcount += cright->rc_blockcount;
|
||||||
|
@ -587,7 +627,10 @@ xfs_refcount_find_left_extents(
|
||||||
error = xfs_refcount_get_rec(cur, &tmp, &found_rec);
|
error = xfs_refcount_get_rec(cur, &tmp, &found_rec);
|
||||||
if (error)
|
if (error)
|
||||||
goto out_error;
|
goto out_error;
|
||||||
XFS_WANT_CORRUPTED_GOTO(cur->bc_mp, found_rec == 1, out_error);
|
if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto out_error;
|
||||||
|
}
|
||||||
|
|
||||||
if (xfs_refc_next(&tmp) != agbno)
|
if (xfs_refc_next(&tmp) != agbno)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -605,8 +648,10 @@ xfs_refcount_find_left_extents(
|
||||||
error = xfs_refcount_get_rec(cur, &tmp, &found_rec);
|
error = xfs_refcount_get_rec(cur, &tmp, &found_rec);
|
||||||
if (error)
|
if (error)
|
||||||
goto out_error;
|
goto out_error;
|
||||||
XFS_WANT_CORRUPTED_GOTO(cur->bc_mp, found_rec == 1,
|
if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) {
|
||||||
out_error);
|
error = -EFSCORRUPTED;
|
||||||
|
goto out_error;
|
||||||
|
}
|
||||||
|
|
||||||
/* if tmp starts at the end of our range, just use that */
|
/* if tmp starts at the end of our range, just use that */
|
||||||
if (tmp.rc_startblock == agbno)
|
if (tmp.rc_startblock == agbno)
|
||||||
|
@ -671,7 +716,10 @@ xfs_refcount_find_right_extents(
|
||||||
error = xfs_refcount_get_rec(cur, &tmp, &found_rec);
|
error = xfs_refcount_get_rec(cur, &tmp, &found_rec);
|
||||||
if (error)
|
if (error)
|
||||||
goto out_error;
|
goto out_error;
|
||||||
XFS_WANT_CORRUPTED_GOTO(cur->bc_mp, found_rec == 1, out_error);
|
if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto out_error;
|
||||||
|
}
|
||||||
|
|
||||||
if (tmp.rc_startblock != agbno + aglen)
|
if (tmp.rc_startblock != agbno + aglen)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -689,8 +737,10 @@ xfs_refcount_find_right_extents(
|
||||||
error = xfs_refcount_get_rec(cur, &tmp, &found_rec);
|
error = xfs_refcount_get_rec(cur, &tmp, &found_rec);
|
||||||
if (error)
|
if (error)
|
||||||
goto out_error;
|
goto out_error;
|
||||||
XFS_WANT_CORRUPTED_GOTO(cur->bc_mp, found_rec == 1,
|
if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) {
|
||||||
out_error);
|
error = -EFSCORRUPTED;
|
||||||
|
goto out_error;
|
||||||
|
}
|
||||||
|
|
||||||
/* if tmp ends at the end of our range, just use that */
|
/* if tmp ends at the end of our range, just use that */
|
||||||
if (xfs_refc_next(&tmp) == agbno + aglen)
|
if (xfs_refc_next(&tmp) == agbno + aglen)
|
||||||
|
@ -913,8 +963,11 @@ xfs_refcount_adjust_extents(
|
||||||
&found_tmp);
|
&found_tmp);
|
||||||
if (error)
|
if (error)
|
||||||
goto out_error;
|
goto out_error;
|
||||||
XFS_WANT_CORRUPTED_GOTO(cur->bc_mp,
|
if (XFS_IS_CORRUPT(cur->bc_mp,
|
||||||
found_tmp == 1, out_error);
|
found_tmp != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto out_error;
|
||||||
|
}
|
||||||
cur->bc_private.a.priv.refc.nr_ops++;
|
cur->bc_private.a.priv.refc.nr_ops++;
|
||||||
} else {
|
} else {
|
||||||
fsbno = XFS_AGB_TO_FSB(cur->bc_mp,
|
fsbno = XFS_AGB_TO_FSB(cur->bc_mp,
|
||||||
|
@ -955,8 +1008,10 @@ xfs_refcount_adjust_extents(
|
||||||
error = xfs_refcount_delete(cur, &found_rec);
|
error = xfs_refcount_delete(cur, &found_rec);
|
||||||
if (error)
|
if (error)
|
||||||
goto out_error;
|
goto out_error;
|
||||||
XFS_WANT_CORRUPTED_GOTO(cur->bc_mp,
|
if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) {
|
||||||
found_rec == 1, out_error);
|
error = -EFSCORRUPTED;
|
||||||
|
goto out_error;
|
||||||
|
}
|
||||||
cur->bc_private.a.priv.refc.nr_ops++;
|
cur->bc_private.a.priv.refc.nr_ops++;
|
||||||
goto advloop;
|
goto advloop;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1272,7 +1327,10 @@ xfs_refcount_find_shared(
|
||||||
error = xfs_refcount_get_rec(cur, &tmp, &i);
|
error = xfs_refcount_get_rec(cur, &tmp, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto out_error;
|
goto out_error;
|
||||||
XFS_WANT_CORRUPTED_GOTO(cur->bc_mp, i == 1, out_error);
|
if (XFS_IS_CORRUPT(cur->bc_mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto out_error;
|
||||||
|
}
|
||||||
|
|
||||||
/* If the extent ends before the start, look at the next one */
|
/* If the extent ends before the start, look at the next one */
|
||||||
if (tmp.rc_startblock + tmp.rc_blockcount <= agbno) {
|
if (tmp.rc_startblock + tmp.rc_blockcount <= agbno) {
|
||||||
|
@ -1284,7 +1342,10 @@ xfs_refcount_find_shared(
|
||||||
error = xfs_refcount_get_rec(cur, &tmp, &i);
|
error = xfs_refcount_get_rec(cur, &tmp, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto out_error;
|
goto out_error;
|
||||||
XFS_WANT_CORRUPTED_GOTO(cur->bc_mp, i == 1, out_error);
|
if (XFS_IS_CORRUPT(cur->bc_mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto out_error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If the extent starts after the range we want, bail out */
|
/* If the extent starts after the range we want, bail out */
|
||||||
|
@ -1312,7 +1373,10 @@ xfs_refcount_find_shared(
|
||||||
error = xfs_refcount_get_rec(cur, &tmp, &i);
|
error = xfs_refcount_get_rec(cur, &tmp, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto out_error;
|
goto out_error;
|
||||||
XFS_WANT_CORRUPTED_GOTO(cur->bc_mp, i == 1, out_error);
|
if (XFS_IS_CORRUPT(cur->bc_mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto out_error;
|
||||||
|
}
|
||||||
if (tmp.rc_startblock >= agbno + aglen ||
|
if (tmp.rc_startblock >= agbno + aglen ||
|
||||||
tmp.rc_startblock != *fbno + *flen)
|
tmp.rc_startblock != *fbno + *flen)
|
||||||
break;
|
break;
|
||||||
|
@ -1413,8 +1477,11 @@ xfs_refcount_adjust_cow_extents(
|
||||||
switch (adj) {
|
switch (adj) {
|
||||||
case XFS_REFCOUNT_ADJUST_COW_ALLOC:
|
case XFS_REFCOUNT_ADJUST_COW_ALLOC:
|
||||||
/* Adding a CoW reservation, there should be nothing here. */
|
/* Adding a CoW reservation, there should be nothing here. */
|
||||||
XFS_WANT_CORRUPTED_GOTO(cur->bc_mp,
|
if (XFS_IS_CORRUPT(cur->bc_mp,
|
||||||
ext.rc_startblock >= agbno + aglen, out_error);
|
agbno + aglen > ext.rc_startblock)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto out_error;
|
||||||
|
}
|
||||||
|
|
||||||
tmp.rc_startblock = agbno;
|
tmp.rc_startblock = agbno;
|
||||||
tmp.rc_blockcount = aglen;
|
tmp.rc_blockcount = aglen;
|
||||||
|
@ -1426,17 +1493,25 @@ xfs_refcount_adjust_cow_extents(
|
||||||
&found_tmp);
|
&found_tmp);
|
||||||
if (error)
|
if (error)
|
||||||
goto out_error;
|
goto out_error;
|
||||||
XFS_WANT_CORRUPTED_GOTO(cur->bc_mp,
|
if (XFS_IS_CORRUPT(cur->bc_mp, found_tmp != 1)) {
|
||||||
found_tmp == 1, out_error);
|
error = -EFSCORRUPTED;
|
||||||
|
goto out_error;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
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. */
|
||||||
XFS_WANT_CORRUPTED_GOTO(cur->bc_mp,
|
if (XFS_IS_CORRUPT(cur->bc_mp, ext.rc_startblock != agbno)) {
|
||||||
ext.rc_startblock == agbno, out_error);
|
error = -EFSCORRUPTED;
|
||||||
XFS_WANT_CORRUPTED_GOTO(cur->bc_mp,
|
goto out_error;
|
||||||
ext.rc_blockcount == aglen, out_error);
|
}
|
||||||
XFS_WANT_CORRUPTED_GOTO(cur->bc_mp,
|
if (XFS_IS_CORRUPT(cur->bc_mp, ext.rc_blockcount != aglen)) {
|
||||||
ext.rc_refcount == 1, out_error);
|
error = -EFSCORRUPTED;
|
||||||
|
goto out_error;
|
||||||
|
}
|
||||||
|
if (XFS_IS_CORRUPT(cur->bc_mp, ext.rc_refcount != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto out_error;
|
||||||
|
}
|
||||||
|
|
||||||
ext.rc_refcount = 0;
|
ext.rc_refcount = 0;
|
||||||
trace_xfs_refcount_modify_extent(cur->bc_mp,
|
trace_xfs_refcount_modify_extent(cur->bc_mp,
|
||||||
|
@ -1444,8 +1519,10 @@ xfs_refcount_adjust_cow_extents(
|
||||||
error = xfs_refcount_delete(cur, &found_rec);
|
error = xfs_refcount_delete(cur, &found_rec);
|
||||||
if (error)
|
if (error)
|
||||||
goto out_error;
|
goto out_error;
|
||||||
XFS_WANT_CORRUPTED_GOTO(cur->bc_mp,
|
if (XFS_IS_CORRUPT(cur->bc_mp, found_rec != 1)) {
|
||||||
found_rec == 1, out_error);
|
error = -EFSCORRUPTED;
|
||||||
|
goto out_error;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
|
|
|
@ -113,7 +113,10 @@ xfs_rmap_insert(
|
||||||
error = xfs_rmap_lookup_eq(rcur, agbno, len, owner, offset, flags, &i);
|
error = xfs_rmap_lookup_eq(rcur, agbno, len, owner, offset, flags, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(rcur->bc_mp, i == 0, done);
|
if (XFS_IS_CORRUPT(rcur->bc_mp, i != 0)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
rcur->bc_rec.r.rm_startblock = agbno;
|
rcur->bc_rec.r.rm_startblock = agbno;
|
||||||
rcur->bc_rec.r.rm_blockcount = len;
|
rcur->bc_rec.r.rm_blockcount = len;
|
||||||
|
@ -123,7 +126,10 @@ xfs_rmap_insert(
|
||||||
error = xfs_btree_insert(rcur, &i);
|
error = xfs_btree_insert(rcur, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(rcur->bc_mp, i == 1, done);
|
if (XFS_IS_CORRUPT(rcur->bc_mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
done:
|
done:
|
||||||
if (error)
|
if (error)
|
||||||
trace_xfs_rmap_insert_error(rcur->bc_mp,
|
trace_xfs_rmap_insert_error(rcur->bc_mp,
|
||||||
|
@ -149,12 +155,18 @@ xfs_rmap_delete(
|
||||||
error = xfs_rmap_lookup_eq(rcur, agbno, len, owner, offset, flags, &i);
|
error = xfs_rmap_lookup_eq(rcur, agbno, len, owner, offset, flags, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(rcur->bc_mp, i == 1, done);
|
if (XFS_IS_CORRUPT(rcur->bc_mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
error = xfs_btree_delete(rcur, &i);
|
error = xfs_btree_delete(rcur, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(rcur->bc_mp, i == 1, done);
|
if (XFS_IS_CORRUPT(rcur->bc_mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
done:
|
done:
|
||||||
if (error)
|
if (error)
|
||||||
trace_xfs_rmap_delete_error(rcur->bc_mp,
|
trace_xfs_rmap_delete_error(rcur->bc_mp,
|
||||||
|
@ -406,24 +418,39 @@ xfs_rmap_free_check_owner(
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* Make sure the unwritten flag matches. */
|
/* Make sure the unwritten flag matches. */
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, (flags & XFS_RMAP_UNWRITTEN) ==
|
if (XFS_IS_CORRUPT(mp,
|
||||||
(rec->rm_flags & XFS_RMAP_UNWRITTEN), out);
|
(flags & XFS_RMAP_UNWRITTEN) !=
|
||||||
|
(rec->rm_flags & XFS_RMAP_UNWRITTEN))) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
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. */
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, owner == rec->rm_owner, out);
|
if (XFS_IS_CORRUPT(mp, owner != rec->rm_owner)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
/* Check the offset, if necessary. */
|
/* Check the offset, if necessary. */
|
||||||
if (XFS_RMAP_NON_INODE_OWNER(owner))
|
if (XFS_RMAP_NON_INODE_OWNER(owner))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (flags & XFS_RMAP_BMBT_BLOCK) {
|
if (flags & XFS_RMAP_BMBT_BLOCK) {
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, rec->rm_flags & XFS_RMAP_BMBT_BLOCK,
|
if (XFS_IS_CORRUPT(mp,
|
||||||
out);
|
!(rec->rm_flags & XFS_RMAP_BMBT_BLOCK))) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, rec->rm_offset <= offset, out);
|
if (XFS_IS_CORRUPT(mp, rec->rm_offset > offset)) {
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp,
|
error = -EFSCORRUPTED;
|
||||||
ltoff + rec->rm_blockcount >= offset + len,
|
goto out;
|
||||||
out);
|
}
|
||||||
|
if (XFS_IS_CORRUPT(mp,
|
||||||
|
offset + len > ltoff + rec->rm_blockcount)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
@ -482,12 +509,18 @@ xfs_rmap_unmap(
|
||||||
error = xfs_rmap_lookup_le(cur, bno, len, owner, offset, flags, &i);
|
error = xfs_rmap_lookup_le(cur, bno, len, owner, offset, flags, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto out_error;
|
goto out_error;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, out_error);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto out_error;
|
||||||
|
}
|
||||||
|
|
||||||
error = xfs_rmap_get_rec(cur, <rec, &i);
|
error = xfs_rmap_get_rec(cur, <rec, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto out_error;
|
goto out_error;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, out_error);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto out_error;
|
||||||
|
}
|
||||||
trace_xfs_rmap_lookup_le_range_result(cur->bc_mp,
|
trace_xfs_rmap_lookup_le_range_result(cur->bc_mp,
|
||||||
cur->bc_private.a.agno, ltrec.rm_startblock,
|
cur->bc_private.a.agno, ltrec.rm_startblock,
|
||||||
ltrec.rm_blockcount, ltrec.rm_owner,
|
ltrec.rm_blockcount, ltrec.rm_owner,
|
||||||
|
@ -502,8 +535,12 @@ xfs_rmap_unmap(
|
||||||
* be the case that the "left" extent goes all the way to EOFS.
|
* be the case that the "left" extent goes all the way to EOFS.
|
||||||
*/
|
*/
|
||||||
if (owner == XFS_RMAP_OWN_NULL) {
|
if (owner == XFS_RMAP_OWN_NULL) {
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, bno >= ltrec.rm_startblock +
|
if (XFS_IS_CORRUPT(mp,
|
||||||
ltrec.rm_blockcount, out_error);
|
bno <
|
||||||
|
ltrec.rm_startblock + ltrec.rm_blockcount)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto out_error;
|
||||||
|
}
|
||||||
goto out_done;
|
goto out_done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -526,15 +563,22 @@ xfs_rmap_unmap(
|
||||||
error = xfs_rmap_get_rec(cur, &rtrec, &i);
|
error = xfs_rmap_get_rec(cur, &rtrec, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto out_error;
|
goto out_error;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, out_error);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto out_error;
|
||||||
|
}
|
||||||
if (rtrec.rm_startblock >= bno + len)
|
if (rtrec.rm_startblock >= bno + len)
|
||||||
goto out_done;
|
goto out_done;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make sure the extent we found covers the entire freeing range. */
|
/* Make sure the extent we found covers the entire freeing range. */
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, ltrec.rm_startblock <= bno &&
|
if (XFS_IS_CORRUPT(mp,
|
||||||
ltrec.rm_startblock + ltrec.rm_blockcount >=
|
ltrec.rm_startblock > bno ||
|
||||||
bno + len, out_error);
|
ltrec.rm_startblock + ltrec.rm_blockcount <
|
||||||
|
bno + len)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto out_error;
|
||||||
|
}
|
||||||
|
|
||||||
/* Check owner information. */
|
/* Check owner information. */
|
||||||
error = xfs_rmap_free_check_owner(mp, ltoff, <rec, len, owner,
|
error = xfs_rmap_free_check_owner(mp, ltoff, <rec, len, owner,
|
||||||
|
@ -551,7 +595,10 @@ xfs_rmap_unmap(
|
||||||
error = xfs_btree_delete(cur, &i);
|
error = xfs_btree_delete(cur, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto out_error;
|
goto out_error;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, out_error);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto out_error;
|
||||||
|
}
|
||||||
} else if (ltrec.rm_startblock == bno) {
|
} else if (ltrec.rm_startblock == bno) {
|
||||||
/*
|
/*
|
||||||
* overlap left hand side of extent: move the start, trim the
|
* overlap left hand side of extent: move the start, trim the
|
||||||
|
@ -743,7 +790,10 @@ xfs_rmap_map(
|
||||||
error = xfs_rmap_get_rec(cur, <rec, &have_lt);
|
error = xfs_rmap_get_rec(cur, <rec, &have_lt);
|
||||||
if (error)
|
if (error)
|
||||||
goto out_error;
|
goto out_error;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, have_lt == 1, out_error);
|
if (XFS_IS_CORRUPT(mp, have_lt != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto out_error;
|
||||||
|
}
|
||||||
trace_xfs_rmap_lookup_le_range_result(cur->bc_mp,
|
trace_xfs_rmap_lookup_le_range_result(cur->bc_mp,
|
||||||
cur->bc_private.a.agno, ltrec.rm_startblock,
|
cur->bc_private.a.agno, ltrec.rm_startblock,
|
||||||
ltrec.rm_blockcount, ltrec.rm_owner,
|
ltrec.rm_blockcount, ltrec.rm_owner,
|
||||||
|
@ -753,9 +803,12 @@ xfs_rmap_map(
|
||||||
have_lt = 0;
|
have_lt = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp,
|
if (XFS_IS_CORRUPT(mp,
|
||||||
have_lt == 0 ||
|
have_lt != 0 &&
|
||||||
ltrec.rm_startblock + ltrec.rm_blockcount <= bno, out_error);
|
ltrec.rm_startblock + ltrec.rm_blockcount > bno)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto out_error;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Increment the cursor to see if we have a right-adjacent record to our
|
* Increment the cursor to see if we have a right-adjacent record to our
|
||||||
|
@ -769,9 +822,14 @@ xfs_rmap_map(
|
||||||
error = xfs_rmap_get_rec(cur, >rec, &have_gt);
|
error = xfs_rmap_get_rec(cur, >rec, &have_gt);
|
||||||
if (error)
|
if (error)
|
||||||
goto out_error;
|
goto out_error;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, have_gt == 1, out_error);
|
if (XFS_IS_CORRUPT(mp, have_gt != 1)) {
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, bno + len <= gtrec.rm_startblock,
|
error = -EFSCORRUPTED;
|
||||||
out_error);
|
goto out_error;
|
||||||
|
}
|
||||||
|
if (XFS_IS_CORRUPT(mp, bno + len > gtrec.rm_startblock)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto out_error;
|
||||||
|
}
|
||||||
trace_xfs_rmap_find_right_neighbor_result(cur->bc_mp,
|
trace_xfs_rmap_find_right_neighbor_result(cur->bc_mp,
|
||||||
cur->bc_private.a.agno, gtrec.rm_startblock,
|
cur->bc_private.a.agno, gtrec.rm_startblock,
|
||||||
gtrec.rm_blockcount, gtrec.rm_owner,
|
gtrec.rm_blockcount, gtrec.rm_owner,
|
||||||
|
@ -821,7 +879,10 @@ xfs_rmap_map(
|
||||||
error = xfs_btree_delete(cur, &i);
|
error = xfs_btree_delete(cur, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto out_error;
|
goto out_error;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, out_error);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto out_error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* point the cursor back to the left record and update */
|
/* point the cursor back to the left record and update */
|
||||||
|
@ -865,7 +926,10 @@ xfs_rmap_map(
|
||||||
error = xfs_btree_insert(cur, &i);
|
error = xfs_btree_insert(cur, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto out_error;
|
goto out_error;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, out_error);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto out_error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
trace_xfs_rmap_map_done(mp, cur->bc_private.a.agno, bno, len,
|
trace_xfs_rmap_map_done(mp, cur->bc_private.a.agno, bno, len,
|
||||||
|
@ -957,12 +1021,18 @@ xfs_rmap_convert(
|
||||||
error = xfs_rmap_lookup_le(cur, bno, len, owner, offset, oldext, &i);
|
error = xfs_rmap_lookup_le(cur, bno, len, owner, offset, oldext, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
error = xfs_rmap_get_rec(cur, &PREV, &i);
|
error = xfs_rmap_get_rec(cur, &PREV, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
trace_xfs_rmap_lookup_le_range_result(cur->bc_mp,
|
trace_xfs_rmap_lookup_le_range_result(cur->bc_mp,
|
||||||
cur->bc_private.a.agno, PREV.rm_startblock,
|
cur->bc_private.a.agno, PREV.rm_startblock,
|
||||||
PREV.rm_blockcount, PREV.rm_owner,
|
PREV.rm_blockcount, PREV.rm_owner,
|
||||||
|
@ -995,10 +1065,16 @@ xfs_rmap_convert(
|
||||||
error = xfs_rmap_get_rec(cur, &LEFT, &i);
|
error = xfs_rmap_get_rec(cur, &LEFT, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp,
|
error = -EFSCORRUPTED;
|
||||||
LEFT.rm_startblock + LEFT.rm_blockcount <= bno,
|
goto done;
|
||||||
done);
|
}
|
||||||
|
if (XFS_IS_CORRUPT(mp,
|
||||||
|
LEFT.rm_startblock + LEFT.rm_blockcount >
|
||||||
|
bno)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
trace_xfs_rmap_find_left_neighbor_result(cur->bc_mp,
|
trace_xfs_rmap_find_left_neighbor_result(cur->bc_mp,
|
||||||
cur->bc_private.a.agno, LEFT.rm_startblock,
|
cur->bc_private.a.agno, LEFT.rm_startblock,
|
||||||
LEFT.rm_blockcount, LEFT.rm_owner,
|
LEFT.rm_blockcount, LEFT.rm_owner,
|
||||||
|
@ -1017,7 +1093,10 @@ xfs_rmap_convert(
|
||||||
error = xfs_btree_increment(cur, 0, &i);
|
error = xfs_btree_increment(cur, 0, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
error = xfs_btree_increment(cur, 0, &i);
|
error = xfs_btree_increment(cur, 0, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
|
@ -1026,9 +1105,14 @@ xfs_rmap_convert(
|
||||||
error = xfs_rmap_get_rec(cur, &RIGHT, &i);
|
error = xfs_rmap_get_rec(cur, &RIGHT, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, bno + len <= RIGHT.rm_startblock,
|
error = -EFSCORRUPTED;
|
||||||
done);
|
goto done;
|
||||||
|
}
|
||||||
|
if (XFS_IS_CORRUPT(mp, bno + len > RIGHT.rm_startblock)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
trace_xfs_rmap_find_right_neighbor_result(cur->bc_mp,
|
trace_xfs_rmap_find_right_neighbor_result(cur->bc_mp,
|
||||||
cur->bc_private.a.agno, RIGHT.rm_startblock,
|
cur->bc_private.a.agno, RIGHT.rm_startblock,
|
||||||
RIGHT.rm_blockcount, RIGHT.rm_owner,
|
RIGHT.rm_blockcount, RIGHT.rm_owner,
|
||||||
|
@ -1055,7 +1139,10 @@ xfs_rmap_convert(
|
||||||
error = xfs_rmap_lookup_le(cur, bno, len, owner, offset, oldext, &i);
|
error = xfs_rmap_lookup_le(cur, bno, len, owner, offset, oldext, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Switch out based on the FILLING and CONTIG state bits.
|
* Switch out based on the FILLING and CONTIG state bits.
|
||||||
|
@ -1071,7 +1158,10 @@ xfs_rmap_convert(
|
||||||
error = xfs_btree_increment(cur, 0, &i);
|
error = xfs_btree_increment(cur, 0, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
trace_xfs_rmap_delete(mp, cur->bc_private.a.agno,
|
trace_xfs_rmap_delete(mp, cur->bc_private.a.agno,
|
||||||
RIGHT.rm_startblock, RIGHT.rm_blockcount,
|
RIGHT.rm_startblock, RIGHT.rm_blockcount,
|
||||||
RIGHT.rm_owner, RIGHT.rm_offset,
|
RIGHT.rm_owner, RIGHT.rm_offset,
|
||||||
|
@ -1079,11 +1169,17 @@ xfs_rmap_convert(
|
||||||
error = xfs_btree_delete(cur, &i);
|
error = xfs_btree_delete(cur, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
error = xfs_btree_decrement(cur, 0, &i);
|
error = xfs_btree_decrement(cur, 0, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
trace_xfs_rmap_delete(mp, cur->bc_private.a.agno,
|
trace_xfs_rmap_delete(mp, cur->bc_private.a.agno,
|
||||||
PREV.rm_startblock, PREV.rm_blockcount,
|
PREV.rm_startblock, PREV.rm_blockcount,
|
||||||
PREV.rm_owner, PREV.rm_offset,
|
PREV.rm_owner, PREV.rm_offset,
|
||||||
|
@ -1091,11 +1187,17 @@ xfs_rmap_convert(
|
||||||
error = xfs_btree_delete(cur, &i);
|
error = xfs_btree_delete(cur, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
error = xfs_btree_decrement(cur, 0, &i);
|
error = xfs_btree_decrement(cur, 0, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
NEW = LEFT;
|
NEW = LEFT;
|
||||||
NEW.rm_blockcount += PREV.rm_blockcount + RIGHT.rm_blockcount;
|
NEW.rm_blockcount += PREV.rm_blockcount + RIGHT.rm_blockcount;
|
||||||
error = xfs_rmap_update(cur, &NEW);
|
error = xfs_rmap_update(cur, &NEW);
|
||||||
|
@ -1115,11 +1217,17 @@ xfs_rmap_convert(
|
||||||
error = xfs_btree_delete(cur, &i);
|
error = xfs_btree_delete(cur, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
error = xfs_btree_decrement(cur, 0, &i);
|
error = xfs_btree_decrement(cur, 0, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
NEW = LEFT;
|
NEW = LEFT;
|
||||||
NEW.rm_blockcount += PREV.rm_blockcount;
|
NEW.rm_blockcount += PREV.rm_blockcount;
|
||||||
error = xfs_rmap_update(cur, &NEW);
|
error = xfs_rmap_update(cur, &NEW);
|
||||||
|
@ -1135,7 +1243,10 @@ xfs_rmap_convert(
|
||||||
error = xfs_btree_increment(cur, 0, &i);
|
error = xfs_btree_increment(cur, 0, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
trace_xfs_rmap_delete(mp, cur->bc_private.a.agno,
|
trace_xfs_rmap_delete(mp, cur->bc_private.a.agno,
|
||||||
RIGHT.rm_startblock, RIGHT.rm_blockcount,
|
RIGHT.rm_startblock, RIGHT.rm_blockcount,
|
||||||
RIGHT.rm_owner, RIGHT.rm_offset,
|
RIGHT.rm_owner, RIGHT.rm_offset,
|
||||||
|
@ -1143,11 +1254,17 @@ xfs_rmap_convert(
|
||||||
error = xfs_btree_delete(cur, &i);
|
error = xfs_btree_delete(cur, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
error = xfs_btree_decrement(cur, 0, &i);
|
error = xfs_btree_decrement(cur, 0, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
NEW = PREV;
|
NEW = PREV;
|
||||||
NEW.rm_blockcount = len + RIGHT.rm_blockcount;
|
NEW.rm_blockcount = len + RIGHT.rm_blockcount;
|
||||||
NEW.rm_flags = newext;
|
NEW.rm_flags = newext;
|
||||||
|
@ -1214,7 +1331,10 @@ xfs_rmap_convert(
|
||||||
error = xfs_btree_insert(cur, &i);
|
error = xfs_btree_insert(cur, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RMAP_RIGHT_FILLING | RMAP_RIGHT_CONTIG:
|
case RMAP_RIGHT_FILLING | RMAP_RIGHT_CONTIG:
|
||||||
|
@ -1253,7 +1373,10 @@ xfs_rmap_convert(
|
||||||
oldext, &i);
|
oldext, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 0, done);
|
if (XFS_IS_CORRUPT(mp, i != 0)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
NEW.rm_startblock = bno;
|
NEW.rm_startblock = bno;
|
||||||
NEW.rm_owner = owner;
|
NEW.rm_owner = owner;
|
||||||
NEW.rm_offset = offset;
|
NEW.rm_offset = offset;
|
||||||
|
@ -1265,7 +1388,10 @@ xfs_rmap_convert(
|
||||||
error = xfs_btree_insert(cur, &i);
|
error = xfs_btree_insert(cur, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -1295,7 +1421,10 @@ xfs_rmap_convert(
|
||||||
error = xfs_btree_insert(cur, &i);
|
error = xfs_btree_insert(cur, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* Reset the cursor to the position of the new extent
|
* Reset the cursor to the position of the new extent
|
||||||
* we are about to insert as we can't trust it after
|
* we are about to insert as we can't trust it after
|
||||||
|
@ -1305,7 +1434,10 @@ xfs_rmap_convert(
|
||||||
oldext, &i);
|
oldext, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 0, done);
|
if (XFS_IS_CORRUPT(mp, i != 0)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
/* new middle extent - newext */
|
/* new middle extent - newext */
|
||||||
cur->bc_rec.r.rm_flags &= ~XFS_RMAP_UNWRITTEN;
|
cur->bc_rec.r.rm_flags &= ~XFS_RMAP_UNWRITTEN;
|
||||||
cur->bc_rec.r.rm_flags |= newext;
|
cur->bc_rec.r.rm_flags |= newext;
|
||||||
|
@ -1314,7 +1446,10 @@ xfs_rmap_convert(
|
||||||
error = xfs_btree_insert(cur, &i);
|
error = xfs_btree_insert(cur, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RMAP_LEFT_FILLING | RMAP_LEFT_CONTIG | RMAP_RIGHT_CONTIG:
|
case RMAP_LEFT_FILLING | RMAP_LEFT_CONTIG | RMAP_RIGHT_CONTIG:
|
||||||
|
@ -1383,7 +1518,10 @@ xfs_rmap_convert_shared(
|
||||||
&PREV, &i);
|
&PREV, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
ASSERT(PREV.rm_offset <= offset);
|
ASSERT(PREV.rm_offset <= offset);
|
||||||
ASSERT(PREV.rm_offset + PREV.rm_blockcount >= new_endoff);
|
ASSERT(PREV.rm_offset + PREV.rm_blockcount >= new_endoff);
|
||||||
|
@ -1406,9 +1544,12 @@ xfs_rmap_convert_shared(
|
||||||
goto done;
|
goto done;
|
||||||
if (i) {
|
if (i) {
|
||||||
state |= RMAP_LEFT_VALID;
|
state |= RMAP_LEFT_VALID;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp,
|
if (XFS_IS_CORRUPT(mp,
|
||||||
LEFT.rm_startblock + LEFT.rm_blockcount <= bno,
|
LEFT.rm_startblock + LEFT.rm_blockcount >
|
||||||
done);
|
bno)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
if (xfs_rmap_is_mergeable(&LEFT, owner, newext))
|
if (xfs_rmap_is_mergeable(&LEFT, owner, newext))
|
||||||
state |= RMAP_LEFT_CONTIG;
|
state |= RMAP_LEFT_CONTIG;
|
||||||
}
|
}
|
||||||
|
@ -1423,9 +1564,14 @@ xfs_rmap_convert_shared(
|
||||||
error = xfs_rmap_get_rec(cur, &RIGHT, &i);
|
error = xfs_rmap_get_rec(cur, &RIGHT, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, bno + len <= RIGHT.rm_startblock,
|
error = -EFSCORRUPTED;
|
||||||
done);
|
goto done;
|
||||||
|
}
|
||||||
|
if (XFS_IS_CORRUPT(mp, bno + len > RIGHT.rm_startblock)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
trace_xfs_rmap_find_right_neighbor_result(cur->bc_mp,
|
trace_xfs_rmap_find_right_neighbor_result(cur->bc_mp,
|
||||||
cur->bc_private.a.agno, RIGHT.rm_startblock,
|
cur->bc_private.a.agno, RIGHT.rm_startblock,
|
||||||
RIGHT.rm_blockcount, RIGHT.rm_owner,
|
RIGHT.rm_blockcount, RIGHT.rm_owner,
|
||||||
|
@ -1472,7 +1618,10 @@ xfs_rmap_convert_shared(
|
||||||
NEW.rm_offset, NEW.rm_flags, &i);
|
NEW.rm_offset, NEW.rm_flags, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
NEW.rm_blockcount += PREV.rm_blockcount + RIGHT.rm_blockcount;
|
NEW.rm_blockcount += PREV.rm_blockcount + RIGHT.rm_blockcount;
|
||||||
error = xfs_rmap_update(cur, &NEW);
|
error = xfs_rmap_update(cur, &NEW);
|
||||||
if (error)
|
if (error)
|
||||||
|
@ -1495,7 +1644,10 @@ xfs_rmap_convert_shared(
|
||||||
NEW.rm_offset, NEW.rm_flags, &i);
|
NEW.rm_offset, NEW.rm_flags, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
NEW.rm_blockcount += PREV.rm_blockcount;
|
NEW.rm_blockcount += PREV.rm_blockcount;
|
||||||
error = xfs_rmap_update(cur, &NEW);
|
error = xfs_rmap_update(cur, &NEW);
|
||||||
if (error)
|
if (error)
|
||||||
|
@ -1518,7 +1670,10 @@ xfs_rmap_convert_shared(
|
||||||
NEW.rm_offset, NEW.rm_flags, &i);
|
NEW.rm_offset, NEW.rm_flags, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
NEW.rm_blockcount += RIGHT.rm_blockcount;
|
NEW.rm_blockcount += RIGHT.rm_blockcount;
|
||||||
NEW.rm_flags = RIGHT.rm_flags;
|
NEW.rm_flags = RIGHT.rm_flags;
|
||||||
error = xfs_rmap_update(cur, &NEW);
|
error = xfs_rmap_update(cur, &NEW);
|
||||||
|
@ -1538,7 +1693,10 @@ xfs_rmap_convert_shared(
|
||||||
NEW.rm_offset, NEW.rm_flags, &i);
|
NEW.rm_offset, NEW.rm_flags, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
NEW.rm_flags = newext;
|
NEW.rm_flags = newext;
|
||||||
error = xfs_rmap_update(cur, &NEW);
|
error = xfs_rmap_update(cur, &NEW);
|
||||||
if (error)
|
if (error)
|
||||||
|
@ -1570,7 +1728,10 @@ xfs_rmap_convert_shared(
|
||||||
NEW.rm_offset, NEW.rm_flags, &i);
|
NEW.rm_offset, NEW.rm_flags, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
NEW.rm_blockcount += len;
|
NEW.rm_blockcount += len;
|
||||||
error = xfs_rmap_update(cur, &NEW);
|
error = xfs_rmap_update(cur, &NEW);
|
||||||
if (error)
|
if (error)
|
||||||
|
@ -1612,7 +1773,10 @@ xfs_rmap_convert_shared(
|
||||||
NEW.rm_offset, NEW.rm_flags, &i);
|
NEW.rm_offset, NEW.rm_flags, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
NEW.rm_blockcount = offset - NEW.rm_offset;
|
NEW.rm_blockcount = offset - NEW.rm_offset;
|
||||||
error = xfs_rmap_update(cur, &NEW);
|
error = xfs_rmap_update(cur, &NEW);
|
||||||
if (error)
|
if (error)
|
||||||
|
@ -1644,7 +1808,10 @@ xfs_rmap_convert_shared(
|
||||||
NEW.rm_offset, NEW.rm_flags, &i);
|
NEW.rm_offset, NEW.rm_flags, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
NEW.rm_blockcount -= len;
|
NEW.rm_blockcount -= len;
|
||||||
error = xfs_rmap_update(cur, &NEW);
|
error = xfs_rmap_update(cur, &NEW);
|
||||||
if (error)
|
if (error)
|
||||||
|
@ -1679,7 +1846,10 @@ xfs_rmap_convert_shared(
|
||||||
NEW.rm_offset, NEW.rm_flags, &i);
|
NEW.rm_offset, NEW.rm_flags, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto done;
|
goto done;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
NEW.rm_blockcount = offset - NEW.rm_offset;
|
NEW.rm_blockcount = offset - NEW.rm_offset;
|
||||||
error = xfs_rmap_update(cur, &NEW);
|
error = xfs_rmap_update(cur, &NEW);
|
||||||
if (error)
|
if (error)
|
||||||
|
@ -1765,25 +1935,44 @@ xfs_rmap_unmap_shared(
|
||||||
<rec, &i);
|
<rec, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto out_error;
|
goto out_error;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, out_error);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto out_error;
|
||||||
|
}
|
||||||
ltoff = ltrec.rm_offset;
|
ltoff = ltrec.rm_offset;
|
||||||
|
|
||||||
/* Make sure the extent we found covers the entire freeing range. */
|
/* Make sure the extent we found covers the entire freeing range. */
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, ltrec.rm_startblock <= bno &&
|
if (XFS_IS_CORRUPT(mp,
|
||||||
ltrec.rm_startblock + ltrec.rm_blockcount >=
|
ltrec.rm_startblock > bno ||
|
||||||
bno + len, out_error);
|
ltrec.rm_startblock + ltrec.rm_blockcount <
|
||||||
|
bno + len)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
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. */
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, owner == ltrec.rm_owner, out_error);
|
if (XFS_IS_CORRUPT(mp, owner != ltrec.rm_owner)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto out_error;
|
||||||
|
}
|
||||||
|
|
||||||
/* Make sure the unwritten flag matches. */
|
/* Make sure the unwritten flag matches. */
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, (flags & XFS_RMAP_UNWRITTEN) ==
|
if (XFS_IS_CORRUPT(mp,
|
||||||
(ltrec.rm_flags & XFS_RMAP_UNWRITTEN), out_error);
|
(flags & XFS_RMAP_UNWRITTEN) !=
|
||||||
|
(ltrec.rm_flags & XFS_RMAP_UNWRITTEN))) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto out_error;
|
||||||
|
}
|
||||||
|
|
||||||
/* Check the offset. */
|
/* Check the offset. */
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, ltrec.rm_offset <= offset, out_error);
|
if (XFS_IS_CORRUPT(mp, ltrec.rm_offset > offset)) {
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, offset <= ltoff + ltrec.rm_blockcount,
|
error = -EFSCORRUPTED;
|
||||||
out_error);
|
goto out_error;
|
||||||
|
}
|
||||||
|
if (XFS_IS_CORRUPT(mp, offset > ltoff + ltrec.rm_blockcount)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto out_error;
|
||||||
|
}
|
||||||
|
|
||||||
if (ltrec.rm_startblock == bno && ltrec.rm_blockcount == len) {
|
if (ltrec.rm_startblock == bno && ltrec.rm_blockcount == len) {
|
||||||
/* Exact match, simply remove the record from rmap tree. */
|
/* Exact match, simply remove the record from rmap tree. */
|
||||||
|
@ -1836,7 +2025,10 @@ xfs_rmap_unmap_shared(
|
||||||
ltrec.rm_offset, ltrec.rm_flags, &i);
|
ltrec.rm_offset, ltrec.rm_flags, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto out_error;
|
goto out_error;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, out_error);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto out_error;
|
||||||
|
}
|
||||||
ltrec.rm_blockcount -= len;
|
ltrec.rm_blockcount -= len;
|
||||||
error = xfs_rmap_update(cur, <rec);
|
error = xfs_rmap_update(cur, <rec);
|
||||||
if (error)
|
if (error)
|
||||||
|
@ -1862,7 +2054,10 @@ xfs_rmap_unmap_shared(
|
||||||
ltrec.rm_offset, ltrec.rm_flags, &i);
|
ltrec.rm_offset, ltrec.rm_flags, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto out_error;
|
goto out_error;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, out_error);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto out_error;
|
||||||
|
}
|
||||||
ltrec.rm_blockcount = bno - ltrec.rm_startblock;
|
ltrec.rm_blockcount = bno - ltrec.rm_startblock;
|
||||||
error = xfs_rmap_update(cur, <rec);
|
error = xfs_rmap_update(cur, <rec);
|
||||||
if (error)
|
if (error)
|
||||||
|
@ -1938,7 +2133,10 @@ xfs_rmap_map_shared(
|
||||||
error = xfs_rmap_get_rec(cur, >rec, &have_gt);
|
error = xfs_rmap_get_rec(cur, >rec, &have_gt);
|
||||||
if (error)
|
if (error)
|
||||||
goto out_error;
|
goto out_error;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, have_gt == 1, out_error);
|
if (XFS_IS_CORRUPT(mp, have_gt != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto out_error;
|
||||||
|
}
|
||||||
trace_xfs_rmap_find_right_neighbor_result(cur->bc_mp,
|
trace_xfs_rmap_find_right_neighbor_result(cur->bc_mp,
|
||||||
cur->bc_private.a.agno, gtrec.rm_startblock,
|
cur->bc_private.a.agno, gtrec.rm_startblock,
|
||||||
gtrec.rm_blockcount, gtrec.rm_owner,
|
gtrec.rm_blockcount, gtrec.rm_owner,
|
||||||
|
@ -1987,7 +2185,10 @@ xfs_rmap_map_shared(
|
||||||
ltrec.rm_offset, ltrec.rm_flags, &i);
|
ltrec.rm_offset, ltrec.rm_flags, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto out_error;
|
goto out_error;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, out_error);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto out_error;
|
||||||
|
}
|
||||||
|
|
||||||
error = xfs_rmap_update(cur, <rec);
|
error = xfs_rmap_update(cur, <rec);
|
||||||
if (error)
|
if (error)
|
||||||
|
|
|
@ -71,7 +71,10 @@ xfs_trim_extents(
|
||||||
error = xfs_alloc_get_rec(cur, &fbno, &flen, &i);
|
error = xfs_alloc_get_rec(cur, &fbno, &flen, &i);
|
||||||
if (error)
|
if (error)
|
||||||
goto out_del_cursor;
|
goto out_del_cursor;
|
||||||
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, out_del_cursor);
|
if (XFS_IS_CORRUPT(mp, i != 1)) {
|
||||||
|
error = -EFSCORRUPTED;
|
||||||
|
goto out_del_cursor;
|
||||||
|
}
|
||||||
ASSERT(flen <= be32_to_cpu(XFS_BUF_TO_AGF(agbp)->agf_longest));
|
ASSERT(flen <= be32_to_cpu(XFS_BUF_TO_AGF(agbp)->agf_longest));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -38,32 +38,6 @@ extern void xfs_inode_verifier_error(struct xfs_inode *ip, int error,
|
||||||
/* Dump 128 bytes of any corrupt buffer */
|
/* Dump 128 bytes of any corrupt buffer */
|
||||||
#define XFS_CORRUPTION_DUMP_LEN (128)
|
#define XFS_CORRUPTION_DUMP_LEN (128)
|
||||||
|
|
||||||
/*
|
|
||||||
* Macros to set EFSCORRUPTED & return/branch.
|
|
||||||
*/
|
|
||||||
#define XFS_WANT_CORRUPTED_GOTO(mp, x, l) \
|
|
||||||
{ \
|
|
||||||
int fs_is_ok = (x); \
|
|
||||||
ASSERT(fs_is_ok); \
|
|
||||||
if (unlikely(!fs_is_ok)) { \
|
|
||||||
XFS_ERROR_REPORT("XFS_WANT_CORRUPTED_GOTO", \
|
|
||||||
XFS_ERRLEVEL_LOW, mp); \
|
|
||||||
error = -EFSCORRUPTED; \
|
|
||||||
goto l; \
|
|
||||||
} \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define XFS_WANT_CORRUPTED_RETURN(mp, x) \
|
|
||||||
{ \
|
|
||||||
int fs_is_ok = (x); \
|
|
||||||
ASSERT(fs_is_ok); \
|
|
||||||
if (unlikely(!fs_is_ok)) { \
|
|
||||||
XFS_ERROR_REPORT("XFS_WANT_CORRUPTED_RETURN", \
|
|
||||||
XFS_ERRLEVEL_LOW, mp); \
|
|
||||||
return -EFSCORRUPTED; \
|
|
||||||
} \
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
extern int xfs_errortag_init(struct xfs_mount *mp);
|
extern int xfs_errortag_init(struct xfs_mount *mp);
|
||||||
extern void xfs_errortag_del(struct xfs_mount *mp);
|
extern void xfs_errortag_del(struct xfs_mount *mp);
|
||||||
|
|
|
@ -298,7 +298,8 @@ 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;
|
||||||
XFS_WANT_CORRUPTED_RETURN(mp, *has_more == 1);
|
if (XFS_IS_CORRUPT(mp, *has_more != 1))
|
||||||
|
return -EFSCORRUPTED;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the LE lookup yielded an inobt record before the cursor position,
|
* If the LE lookup yielded an inobt record before the cursor position,
|
||||||
|
|
Загрузка…
Ссылка в новой задаче