btrfs-progs: Fix an infinite loop in btrfs_next_bg
diff mbox

Message ID 20170609180935.9554-1-jmaggard@netgear.com
State New
Headers show

Commit Message

Justin Maggard June 9, 2017, 6:09 p.m. UTC
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>
---
 volumes.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

David Sterba July 12, 2017, 10:34 p.m. UTC | #1
On Fri, Jun 09, 2017 at 11:09:35AM -0700, Justin Maggard wrote:
> 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>

Applied, thanks.  Do you have a minimal image for testing?
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch
diff mbox

diff --git a/volumes.c b/volumes.c
index b350e259..8c0c10ce 100644
--- a/volumes.c
+++ b/volumes.c
@@ -1278,6 +1278,8 @@  int btrfs_next_bg(struct btrfs_mapping_tree *map_tree, u64 *logical,
 			*size = ce->size;
 			return 0;
 		}
+		if (!cur)
+			ce = next_cache_extent(ce);
 	}
 
 	return -ENOENT;