* [PATCH] Btrfs: fix chunk allocate size calculation
@ 2010-03-17 20:45 Josef Bacik
2010-04-06 7:54 ` Yan, Zheng
0 siblings, 1 reply; 4+ messages in thread
From: Josef Bacik @ 2010-03-17 20:45 UTC (permalink / raw)
To: linux-btrfs
If the amount of free space left in a device is less than what we think should
be the minimum size, just ignore the minimum size and use the amount we have. I
ran into this running tests on a 600mb volume, the chunk allocator wouldn't let
me allocate the last 52mb of the disk for data because we want to have at least
64mb chunks for data. This patch fixes that problem. Thanks,
Signed-off-by: Josef Bacik <josef@redhat.com>
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 9df8e3f..1c5b5ba 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -2244,8 +2244,10 @@ again:
do_div(calc_size, stripe_len);
calc_size *= stripe_len;
}
+
/* we don't want tiny stripes */
- calc_size = max_t(u64, min_stripe_size, calc_size);
+ if (!looped)
+ calc_size = max_t(u64, min_stripe_size, calc_size);
do_div(calc_size, stripe_len);
calc_size *= stripe_len;
--
1.6.6
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] Btrfs: fix chunk allocate size calculation
2010-03-17 20:45 [PATCH] Btrfs: fix chunk allocate size calculation Josef Bacik
@ 2010-04-06 7:54 ` Yan, Zheng
2010-04-06 11:13 ` Chris Mason
0 siblings, 1 reply; 4+ messages in thread
From: Yan, Zheng @ 2010-04-06 7:54 UTC (permalink / raw)
To: Josef Bacik; +Cc: linux-btrfs
On Thu, Mar 18, 2010 at 4:45 AM, Josef Bacik <josef@redhat.com> wrote:
> If the amount of free space left in a device is less than what we thi=
nk should
> be the minimum size, just ignore the minimum size and use the amount =
we have. =A0I
> ran into this running tests on a 600mb volume, the chunk allocator wo=
uldn't let
> me allocate the last 52mb of the disk for data because we want to hav=
e at least
> 64mb chunks for data. =A0This patch fixes that problem. =A0Thanks,
>
> Signed-off-by: Josef Bacik <josef@redhat.com>
>
> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> index 9df8e3f..1c5b5ba 100644
> --- a/fs/btrfs/volumes.c
> +++ b/fs/btrfs/volumes.c
> @@ -2244,8 +2244,10 @@ again:
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0do_div(calc_size, stripe_len);
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0calc_size *=3D stripe_len;
> =A0 =A0 =A0 =A0}
> +
> =A0 =A0 =A0 =A0/* we don't want tiny stripes */
> - =A0 =A0 =A0 calc_size =3D max_t(u64, min_stripe_size, calc_size);
> + =A0 =A0 =A0 if (!looped)
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 calc_size =3D max_t(u64, min_stripe_siz=
e, calc_size);
>
> =A0 =A0 =A0 =A0do_div(calc_size, stripe_len);
> =A0 =A0 =A0 =A0calc_size *=3D stripe_len;
I encountered an Oops caused by 'calc_size =3D=3D 0'. It's likely intro=
duced
by this change. (calc_size can be zero after calling do_div)
--
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Btrfs: fix chunk allocate size calculation
2010-04-06 7:54 ` Yan, Zheng
@ 2010-04-06 11:13 ` Chris Mason
2010-04-06 14:15 ` Chris Mason
0 siblings, 1 reply; 4+ messages in thread
From: Chris Mason @ 2010-04-06 11:13 UTC (permalink / raw)
To: Yan, Zheng ; +Cc: Josef Bacik, linux-btrfs
On Tue, Apr 06, 2010 at 03:54:27PM +0800, Yan, Zheng wrote:
> On Thu, Mar 18, 2010 at 4:45 AM, Josef Bacik <josef@redhat.com> wrote=
:
> > If the amount of free space left in a device is less than what we t=
hink should
> > be the minimum size, just ignore the minimum size and use the amoun=
t we have. =A0I
> > ran into this running tests on a 600mb volume, the chunk allocator =
wouldn't let
> > me allocate the last 52mb of the disk for data because we want to h=
ave at least
> > 64mb chunks for data. =A0This patch fixes that problem. =A0Thanks,
> >
> > Signed-off-by: Josef Bacik <josef@redhat.com>
> >
> > diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> > index 9df8e3f..1c5b5ba 100644
> > --- a/fs/btrfs/volumes.c
> > +++ b/fs/btrfs/volumes.c
> > @@ -2244,8 +2244,10 @@ again:
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0do_div(calc_size, stripe_len);
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0calc_size *=3D stripe_len;
> > =A0 =A0 =A0 =A0}
> > +
> > =A0 =A0 =A0 =A0/* we don't want tiny stripes */
> > - =A0 =A0 =A0 calc_size =3D max_t(u64, min_stripe_size, calc_size);
> > + =A0 =A0 =A0 if (!looped)
> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 calc_size =3D max_t(u64, min_stripe_s=
ize, calc_size);
> >
> > =A0 =A0 =A0 =A0do_div(calc_size, stripe_len);
> > =A0 =A0 =A0 =A0calc_size *=3D stripe_len;
>=20
> I encountered an Oops caused by 'calc_size =3D=3D 0'. It's likely int=
roduced
> by this change. (calc_size can be zero after calling do_div)
Ok, thanks will fix it up.
-chris
--
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Btrfs: fix chunk allocate size calculation
2010-04-06 11:13 ` Chris Mason
@ 2010-04-06 14:15 ` Chris Mason
0 siblings, 0 replies; 4+ messages in thread
From: Chris Mason @ 2010-04-06 14:15 UTC (permalink / raw)
To: Yan, Zheng , Josef Bacik, linux-btrfs
On Tue, Apr 06, 2010 at 07:13:58AM -0400, Chris Mason wrote:
> On Tue, Apr 06, 2010 at 03:54:27PM +0800, Yan, Zheng wrote:
> > On Thu, Mar 18, 2010 at 4:45 AM, Josef Bacik <josef@redhat.com> wro=
te:
> > > If the amount of free space left in a device is less than what we=
think should
> > > be the minimum size, just ignore the minimum size and use the amo=
unt we have. =A0I
> > > ran into this running tests on a 600mb volume, the chunk allocato=
r wouldn't let
> > > me allocate the last 52mb of the disk for data because we want to=
have at least
> > > 64mb chunks for data. =A0This patch fixes that problem. =A0Thanks=
,
> > >
> > > Signed-off-by: Josef Bacik <josef@redhat.com>
> > >
> > > diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> > > index 9df8e3f..1c5b5ba 100644
> > > --- a/fs/btrfs/volumes.c
> > > +++ b/fs/btrfs/volumes.c
> > > @@ -2244,8 +2244,10 @@ again:
> > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0do_div(calc_size, stripe_len);
> > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0calc_size *=3D stripe_len;
> > > =A0 =A0 =A0 =A0}
> > > +
> > > =A0 =A0 =A0 =A0/* we don't want tiny stripes */
> > > - =A0 =A0 =A0 calc_size =3D max_t(u64, min_stripe_size, calc_size=
);
> > > + =A0 =A0 =A0 if (!looped)
> > > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 calc_size =3D max_t(u64, min_stripe=
_size, calc_size);
> > >
> > > =A0 =A0 =A0 =A0do_div(calc_size, stripe_len);
> > > =A0 =A0 =A0 =A0calc_size *=3D stripe_len;
> >=20
> > I encountered an Oops caused by 'calc_size =3D=3D 0'. It's likely i=
ntroduced
> > by this change. (calc_size can be zero after calling do_div)
Ok, anyone object to this:
=46rom 9f680ce04ea19dabbbafe01b57b61930a9b70741 Mon Sep 17 00:00:00 200=
1
=46rom: Chris Mason <chris.mason@oracle.com>
Date: Tue, 6 Apr 2010 09:37:47 -0400
Subject: [PATCH] Btrfs: make sure the chunk allocator doesn't create ze=
ro length chunks
A recent commit allowed for smaller chunks to be created, but didn't
make sure they were always bigger than a stripe. After some divides,
this led to zero length stripes.
Signed-off-by: Chris Mason <chris.mason@oracle.com>
---
fs/btrfs/volumes.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 9bf1f58..b584e9a 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -2249,6 +2249,12 @@ again:
if (!looped)
calc_size =3D max_t(u64, min_stripe_size, calc_size);
=20
+ /*
+ * we're about to do_div by the stripe_len so lets make sure
+ * we end up with something bigger than a stripe
+ */
+ calc_size =3D max_t(u64, calc_size, stripe_len * 4);
+
do_div(calc_size, stripe_len);
calc_size *=3D stripe_len;
=20
--=20
1.7.0.2
--
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-04-06 14:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-17 20:45 [PATCH] Btrfs: fix chunk allocate size calculation Josef Bacik
2010-04-06 7:54 ` Yan, Zheng
2010-04-06 11:13 ` Chris Mason
2010-04-06 14:15 ` Chris Mason
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).