All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
To: linux-btrfs@vger.kernel.org
Cc: chris.mason@fusionio.com
Subject: [PATCH 2/2] btrfs-progs: exit if there is not enough free space for mkfs
Date: Fri, 23 Aug 2013 15:31:41 +0900	[thread overview]
Message-ID: <521701CD.7060409@jp.fujitsu.com> (raw)
In-Reply-To: <52170114.7060604@jp.fujitsu.com>

Again, while playing mkfs with small volumes, I found that mkfs.btrfs
aborts if there is really no spaces for a brand-new filesystem:

  # ./mkfs.btrfs -f /dev/sdf1 /dev/sdf2
  :
  SMALL VOLUME: forcing mixed metadata/data groups
  adding device /dev/sdf2 id 2
  mkfs.btrfs: mkfs.c:184: create_one_raid_group: Assertion `!(ret)' failed.
  Aborted (core dumped)

This fix let mkfs prints error message if it cannot make filesystem due
to a lack of free spaces.

Signed-off-by: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
---
 mkfs.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/mkfs.c b/mkfs.c
index b412b7e..3c0bc60 100644
--- a/mkfs.c
+++ b/mkfs.c
@@ -181,6 +181,10 @@ static int create_one_raid_group(struct btrfs_trans_handle *trans,
 
 	ret = btrfs_alloc_chunk(trans, root->fs_info->extent_root,
 				&chunk_start, &chunk_size, type);
+	if (ret == -ENOSPC) {
+		fprintf(stderr, "not enough free space\n");
+		exit(1);
+	}
 	BUG_ON(ret);
 	ret = btrfs_make_block_group(trans, root->fs_info->extent_root, 0,
 				     type, BTRFS_FIRST_CHUNK_TREE_OBJECTID,
-- 
1.7.1



  parent reply	other threads:[~2013-08-23  6:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-23  6:28 [PATCH 0/2] btrfs-progs: prevent mkfs from aborting with small volume Hidetoshi Seto
2013-08-23  6:30 ` [PATCH 1/2] btrfs-progs: treat reserved 1MB for superblock properly Hidetoshi Seto
2013-08-23  6:31 ` Hidetoshi Seto [this message]
2013-08-26 14:23 ` [PATCH 0/2] btrfs-progs: prevent mkfs from aborting with small volume Eric Sandeen
2013-08-28  5:01   ` Hidetoshi Seto
2013-08-29 16:11     ` Eric Sandeen
2013-08-30 23:10       ` David Sterba

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=521701CD.7060409@jp.fujitsu.com \
    --to=seto.hidetoshi@jp.fujitsu.com \
    --cc=chris.mason@fusionio.com \
    --cc=linux-btrfs@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.