btrfs-progs: Fix an infinite loop in btrfs_next_bg

I've run into a couple filesystems where btrfs-find-root would spin
indefinitely.

If the first cache extent start location is 0, we end up in an infinite
loop in btrfs_next_bg().  Fix it by checking for that situation, and
jumping to the next bg if necessary.

Fixes: e2e0dae9 (btrfs-progs: volume: Fix a bug causing btrfs-find-root to skip first chunk)
Signed-off-by: Justin Maggard <jmaggard@netgear.com>
Signed-off-by: David Sterba <dsterba@suse.com>
master
Justin Maggard 2017-06-09 11:09:35 -07:00 committed by David Sterba
parent d0379cc1d0
commit e2fd79c243
1 changed files with 2 additions and 0 deletions

View File

@ -1279,6 +1279,8 @@ int btrfs_next_bg(struct btrfs_fs_info *fs_info, u64 *logical,
*size = ce->size;
return 0;
}
if (!cur)
ce = next_cache_extent(ce);
}
return -ENOENT;