On Sat, Feb 26, 2011 at 10:05:40AM +0800, Yan, Zheng wrote:
> On Sat, Feb 26, 2011 at 7:43 AM, Ilya Dryomov <idryomov@xxxxxxxxx> wrote:
> > 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;
> > Â Â Â Â}
>
> it should be if (--key.offset == (u64) -1)
>
> >
> > Â Â Â Â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
> >
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.
---
From: Ilya Dryomov <idryomov@xxxxxxxxx>
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) 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 beginning 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..cd334ae 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 == (u64)-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