aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs
diff options
context:
space:
mode:
authorIlya Dryomov <idryomov@gmail.com>2012-03-27 10:09:18 -0400
committerIlya Dryomov <idryomov@gmail.com>2012-03-27 10:09:18 -0400
commit213e64da90d14537cd63f7090d6c4d1fcc75d9f8 (patch)
treec7603bcc554d033ef0521a0a7898c924930721e7 /fs/btrfs
parent5eb56d2520fe16f00756ccdf8eebc277398e0f44 (diff)
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>
Diffstat (limited to 'fs/btrfs')
-rw-r--r--fs/btrfs/volumes.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index bcc0acda8691..be2d4e0e6cfb 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -2987,7 +2987,7 @@ again:
2987 key.offset = (u64)-1; 2987 key.offset = (u64)-1;
2988 key.type = BTRFS_DEV_EXTENT_KEY; 2988 key.type = BTRFS_DEV_EXTENT_KEY;
2989 2989
2990 while (1) { 2990 do {
2991 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); 2991 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
2992 if (ret < 0) 2992 if (ret < 0)
2993 goto done; 2993 goto done;
@@ -3029,8 +3029,7 @@ again:
3029 goto done; 3029 goto done;
3030 if (ret == -ENOSPC) 3030 if (ret == -ENOSPC)
3031 failed++; 3031 failed++;
3032 key.offset -= 1; 3032 } while (key.offset-- > 0);
3033 }
3034 3033
3035 if (failed && !retried) { 3034 if (failed && !retried) {
3036 failed = 0; 3035 failed = 0;