btrfs-progs: improve error handling in btrfs_alloc_data_chunk
authorDavid Sterba <dsterba@suse.com>
Wed, 7 Sep 2016 13:57:41 +0000 (15:57 +0200)
committerDavid Sterba <dsterba@suse.com>
Mon, 3 Oct 2016 09:33:15 +0000 (11:33 +0200)
Signed-off-by: David Sterba <dsterba@suse.com>
volumes.c

index e022c16..b0edbac 100644 (file)
--- a/volumes.c
+++ b/volumes.c
@@ -1070,7 +1070,11 @@ int btrfs_alloc_data_chunk(struct btrfs_trans_handle *trans,
        key.objectid = BTRFS_FIRST_CHUNK_TREE_OBJECTID;
        key.type = BTRFS_CHUNK_ITEM_KEY;
        if (convert) {
-               BUG_ON(*start != round_down(*start, extent_root->sectorsize));
+               if (*start != round_down(*start, extent_root->sectorsize)) {
+                       error("DATA chunk start not sectorsize aligned: %llu",
+                                       (unsigned long long)*start);
+                       return -EINVAL;
+               }
                key.offset = *start;
                dev_offset = *start;
        } else {