提交 213e64da 编写于 作者: I Ilya Dryomov

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: NIlya Dryomov <idryomov@gmail.com>
上级 5eb56d25
......@@ -2987,7 +2987,7 @@ int btrfs_shrink_device(struct btrfs_device *device, u64 new_size)
key.offset = (u64)-1;
key.type = BTRFS_DEV_EXTENT_KEY;
while (1) {
do {
ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
if (ret < 0)
goto done;
......@@ -3029,8 +3029,7 @@ int btrfs_shrink_device(struct btrfs_device *device, u64 new_size)
goto done;
if (ret == -ENOSPC)
failed++;
key.offset -= 1;
}
} while (key.offset-- > 0);
if (failed && !retried) {
failed = 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册