On Fri, 16 Nov 2012 17:24:36 +0100 Lukasz Dorau <lukasz.dorau@xxxxxxxxx> wrote: > "freesize" can be equal 0 after rounding to the chunk's size. > Creating should be aborted in such case. > > Signed-off-by: Lukasz Dorau <lukasz.dorau@xxxxxxxxx> > --- > Create.c | 5 +++++ > 1 files changed, 5 insertions(+), 0 deletions(-) > > diff --git a/Create.c b/Create.c > index afcf1a5..f5b7194 100644 > --- a/Create.c > +++ b/Create.c > @@ -399,6 +399,11 @@ int Create(struct supertype *st, char *mddev, > if (s->chunk && s->chunk != UnSet) { > /* round to chunk size */ > freesize = freesize & ~(s->chunk-1); > + if (!freesize) { > + pr_err("no free space left on %s\n", dname); > + fail = 1; > + continue; > + } > if (do_default_chunk) { > /* default chunk was just set */ > if (c->verbose > 0) I think it would be best to have this test even if chunk is not set. So I've applied the following. Thanks, NeilBrown From 3339b154fdc9dcc70b9be1c5ab203d3d011f5434 Mon Sep 17 00:00:00 2001 From: Lukasz Dorau <lukasz.dorau@xxxxxxxxx> Date: Fri, 16 Nov 2012 17:24:36 +0100 Subject: [PATCH] Create.c: check if freesize is equal 0 "freesize" can be equal 0, particularly after rounding to the chunk's size. Creating should be aborted in such case. Signed-off-by: Lukasz Dorau <lukasz.dorau@xxxxxxxxx> Signed-off-by: NeilBrown <neilb@xxxxxxx> diff --git a/Create.c b/Create.c index 79fdec8..a4aab41 100644 --- a/Create.c +++ b/Create.c @@ -408,6 +408,11 @@ int Create(struct supertype *st, char *mddev, do_default_chunk = 0; } } + if (!freesize) { + pr_err("no free space left on %s\n", dname); + fail = 1; + continue; + } if (s->size && freesize < s->size) { pr_err("%s is smaller than given size."
Attachment:
signature.asc
Description: PGP signature