From patchwork Thu Sep 5 06:53:34 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hidetoshi Seto X-Patchwork-Id: 2853942 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B90DC9F3DC for ; Thu, 5 Sep 2013 06:53:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A60CC2018A for ; Thu, 5 Sep 2013 06:53:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5B31D2017E for ; Thu, 5 Sep 2013 06:53:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757483Ab3IEGxr (ORCPT ); Thu, 5 Sep 2013 02:53:47 -0400 Received: from fgwmail6.fujitsu.co.jp ([192.51.44.36]:35030 "EHLO fgwmail6.fujitsu.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757186Ab3IEGxq (ORCPT ); Thu, 5 Sep 2013 02:53:46 -0400 Received: from m4.gw.fujitsu.co.jp (unknown [10.0.50.74]) by fgwmail6.fujitsu.co.jp (Postfix) with ESMTP id 28AC13EE0BB for ; Thu, 5 Sep 2013 15:53:45 +0900 (JST) Received: from smail (m4 [127.0.0.1]) by outgoing.m4.gw.fujitsu.co.jp (Postfix) with ESMTP id 1743145DE50 for ; Thu, 5 Sep 2013 15:53:45 +0900 (JST) Received: from s4.gw.fujitsu.co.jp (s4.gw.fujitsu.co.jp [10.0.50.94]) by m4.gw.fujitsu.co.jp (Postfix) with ESMTP id 0022F45DE4F for ; Thu, 5 Sep 2013 15:53:45 +0900 (JST) Received: from s4.gw.fujitsu.co.jp (localhost.localdomain [127.0.0.1]) by s4.gw.fujitsu.co.jp (Postfix) with ESMTP id E909F1DB8040 for ; Thu, 5 Sep 2013 15:53:44 +0900 (JST) Received: from ml14.s.css.fujitsu.com (ml14.s.css.fujitsu.com [10.240.81.134]) by s4.gw.fujitsu.co.jp (Postfix) with ESMTP id A11CC1DB803B for ; Thu, 5 Sep 2013 15:53:44 +0900 (JST) Received: from ml14.css.fujitsu.com (ml14 [127.0.0.1]) by ml14.s.css.fujitsu.com (Postfix) with ESMTP id 7791A584014; Thu, 5 Sep 2013 15:53:44 +0900 (JST) Received: from [127.0.0.1] (ichinokura.soft.fujitsu.com [10.124.102.143]) by ml14.s.css.fujitsu.com (Postfix) with ESMTP id 1A34258400A; Thu, 5 Sep 2013 15:53:44 +0900 (JST) X-SecurityPolicyCheck: OK by SHieldMailChecker v1.7.4 Message-ID: <52282A6E.1020902@jp.fujitsu.com> Date: Thu, 05 Sep 2013 15:53:34 +0900 From: Hidetoshi Seto User-Agent: Mozilla/5.0 (Windows NT 6.0; rv:17.0) Gecko/20130620 Thunderbird/17.0.7 MIME-Version: 1.0 To: "linux-btrfs@vger.kernel.org" CC: chris.mason@fusionio.com, Eric Sandeen Subject: [PATCH v2 1/3] btrfs-progs: error if device for mkfs is too small References: <522829F5.5050405@jp.fujitsu.com> In-Reply-To: <522829F5.5050405@jp.fujitsu.com> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-9.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Signed-off-by: Hidetoshi Seto --- 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 +