summaryrefslogtreecommitdiff
path: root/btrfs-convert.c
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2016-09-06 14:07:25 +0200
committerDavid Sterba <dsterba@suse.com>2016-09-21 14:12:38 +0200
commit93a34924e134500b4b770168c366e75903315b9e (patch)
treecc32a2536274bd848ab609a6e8e5eb815170384a /btrfs-convert.c
parent030fa48b55583a1bfd2334584edc13945b56c8db (diff)
btrfs-progs: convert: improve error handling in create_image_file_range
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'btrfs-convert.c')
-rw-r--r--btrfs-convert.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/btrfs-convert.c b/btrfs-convert.c
index 5175f1f7..6a7ea5cd 100644
--- a/btrfs-convert.c
+++ b/btrfs-convert.c
@@ -424,8 +424,16 @@ static int create_image_file_range(struct btrfs_trans_handle *trans,
int i;
int ret;
- BUG_ON(bytenr != round_down(bytenr, root->sectorsize));
- BUG_ON(len != round_down(len, root->sectorsize));
+ if (bytenr != round_down(bytenr, root->sectorsize)) {
+ error("bytenr not sectorsize aligned: %llu",
+ (unsigned long long)bytenr);
+ return -EINVAL;
+ }
+ if (len != round_down(len, root->sectorsize)) {
+ error("length not sectorsize aligned: %llu",
+ (unsigned long long)len);
+ return -EINVAL;
+ }
len = min_t(u64, len, BTRFS_MAX_EXTENT_SIZE);
/*
@@ -514,7 +522,11 @@ static int create_image_file_range(struct btrfs_trans_handle *trans,
bg_cache->key.offset - bytenr);
}
- BUG_ON(len != round_down(len, root->sectorsize));
+ if (len != round_down(len, root->sectorsize)) {
+ error("remaining length not sectorsize aligned: %llu",
+ (unsigned long long)len);
+ return -EINVAL;
+ }
ret = btrfs_record_file_extent(trans, root, ino, inode, bytenr,
disk_bytenr, len);
if (ret < 0)