@@ -7772,13 +7772,14 @@ static u64 calc_stripe_length(u64 type, u64 chunk_len, int num_stripes)
}
static int verify_one_dev_extent(struct btrfs_fs_info *fs_info,
- u64 chunk_offset, u64 devid,
- u64 physical_offset, u64 physical_len)
+ struct btrfs_device *dev,
+ u64 chunk_offset, u64 physical_offset,
+ u64 physical_len)
{
struct extent_map_tree *em_tree = &fs_info->mapping_tree.map_tree;
struct extent_map *em;
struct map_lookup *map;
- struct btrfs_device *dev;
+ u64 devid = dev->devid;
u64 stripe_len;
bool found = false;
int ret = 0;
@@ -7830,15 +7831,8 @@ static int verify_one_dev_extent(struct btrfs_fs_info *fs_info,
}
/* Make sure no dev extent is beyond device bondary */
- dev = btrfs_find_device(fs_info->fs_devices, devid, NULL, NULL, true);
- if (!dev) {
- btrfs_err(fs_info, "failed to find devid %llu", devid);
- ret = -EUCLEAN;
- goto out;
- }
-
- /* It's possible this device is a dummy for seed device */
if (dev->disk_total_bytes == 0) {
+ /* This device is a dummy for seed device */
dev = btrfs_find_device(fs_info->fs_devices->seed, devid, NULL,
NULL, false);
if (!dev) {
@@ -7898,6 +7892,7 @@ int btrfs_verify_dev_extents(struct btrfs_fs_info *fs_info)
{
struct btrfs_path *path;
struct btrfs_root *root = fs_info->dev_root;
+ struct btrfs_device *device = NULL;
struct btrfs_key key;
u64 prev_devid = 0;
u64 prev_dev_ext_end = 0;
@@ -7941,6 +7936,17 @@ int btrfs_verify_dev_extents(struct btrfs_fs_info *fs_info)
devid = key.objectid;
physical_offset = key.offset;
+ if (!device || devid != device->devid) {
+ device = btrfs_find_device(fs_info->fs_devices, devid,
+ NULL, NULL, true);
+ if (!device) {
+ btrfs_err(fs_info, "failed to find devid %llu",
+ devid);
+ ret = -EUCLEAN;
+ goto out;
+ }
+ }
+
dext = btrfs_item_ptr(leaf, slot, struct btrfs_dev_extent);
chunk_offset = btrfs_dev_extent_chunk_offset(leaf, dext);
physical_len = btrfs_dev_extent_length(leaf, dext);
@@ -7954,7 +7960,7 @@ int btrfs_verify_dev_extents(struct btrfs_fs_info *fs_info)
goto out;
}
- ret = verify_one_dev_extent(fs_info, chunk_offset, devid,
+ ret = verify_one_dev_extent(fs_info, device, chunk_offset,
physical_offset, physical_len);
if (ret < 0)
goto out;