xfs: don't assert when on-disk btree pointers are garbage
authorDarrick J. Wong <darrick.wong@oracle.com>
Sun, 3 Jun 2018 23:10:12 +0000 (16:10 -0700)
committerDarrick J. Wong <darrick.wong@oracle.com>
Tue, 5 Jun 2018 01:25:05 +0000 (18:25 -0700)
Don't ASSERT when we encounter bad on-disk btree pointers in the debug
check functions.  Log the error to leave breadcrumbs and let the upper
layers deal with it.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
fs/xfs/libxfs/xfs_btree.c

index 3fcddfeaa6628abafcbef0e8ae86406608f6144f..4f83d7949a2196a164ff0dad2d4d60f381759e5d 100644 (file)
@@ -246,16 +246,25 @@ xfs_btree_check_ptr(
        int                     level)
 {
        if (cur->bc_flags & XFS_BTREE_LONG_PTRS) {
-               XFS_WANT_CORRUPTED_RETURN(cur->bc_mp,
-                               xfs_btree_check_lptr(cur,
-                                       be64_to_cpu((&ptr->l)[index]), level));
+               if (xfs_btree_check_lptr(cur, be64_to_cpu((&ptr->l)[index]),
+                               level))
+                       return 0;
+               xfs_err(cur->bc_mp,
+"Inode %llu fork %d: Corrupt btree %d pointer at level %d index %d.",
+                               cur->bc_private.b.ip->i_ino,
+                               cur->bc_private.b.whichfork, cur->bc_btnum,
+                               level, index);
        } else {
-               XFS_WANT_CORRUPTED_RETURN(cur->bc_mp,
-                               xfs_btree_check_sptr(cur,
-                                       be32_to_cpu((&ptr->s)[index]), level));
+               if (xfs_btree_check_sptr(cur, be32_to_cpu((&ptr->s)[index]),
+                               level))
+                       return 0;
+               xfs_err(cur->bc_mp,
+"AG %u: Corrupt btree %d pointer at level %d index %d.",
+                               cur->bc_private.a.agno, cur->bc_btnum,
+                               level, index);
        }
 
-       return 0;
+       return -EFSCORRUPTED;
 }
 
 #ifdef DEBUG