]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: btree lookup shouldn't ASSERT on empty btree nodes
authorDarrick J. Wong <darrick.wong@oracle.com>
Thu, 28 Jun 2018 20:11:57 +0000 (15:11 -0500)
committerEric Sandeen <sandeen@redhat.com>
Thu, 28 Jun 2018 20:11:57 +0000 (15:11 -0500)
Source kernel commit: eeee0d6a9bc93eaa211918c203fde263d44fa20e

If a btree lookup encounters an empty btree node or an empty btree leaf
on a multi-level btree, that's evidence of a corrupt on-disk btree.
Therefore, we should return -EFSCORRUPTED to the upper levels, not an
ASSERT failure.

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

index 2bd9dd3596b9914682502ac26ca1e0367d13dab6..d64cd2899024b86cf5fc9e9d9a21eed5632b1d77 100644 (file)
@@ -1892,7 +1892,12 @@ xfs_btree_lookup(
                        high = xfs_btree_get_numrecs(block);
                        if (!high) {
                                /* Block is empty, must be an empty leaf. */
-                               ASSERT(level == 0 && cur->bc_nlevels == 1);
+                               if (level != 0 || cur->bc_nlevels != 1) {
+                                       XFS_CORRUPTION_ERROR(__func__,
+                                                       XFS_ERRLEVEL_LOW,
+                                                       cur->bc_mp, block);
+                                       return -EFSCORRUPTED;
+                               }
 
                                cur->bc_ptrs[0] = dir != XFS_LOOKUP_LE;
                                *stat = 0;