From: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
To: "linux-btrfs@vger.kernel.org" <linux-btrfs@vger.kernel.org>
Cc: chris.mason@fusionio.com, Eric Sandeen <sandeen@redhat.com>
Subject: [PATCH v2 1/3] btrfs-progs: error if device for mkfs is too small
Date: Thu, 05 Sep 2013 15:53:34 +0900 [thread overview]
Message-ID: <52282A6E.1020902@jp.fujitsu.com> (raw)
In-Reply-To: <522829F5.5050405@jp.fujitsu.com>
Eric pointed out that mkfs abort if specified volume is too small:
# truncate --size=2m testfile
# ./mkfs.btrfs testfile
:
SMALL VOLUME: forcing mixed metadata/data groups
mkfs.btrfs: volumes.c:852: btrfs_alloc_chunk: Assertion `!(ret)' failed.
Aborted (core dumped)
As the first step to fix problems around there, let mkfs to report
error if the size of target volume is less than the size of the first
system block group, BTRFS_MKFS_SYSTEM_GROUP_SIZE (= 4MB).
Reported-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
---
mkfs.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/mkfs.c b/mkfs.c
index b412b7e..a98fe54 100644
--- a/mkfs.c
+++ b/mkfs.c
@@ -1422,6 +1422,12 @@ int main(int ac, char **av)
}
}
+ /* To create the first block group and chunk 0 in make_btrfs */
+ if (dev_block_count < BTRFS_MKFS_SYSTEM_GROUP_SIZE) {
+ fprintf(stderr, "device is too small to make filesystem\n");
+ exit(1);
+ }
+
blocks[0] = BTRFS_SUPER_INFO_OFFSET;
for (i = 1; i < 7; i++) {
blocks[i] = BTRFS_SUPER_INFO_OFFSET + 1024 * 1024 +
--
1.7.1
next prev parent reply other threads:[~2013-09-05 6:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-05 6:51 [PATCH v2 0/3] btrfs-progs: prevent mkfs from aborting with small volume Hidetoshi Seto
2013-09-05 6:53 ` Hidetoshi Seto [this message]
2013-09-05 6:55 ` [PATCH v2 2/3] btrfs-progs: error if device have no space to make primary chunks Hidetoshi Seto
2013-09-05 6:57 ` [PATCH v2 3/3] btrfs-progs: calculate available blocks on device properly Hidetoshi Seto
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=52282A6E.1020902@jp.fujitsu.com \
--to=seto.hidetoshi@jp.fujitsu.com \
--cc=chris.mason@fusionio.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=sandeen@redhat.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).