summaryrefslogtreecommitdiff
path: root/mkfs.c
diff options
context:
space:
mode:
authorDimitri John Ledkov <xnox@ubuntu.com>2016-08-11 12:45:00 +0100
committerDimitri John Ledkov <xnox@ubuntu.com>2016-08-11 12:45:00 +0100
commitffd998be34a1a3d208106d051e85058ff9ac9667 (patch)
tree3f93a4a7362dcbdbadf5086e9404dc58ea22200a /mkfs.c
parent3d69435ee3292b4b1db2d61c4784789d75883821 (diff)
Imported Upstream version 4.7
Diffstat (limited to 'mkfs.c')
-rw-r--r--mkfs.c31
1 files changed, 27 insertions, 4 deletions
diff --git a/mkfs.c b/mkfs.c
index 697bdc2e..f30f0574 100644
--- a/mkfs.c
+++ b/mkfs.c
@@ -1318,10 +1318,27 @@ 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)) {
+ u64 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;
@@ -1619,8 +1636,11 @@ int main(int argc, char **argv)
strerror(errno));
exit(1);
}
- ret = btrfs_prepare_device(fd, file, zero_end, &dev_block_count,
- block_count, discard);
+ ret = btrfs_prepare_device(fd, file, &dev_block_count,
+ block_count,
+ (zero_end ? PREP_DEVICE_ZERO_END : 0) |
+ (discard ? PREP_DEVICE_DISCARD : 0) |
+ (verbose ? PREP_DEVICE_VERBOSE : 0));
if (ret) {
close(fd);
exit(1);
@@ -1750,8 +1770,11 @@ int main(int argc, char **argv)
close(fd);
continue;
}
- ret = btrfs_prepare_device(fd, file, zero_end, &dev_block_count,
- block_count, discard);
+ ret = btrfs_prepare_device(fd, file, &dev_block_count,
+ block_count,
+ (verbose ? PREP_DEVICE_VERBOSE : 0) |
+ (zero_end ? PREP_DEVICE_ZERO_END : 0) |
+ (discard ? PREP_DEVICE_DISCARD : 0));
if (ret) {
close(fd);
exit(1);