Skip to content

Commit

Permalink
xfs: remove more ondisk directory corruption asserts
Browse files Browse the repository at this point in the history
Continue our game of replacing ASSERTs for corrupt ondisk metadata with
EFSCORRUPTED returns.

Signed-off-by: Darrick J. Wong <[email protected]>
Reviewed-by: Bill O'Donnell <[email protected]>
  • Loading branch information
djwong committed Aug 12, 2019
1 parent 294fc7a commit 858b44d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
19 changes: 12 additions & 7 deletions fs/xfs/libxfs/xfs_da_btree.c
Original file line number Diff line number Diff line change
Expand Up @@ -487,10 +487,8 @@ xfs_da3_split(
ASSERT(state->path.active == 0);
oldblk = &state->path.blk[0];
error = xfs_da3_root_split(state, oldblk, addblk);
if (error) {
addblk->bp = NULL;
return error; /* GROT: dir is inconsistent */
}
if (error)
goto out;

/*
* Update pointers to the node which used to be block 0 and just got
Expand All @@ -505,7 +503,10 @@ xfs_da3_split(
*/
node = oldblk->bp->b_addr;
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->hdr.info.back = cpu_to_be32(oldblk->blkno);
xfs_trans_log_buf(state->args->trans, addblk->bp,
Expand All @@ -514,15 +515,19 @@ xfs_da3_split(
}
node = oldblk->bp->b_addr;
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->hdr.info.forw = cpu_to_be32(oldblk->blkno);
xfs_trans_log_buf(state->args->trans, addblk->bp,
XFS_DA_LOGRANGE(node, &node->hdr.info,
sizeof(node->hdr.info)));
}
out:
addblk->bp = NULL;
return 0;
return error;
}

/*
Expand Down
3 changes: 2 additions & 1 deletion fs/xfs/libxfs/xfs_dir2_node.c
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,8 @@ xfs_dir2_leafn_lookup_for_entry(
ents = dp->d_ops->leaf_ents_p(leaf);

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.
Expand Down

0 comments on commit 858b44d

Please sign in to comment.