diff mbox

btrfs-progs: mkfs: fix allocation information output of block group types

Message ID 20160701052625.7748-1-wangxg.fnst@cn.fujitsu.com (mailing list archive)
State Accepted
Headers show

Commit Message

Xiaoguang Wang July 1, 2016, 5:26 a.m. UTC
When cleanup_temp_chunks() removes block groups, it forgot to update
mkfs_allocation accordingly, fix this.

Signed-off-by: Wang Xiaoguang <wangxg.fnst@cn.fujitsu.com>
---
 mkfs.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

Comments

David Sterba July 4, 2016, 12:01 p.m. UTC | #1
On Fri, Jul 01, 2016 at 01:26:25PM +0800, Wang Xiaoguang wrote:
> When cleanup_temp_chunks() removes block groups, it forgot to update
> mkfs_allocation accordingly, fix this.
> 
> Signed-off-by: Wang Xiaoguang <wangxg.fnst@cn.fujitsu.com>

Applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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;