linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Dave Chinner <david@fromorbit.com>
Cc: linux-xfs@vger.kernel.org, xfs@oss.sgi.com
Subject: [PATCH] xfs_repair: don't crash if we run out of space midway through rebuilding a btree
Date: Mon, 29 Aug 2016 20:44:10 -0700	[thread overview]
Message-ID: <20160830034410.GK22760@birch.djwong.org> (raw)

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>
---
 repair/phase5.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/repair/phase5.c b/repair/phase5.c
index b464b56..28aaefe 100644
--- a/repair/phase5.c
+++ b/repair/phase5.c
@@ -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
 		 */

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

                 reply	other threads:[~2016-08-30  3:44 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160830034410.GK22760@birch.djwong.org \
    --to=darrick.wong@oracle.com \
    --cc=david@fromorbit.com \
    --cc=linux-xfs@vger.kernel.org \
    --cc=xfs@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).