btrfs-progs: Fix an infinite loop in btrfs_next_bg
authorJustin Maggard <jmaggard10@gmail.com>
Fri, 9 Jun 2017 18:09:35 +0000 (11:09 -0700)
committerDavid Sterba <dsterba@suse.com>
Thu, 20 Jul 2017 15:43:43 +0000 (17:43 +0200)
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>
volumes.c

index 79dad24..2f3943d 100644 (file)
--- 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;