aboutsummaryrefslogtreecommitdiffstats
path: root/volumes.c
diff options
context:
space:
mode:
authorJosef Bacik <jbacik@fb.com>2014-09-25 16:10:48 -0400
committerDavid Sterba <dsterba@suse.cz>2014-10-01 16:34:45 +0200
commitf6e4243fa8eb102f8fb564800a2bc87d5c110aa2 (patch)
treeea72094327c83ed73fdd511d876e6367cf7d8b89 /volumes.c
parent3ae0209d94776faaa139fcebfafa22fd7840b9f4 (diff)
downloadbtrfs-progs-f6e4243fa8eb102f8fb564800a2bc87d5c110aa2.tar.gz
btrfs-progs-f6e4243fa8eb102f8fb564800a2bc87d5c110aa2.tar.xz
btrfs-progs-f6e4243fa8eb102f8fb564800a2bc87d5c110aa2.zip
Btrfs-progs: don't assert when we have an invalid mapping
Asserting is no fun, we may be able to recover from this error in certain cases (like btrfs-image and btrfsck). Just do what the kernel does and spit out an error and return that there is only 1 copy. Thanks, Signed-off-by: Josef Bacik <jbacik@fb.com> Signed-off-by: David Sterba <dsterba@suse.cz>
Diffstat (limited to 'volumes.c')
-rw-r--r--volumes.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/volumes.c b/volumes.c
index 388c94e..009ce78 100644
--- a/volumes.c
+++ b/volumes.c
@@ -1136,8 +1136,20 @@ int btrfs_num_copies(struct btrfs_mapping_tree *map_tree, u64 logical, u64 len)
int ret;
ce = search_cache_extent(&map_tree->cache_tree, logical);
- BUG_ON(!ce);
- BUG_ON(ce->start > logical || ce->start + ce->size < logical);
+ if (!ce) {
+ fprintf(stderr, "No mapping for %llu-%llu\n",
+ (unsigned long long)logical,
+ (unsigned long long)logical+len);
+ return 1;
+ }
+ if (ce->start > logical || ce->start + ce->size < logical) {
+ fprintf(stderr, "Invalid mapping for %llu-%llu, got "
+ "%llu-%llu\n", (unsigned long long)logical,
+ (unsigned long long)logical+len,
+ (unsigned long long)ce->start,
+ (unsigned long long)ce->start + ce->size);
+ return 1;
+ }
map = container_of(ce, struct map_lookup, ce);
if (map->type & (BTRFS_BLOCK_GROUP_DUP | BTRFS_BLOCK_GROUP_RAID1))