Skip to contentSkip to conversation

btrfs-progs: Fix an infinite loop in btrfs_next_bg

PATCH In review Justin Maggard 2 participants 2 messages Jun 9, 2017 – Jul 12, 2017 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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)
---
 volumes.c | 2 ++
 1 file changed, 2 insertions(+)
volumes.c +2 -0
index b350e259..8c0c10ce 100644
@@ -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;
Signature · 1 line
2.13.0
#1 lore raw
Quoted 9 lines · Justin Maggard

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)

Applied, thanks. Do you have a minimal image for testing?