xfs: remove more ondisk directory corruption asserts

Continue our game of replacing ASSERTs for corrupt ondisk metadata with
EFSCORRUPTED returns.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Bill O'Donnell <billodo@redhat.com>
This commit is contained in:
Darrick J. Wong 2019-08-11 15:52:26 -07:00
parent 294fc7a4c8
commit 858b44dc62
2 changed files with 14 additions and 8 deletions

View File

@ -487,10 +487,8 @@ xfs_da3_split(
ASSERT(state->path.active == 0); ASSERT(state->path.active == 0);
oldblk = &state->path.blk[0]; oldblk = &state->path.blk[0];
error = xfs_da3_root_split(state, oldblk, addblk); error = xfs_da3_root_split(state, oldblk, addblk);
if (error) { if (error)
addblk->bp = NULL; goto out;
return error; /* GROT: dir is inconsistent */
}
/* /*
* Update pointers to the node which used to be block 0 and just got * Update pointers to the node which used to be block 0 and just got
@ -505,7 +503,10 @@ xfs_da3_split(
*/ */
node = oldblk->bp->b_addr; node = oldblk->bp->b_addr;
if (node->hdr.info.forw) { if (node->hdr.info.forw) {
ASSERT(be32_to_cpu(node->hdr.info.forw) == addblk->blkno); if (be32_to_cpu(node->hdr.info.forw) != addblk->blkno) {
error = -EFSCORRUPTED;
goto out;
}
node = addblk->bp->b_addr; node = addblk->bp->b_addr;
node->hdr.info.back = cpu_to_be32(oldblk->blkno); node->hdr.info.back = cpu_to_be32(oldblk->blkno);
xfs_trans_log_buf(state->args->trans, addblk->bp, xfs_trans_log_buf(state->args->trans, addblk->bp,
@ -514,15 +515,19 @@ xfs_da3_split(
} }
node = oldblk->bp->b_addr; node = oldblk->bp->b_addr;
if (node->hdr.info.back) { if (node->hdr.info.back) {
ASSERT(be32_to_cpu(node->hdr.info.back) == addblk->blkno); if (be32_to_cpu(node->hdr.info.back) != addblk->blkno) {
error = -EFSCORRUPTED;
goto out;
}
node = addblk->bp->b_addr; node = addblk->bp->b_addr;
node->hdr.info.forw = cpu_to_be32(oldblk->blkno); node->hdr.info.forw = cpu_to_be32(oldblk->blkno);
xfs_trans_log_buf(state->args->trans, addblk->bp, xfs_trans_log_buf(state->args->trans, addblk->bp,
XFS_DA_LOGRANGE(node, &node->hdr.info, XFS_DA_LOGRANGE(node, &node->hdr.info,
sizeof(node->hdr.info))); sizeof(node->hdr.info)));
} }
out:
addblk->bp = NULL; addblk->bp = NULL;
return 0; return error;
} }
/* /*

View File

@ -741,7 +741,8 @@ xfs_dir2_leafn_lookup_for_entry(
ents = dp->d_ops->leaf_ents_p(leaf); ents = dp->d_ops->leaf_ents_p(leaf);
xfs_dir3_leaf_check(dp, bp); xfs_dir3_leaf_check(dp, bp);
ASSERT(leafhdr.count > 0); if (leafhdr.count <= 0)
return -EFSCORRUPTED;
/* /*
* Look up the hash value in the leaf entries. * Look up the hash value in the leaf entries.