summaryrefslogtreecommitdiff
path: root/fs/xfs/libxfs/xfs_da_btree.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs/libxfs/xfs_da_btree.c')
-rw-r--r--fs/xfs/libxfs/xfs_da_btree.c58
1 files changed, 22 insertions, 36 deletions
diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c
index 9925d4a7dc33..36fc8ffc06b1 100644
--- a/fs/xfs/libxfs/xfs_da_btree.c
+++ b/fs/xfs/libxfs/xfs_da_btree.c
@@ -1619,15 +1619,12 @@ xfs_da3_node_lookup_int(
}
/* We can't point back to the root. */
- if (blkno == args->geo->leafblk) {
- XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW,
- dp->i_mount);
+ if (XFS_CORRUPT_ON(dp->i_mount, blkno == args->geo->leafblk)) {
return -EFSCORRUPTED;
}
}
- if (expected_level != 0) {
- XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, dp->i_mount);
+ if (XFS_CORRUPT_ON(dp->i_mount, expected_level != 0)) {
return -EFSCORRUPTED;
}
@@ -2225,9 +2222,7 @@ xfs_da3_swap_lastblock(
error = xfs_bmap_last_before(tp, dp, &lastoff, w);
if (error)
return error;
- if (unlikely(lastoff == 0)) {
- XFS_ERROR_REPORT("xfs_da_swap_lastblock(1)", XFS_ERRLEVEL_LOW,
- mp);
+ if (XFS_CORRUPT_ON(mp, lastoff == 0)) {
return -EFSCORRUPTED;
}
/*
@@ -2274,11 +2269,9 @@ xfs_da3_swap_lastblock(
if (error)
goto done;
sib_info = sib_buf->b_addr;
- if (unlikely(
+ if (XFS_CORRUPT_ON(mp,
be32_to_cpu(sib_info->forw) != last_blkno ||
sib_info->magic != dead_info->magic)) {
- XFS_ERROR_REPORT("xfs_da_swap_lastblock(2)",
- XFS_ERRLEVEL_LOW, mp);
error = -EFSCORRUPTED;
goto done;
}
@@ -2296,11 +2289,9 @@ xfs_da3_swap_lastblock(
if (error)
goto done;
sib_info = sib_buf->b_addr;
- if (unlikely(
- be32_to_cpu(sib_info->back) != last_blkno ||
- sib_info->magic != dead_info->magic)) {
- XFS_ERROR_REPORT("xfs_da_swap_lastblock(3)",
- XFS_ERRLEVEL_LOW, mp);
+ if (XFS_CORRUPT_ON(mp,
+ be32_to_cpu(sib_info->back) != last_blkno ||
+ sib_info->magic != dead_info->magic)) {
error = -EFSCORRUPTED;
goto done;
}
@@ -2321,9 +2312,8 @@ xfs_da3_swap_lastblock(
goto done;
par_node = par_buf->b_addr;
dp->d_ops->node_hdr_from_disk(&par_hdr, par_node);
- if (level >= 0 && level != par_hdr.level + 1) {
- XFS_ERROR_REPORT("xfs_da_swap_lastblock(4)",
- XFS_ERRLEVEL_LOW, mp);
+ if (XFS_CORRUPT_ON(mp,
+ level >= 0 && level != par_hdr.level + 1)) {
error = -EFSCORRUPTED;
goto done;
}
@@ -2334,9 +2324,7 @@ xfs_da3_swap_lastblock(
be32_to_cpu(btree[entno].hashval) < dead_hash;
entno++)
continue;
- if (entno == par_hdr.count) {
- XFS_ERROR_REPORT("xfs_da_swap_lastblock(5)",
- XFS_ERRLEVEL_LOW, mp);
+ if (XFS_CORRUPT_ON(mp, entno == par_hdr.count)) {
error = -EFSCORRUPTED;
goto done;
}
@@ -2361,9 +2349,7 @@ xfs_da3_swap_lastblock(
par_blkno = par_hdr.forw;
xfs_trans_brelse(tp, par_buf);
par_buf = NULL;
- if (unlikely(par_blkno == 0)) {
- XFS_ERROR_REPORT("xfs_da_swap_lastblock(6)",
- XFS_ERRLEVEL_LOW, mp);
+ if (XFS_CORRUPT_ON(mp, par_blkno == 0)) {
error = -EFSCORRUPTED;
goto done;
}
@@ -2372,9 +2358,7 @@ xfs_da3_swap_lastblock(
goto done;
par_node = par_buf->b_addr;
dp->d_ops->node_hdr_from_disk(&par_hdr, par_node);
- if (par_hdr.level != level) {
- XFS_ERROR_REPORT("xfs_da_swap_lastblock(7)",
- XFS_ERRLEVEL_LOW, mp);
+ if (XFS_CORRUPT_ON(mp, par_hdr.level != level)) {
error = -EFSCORRUPTED;
goto done;
}
@@ -2531,6 +2515,7 @@ xfs_dabuf_map(
int error = 0;
struct xfs_bmbt_irec irec;
struct xfs_bmbt_irec *irecs = &irec;
+ bool covers_blocks;
int nirecs;
ASSERT(map && *map);
@@ -2566,14 +2551,16 @@ xfs_dabuf_map(
nirecs = 1;
}
- if (!xfs_da_map_covers_blocks(nirecs, irecs, bno, nfsb)) {
- /* Caller ok with no mapping. */
- if (mappedbno == -2) {
- error = -1;
- goto out;
- }
+ covers_blocks = xfs_da_map_covers_blocks(nirecs, irecs, bno, nfsb);
+
+ /* Caller ok with no mapping. */
+ if (mappedbno == -2 && !covers_blocks) {
+ error = -1;
+ goto out;
+ }
- /* Caller expected a mapping, so abort. */
+ /* Caller expected a mapping, so abort. */
+ if (XFS_CORRUPT_ON(mp, !covers_blocks)) {
if (xfs_error_level >= XFS_ERRLEVEL_LOW) {
int i;
@@ -2589,7 +2576,6 @@ xfs_dabuf_map(
irecs[i].br_state);
}
}
- XFS_ERROR_REPORT("xfs_da_do_buf(1)", XFS_ERRLEVEL_LOW, mp);
error = -EFSCORRUPTED;
goto out;
}