Linux RAID subsystem development
 help / color / mirror / Atom feed
* [PATCH] Create.c: check if freesize is equal 0
@ 2012-11-16 16:24 Lukasz Dorau
  2012-11-18 23:56 ` NeilBrown
  0 siblings, 1 reply; 2+ messages in thread
From: Lukasz Dorau @ 2012-11-16 16:24 UTC (permalink / raw)
  To: neilb; +Cc: linux-raid, maciej.patelczyk

"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@intel.com>
---
 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)


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Create.c: check if freesize is equal 0
  2012-11-16 16:24 [PATCH] Create.c: check if freesize is equal 0 Lukasz Dorau
@ 2012-11-18 23:56 ` NeilBrown
  0 siblings, 0 replies; 2+ messages in thread
From: NeilBrown @ 2012-11-18 23:56 UTC (permalink / raw)
  To: Lukasz Dorau; +Cc: linux-raid, maciej.patelczyk

[-- Attachment #1: Type: text/plain, Size: 1826 bytes --]

On Fri, 16 Nov 2012 17:24:36 +0100 Lukasz Dorau <lukasz.dorau@intel.com>
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@intel.com>
> ---
>  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@intel.com>
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@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>

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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-11-18 23:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-16 16:24 [PATCH] Create.c: check if freesize is equal 0 Lukasz Dorau
2012-11-18 23:56 ` NeilBrown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox