[PATCH] Btrfs: fix infinite loop in btrfs_shrink_device()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In case of an ENOSPC error from btrfs_relocate_chunk() (line 2202) while
relocating a block group with offset 0 we end up endlessly looping.
This happens because key.offset -= 1 statement then unconditionally
brings us back to the beginnig of the loop (key.offset == (u64)-1).

Signed-off-by: Ilya Dryomov <idryomov@xxxxxxxxx>
---
 fs/btrfs/volumes.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index dd13eb8..0cb94ce 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -2212,7 +2212,8 @@ again:
 			goto done;
 		if (ret == -ENOSPC)
 			failed++;
-		key.offset -= 1;
+		if (--key.offset == -1)
+			break;
 	}
 
 	if (failed && !retried) {
-- 
1.7.2.3

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux