From patchwork Fri Jul 1 05:26:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiaoguang Wang X-Patchwork-Id: 9209221 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AF0D560752 for ; Fri, 1 Jul 2016 05:31:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9587228696 for ; Fri, 1 Jul 2016 05:31:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 881492869A; Fri, 1 Jul 2016 05:31:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2840D28696 for ; Fri, 1 Jul 2016 05:31:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751651AbcGAFb2 (ORCPT ); Fri, 1 Jul 2016 01:31:28 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:13225 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1751426AbcGAFb2 (ORCPT ); Fri, 1 Jul 2016 01:31:28 -0400 X-IronPort-AV: E=Sophos;i="5.20,367,1444665600"; d="scan'208";a="652054" Received: from unknown (HELO cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 01 Jul 2016 13:28:06 +0800 Received: from localhost.localdomain (unknown [10.167.226.107]) by cn.fujitsu.com (Postfix) with ESMTP id A96804056403 for ; Fri, 1 Jul 2016 13:28:03 +0800 (CST) From: Wang Xiaoguang To: linux-btrfs@vger.kernel.org Subject: [PATCH] btrfs-progs: mkfs: fix allocation information output of block group types Date: Fri, 1 Jul 2016 13:26:25 +0800 Message-Id: <20160701052625.7748-1-wangxg.fnst@cn.fujitsu.com> X-Mailer: git-send-email 2.9.0 MIME-Version: 1.0 X-yoursite-MailScanner-ID: A96804056403.AFF17 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: wangxg.fnst@cn.fujitsu.com Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When cleanup_temp_chunks() removes block groups, it forgot to update mkfs_allocation accordingly, fix this. Signed-off-by: Wang Xiaoguang --- mkfs.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/mkfs.c b/mkfs.c index 697bdc2..e837131 100644 --- a/mkfs.c +++ b/mkfs.c @@ -1275,6 +1275,7 @@ static int cleanup_temp_chunks(struct btrfs_fs_info *fs_info, struct btrfs_key found_key; struct btrfs_path *path; int ret = 0; + u64 flags; path = btrfs_alloc_path(); if (!path) { @@ -1318,10 +1319,26 @@ static int cleanup_temp_chunks(struct btrfs_fs_info *fs_info, if (is_temp_block_group(path->nodes[0], bgi, data_profile, meta_profile, sys_profile)) { + flags = btrfs_disk_block_group_flags(path->nodes[0], + bgi); ret = btrfs_free_block_group(trans, fs_info, found_key.objectid, found_key.offset); if (ret < 0) goto out; + + if ((flags & BTRFS_BLOCK_GROUP_TYPE_MASK) == + BTRFS_BLOCK_GROUP_DATA) + alloc->data -= found_key.offset; + else if ((flags & BTRFS_BLOCK_GROUP_TYPE_MASK) == + BTRFS_BLOCK_GROUP_METADATA) + alloc->metadata -= found_key.offset; + else if ((flags & BTRFS_BLOCK_GROUP_TYPE_MASK) == + BTRFS_BLOCK_GROUP_SYSTEM) + alloc->system -= found_key.offset; + else if ((flags & BTRFS_BLOCK_GROUP_TYPE_MASK) == + (BTRFS_BLOCK_GROUP_METADATA| + BTRFS_BLOCK_GROUP_DATA)) + alloc->mixed -= found_key.offset; } btrfs_release_path(path); key.objectid = found_key.objectid + found_key.offset;