On Sat, Feb 26, 2011 at 10:05:40AM +0800, Yan, Zheng wrote: > On Sat, Feb 26, 2011 at 7:43 AM, Ilya Dryomov <[email protected]> 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 <[email protected]> > > --- > > 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 [email protected] > > 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 <[email protected]> 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 <[email protected]> --- 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 [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
