From: Ilya Dryomov <idryomov@gmail.com>
To: "Yan, Zheng " <yanzheng@21cn.com>
Cc: linux-btrfs@vger.kernel.org, Chris Mason <chris.mason@oracle.com>
Subject: Re: [PATCH] Btrfs: fix infinite loop in btrfs_shrink_device()
Date: Sat, 26 Feb 2011 16:15:49 +0200 [thread overview]
Message-ID: <20110226141549.GA2550@kwango.lan.net> (raw)
In-Reply-To: <AANLkTik1J7q10fLp1js29_ge0HT0-=Bg9VOj6zYN-svW@mail.gmail.com>
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@gmail.com> wr=
ote:
> > 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 -=3D 1 statement then unconditional=
ly
> > brings us back to the beginnig of the loop (key.offset =3D=3D (u64)=
-1).
> >
> > 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;
> > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (ret =3D=3D=
-ENOSPC)
> > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
=C2=A0 =C2=A0failed++;
> > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 key.offset -=3D =
1;
> > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (--key.offset=
=3D=3D -1)
> > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 break;
> > =C2=A0 =C2=A0 =C2=A0 =C2=A0}
>=20
> it should be if (--key.offset =3D=3D (u64) -1)
>=20
> >
> > =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
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at =C2=A0http://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.
---
=46rom: Ilya Dryomov <idryomov@gmail.com>
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
next prev parent reply other threads:[~2011-02-26 14:15 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-25 23:43 [PATCH] Btrfs: fix infinite loop in btrfs_shrink_device() Ilya Dryomov
2011-02-26 2:05 ` Yan, Zheng
2011-02-26 14:15 ` Ilya Dryomov [this message]
-- strict thread matches above, loose matches on Subject: below --
2012-03-27 15:14 Ilya Dryomov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110226141549.GA2550@kwango.lan.net \
--to=idryomov@gmail.com \
--cc=chris.mason@oracle.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=yanzheng@21cn.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.