@@ -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;
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(+)