path: root/volumes.c
diff options
authorJustin Maggard <>2017-06-09 11:09:35 -0700
committerDavid Sterba <>2017-07-20 17:43:43 +0200
commite2fd79c243f9939851d69d369a588953a6d070f7 (patch)
tree1375309db2d9f875eae2f22d7849a4665ac33582 /volumes.c
parentd0379cc1d0a34313e7436cdc75e418515f9b03fc (diff)
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 <>
Diffstat (limited to 'volumes.c')
1 files changed, 2 insertions, 0 deletions
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;