Btrfs: fix infinite loop in btrfs_shrink_device()
If relocate of block group 0 fails with ENOSPC we end up infinitely looping because key.offset -= 1 statement in that case brings us back to where we started. Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
This commit is contained in:
parent
5eb56d2520
commit
213e64da90
|
@ -2987,7 +2987,7 @@ again:
|
||||||
key.offset = (u64)-1;
|
key.offset = (u64)-1;
|
||||||
key.type = BTRFS_DEV_EXTENT_KEY;
|
key.type = BTRFS_DEV_EXTENT_KEY;
|
||||||
|
|
||||||
while (1) {
|
do {
|
||||||
ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
|
ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto done;
|
goto done;
|
||||||
|
@ -3029,8 +3029,7 @@ again:
|
||||||
goto done;
|
goto done;
|
||||||
if (ret == -ENOSPC)
|
if (ret == -ENOSPC)
|
||||||
failed++;
|
failed++;
|
||||||
key.offset -= 1;
|
} while (key.offset-- > 0);
|
||||||
}
|
|
||||||
|
|
||||||
if (failed && !retried) {
|
if (failed && !retried) {
|
||||||
failed = 0;
|
failed = 0;
|
||||||
|
|
Loading…
Reference in New Issue