diff options
Diffstat (limited to 'fs')
-rw-r--r-- | fs/btrfs/volumes.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index c8a315d4b86f..c1a22178c6e8 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c | |||
@@ -4232,9 +4232,25 @@ int btrfs_num_copies(struct btrfs_fs_info *fs_info, u64 logical, u64 len) | |||
4232 | read_lock(&em_tree->lock); | 4232 | read_lock(&em_tree->lock); |
4233 | em = lookup_extent_mapping(em_tree, logical, len); | 4233 | em = lookup_extent_mapping(em_tree, logical, len); |
4234 | read_unlock(&em_tree->lock); | 4234 | read_unlock(&em_tree->lock); |
4235 | BUG_ON(!em); | ||
4236 | 4235 | ||
4237 | BUG_ON(em->start > logical || em->start + em->len < logical); | 4236 | /* |
4237 | * We could return errors for these cases, but that could get ugly and | ||
4238 | * we'd probably do the same thing which is just not do anything else | ||
4239 | * and exit, so return 1 so the callers don't try to use other copies. | ||
4240 | */ | ||
4241 | if (!em) { | ||
4242 | btrfs_emerg(fs_info, "No mapping for %Lu-%Lu\n", logical, | ||
4243 | logical+len); | ||
4244 | return 1; | ||
4245 | } | ||
4246 | |||
4247 | if (em->start > logical || em->start + em->len < logical) { | ||
4248 | btrfs_emerg(fs_info, "Invalid mapping for %Lu-%Lu, got " | ||
4249 | "%Lu-%Lu\n", logical, logical+len, em->start, | ||
4250 | em->start + em->len); | ||
4251 | return 1; | ||
4252 | } | ||
4253 | |||
4238 | map = (struct map_lookup *)em->bdev; | 4254 | map = (struct map_lookup *)em->bdev; |
4239 | if (map->type & (BTRFS_BLOCK_GROUP_DUP | BTRFS_BLOCK_GROUP_RAID1)) | 4255 | if (map->type & (BTRFS_BLOCK_GROUP_DUP | BTRFS_BLOCK_GROUP_RAID1)) |
4240 | ret = map->num_stripes; | 4256 | ret = map->num_stripes; |