Btrfs-progs: fix infinite loop in find_free_extent

If the found %ins is crossing a stripe len, ie. BTRFS_STRIPE_LEN, we'd
search again with a stripe-aligned %search_start.  The current code
calculates %search_start by adding a wrong offset, in order to fix it, the
start position of the block group should be taken, otherwise, it'll end up
with looking at the same block group forever.

Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
master
Liu Bo 2017-06-26 11:34:41 -06:00 committed by David Sterba
parent 3987fb6f07
commit d0379cc1d0
1 changed files with 3 additions and 2 deletions

View File

@ -2611,8 +2611,9 @@ check_failed:
goto no_bg_cache;
bg_offset = ins->objectid - bg_cache->key.objectid;
search_start = round_up(bg_offset + num_bytes,
BTRFS_STRIPE_LEN) + bg_offset;
search_start = round_up(
bg_offset + num_bytes, BTRFS_STRIPE_LEN) +
bg_cache->key.objectid;
goto new_group;
}
no_bg_cache: