From e2fd79c243f9939851d69d369a588953a6d070f7 Mon Sep 17 00:00:00 2001 From: Justin Maggard Date: Fri, 9 Jun 2017 11:09:35 -0700 Subject: 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 Signed-off-by: David Sterba --- volumes.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'volumes.c') diff --git a/volumes.c b/volumes.c index 79dad244..2f3943dc 100644 --- a/volumes.c +++ b/volumes.c @@ -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; -- cgit v1.2.3