Thread (3 messages) 3 messages, 2 authors, 2011-02-26

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

From: Ilya Dryomov <idryomov@gmail.com>
Date: 2011-02-26 14:15:49
Subsystem: btrfs file system, filesystems (vfs and infrastructure), the rest · Maintainers: Chris Mason, David Sterba, Alexander Viro, Christian Brauner, Linus Torvalds

On Sat, Feb 26, 2011 at 10:05:40AM +0800, Yan, Zheng  wrote:
On Sat, Feb 26, 2011 at 7:43 AM, Ilya Dryomov [off-list ref] wr=
ote:
quoted
In case of an ENOSPC error from btrfs_relocate_chunk() (line 2202) =
while
quoted
relocating a block group with offset 0 we end up endlessly looping.
This happens because key.offset -=3D 1 statement then unconditional=
ly
quoted
brings us back to the beginnig of the loop (key.offset =3D=3D (u64)=
-1).
quoted
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
---
=C2=A0fs/btrfs/volumes.c | =C2=A0 =C2=A03 ++-
=C2=A01 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:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
 =C2=A0 =C2=A0goto done;
quoted
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (ret =3D=3D=
 -ENOSPC)
quoted
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
 =C2=A0 =C2=A0failed++;
quoted
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 key.offset -=3D =
1;
quoted
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (--key.offset=
 =3D=3D -1)
quoted
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 break;
quoted
=C2=A0 =C2=A0 =C2=A0 =C2=A0}
=20
it should be  if (--key.offset =3D=3D (u64) -1)
=20
quoted
=C2=A0 =C2=A0 =C2=A0 =C2=A0if (failed && !retried) {
--
1.7.2.3

--
To unsubscribe from this list: send the line "unsubscribe linux-btr=
fs" in
quoted
the body of a message to majordomo@vger.kernel.org
More majordomo info at =C2=A0http://vger.kernel.org/majordomo-info.=
html
quoted
I wonder how I managed to screw that up, I got it right in the commit
description..  Sorry for the noise, here is an updated version.

---

=46rom: Ilya Dryomov [off-list ref]
Date: Sat, 26 Feb 2011 01:29:25 +0200
Subject: [PATCH] Btrfs: fix infinite loop in btrfs_shrink_device()

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

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
---
 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..cd334ae 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -2212,7 +2212,8 @@ again:
 			goto done;
 		if (ret =3D=3D -ENOSPC)
 			failed++;
-		key.offset -=3D 1;
+		if (--key.offset =3D=3D (u64)-1)
+			break;
 	}
=20
 	if (failed && !retried) {
--=20
1.7.2.3

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" =
in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help