diff options
author | David Sterba <dsterba@suse.com> | 2016-09-06 13:52:09 +0200 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2016-09-21 14:12:38 +0200 |
commit | 030fa48b55583a1bfd2334584edc13945b56c8db (patch) | |
tree | 1527cae0cdbe52bc13ec1a064dc3b6b16a620f34 | |
parent | b83e93e65df9e94b15a768ddb19c2526d5095105 (diff) |
btrfs-progs: mkfs: handle block ordering errors in make_btrfs
Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r-- | utils.c | 17 |
1 files changed, 15 insertions, 2 deletions
@@ -1219,8 +1219,21 @@ int make_btrfs(int fd, struct btrfs_mkfs_config *cfg, if (!skinny_metadata) item_size += sizeof(struct btrfs_tree_block_info); - BUG_ON(cfg->blocks[i] < first_free); - BUG_ON(cfg->blocks[i] < cfg->blocks[i - 1]); + if (cfg->blocks[i] < first_free) { + error("block[%d] below first free: %llu < %llu", + i, (unsigned long long)cfg->blocks[i], + (unsigned long long)first_free); + ret = -EINVAL; + goto out; + } + if (cfg->blocks[i] < cfg->blocks[i - 1]) { + error("blocks %d and %d in reverse order: %llu < %llu", + i, i - 1, + (unsigned long long)cfg->blocks[i], + (unsigned long long)cfg->blocks[i - 1]); + ret = -EINVAL; + goto out; + } /* create extent item */ itemoff -= item_size; |