]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_repair: don't crash on ENOSPC rebuilding a btree
authorDarrick J. Wong <darrick.wong@oracle.com>
Thu, 8 Sep 2016 00:22:28 +0000 (10:22 +1000)
committerDave Chinner <david@fromorbit.com>
Thu, 8 Sep 2016 00:22:28 +0000 (10:22 +1000)
During btree rebuilding, the cursor setup function checks ext_ptr to
report ENOSPC problems when it grabs the first extent for the btree.
However, subsequent grabs for free space don't check ext_ptr and so we
segfault if there's no space.  Therefore, move the ENOSPC check into
the loop so that we always complain about insufficient space instead
of just crashing.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
repair/phase5.c

index b464b560846b976bc113f6da47536443243d920c..28aaefe35d4b6c3666f285839cfcf32c33c98c69 100644 (file)
@@ -231,8 +231,7 @@ setup_cursor(xfs_mount_t *mp, xfs_agnumber_t agno, bt_status_t *curs)
         * grab the smallest extent and use it up, then get the
         * next smallest.  This mimics the init_*_cursor code.
         */
-       if ((ext_ptr =  findfirst_bcnt_extent(agno)) == NULL)
-               do_error(_("error - not enough free space in filesystem\n"));
+       ext_ptr =  findfirst_bcnt_extent(agno);
 
        agb_ptr = curs->btree_blocks;
 
@@ -240,6 +239,9 @@ setup_cursor(xfs_mount_t *mp, xfs_agnumber_t agno, bt_status_t *curs)
         * set up the free block array
         */
        while (blocks_allocated < big_extent_len)  {
+               if (!ext_ptr)
+                       do_error(
+_("error - not enough free space in filesystem\n"));
                /*
                 * use up the extent we've got
                 */