NeilBrown: Improve error messages when metadata handler does not support request.

Martin F. Krafft madduck at alioth.debian.org
Wed Jan 27 02:03:35 UTC 2010


Module: mdadm
Branch: upstream
Commit: b42f577a0dbe0b232600478f4a5068b2f63a2684
URL:    http://git.debian.org/?p=pkg-mdadm/mdadm.git;a=commit;h=b42f577a0dbe0b232600478f4a5068b2f63a2684

Author: NeilBrown <neilb at suse.de>
Date:   Tue Nov 17 13:15:34 2009 +1100

Improve error messages when metadata handler does not support request.

->validate_geometry is called to validate overall parameters,
and to validate each individual device.
If it ever fails, it needs to report the reason, as common code
cannot possible know.

Signed-off-by: NeilBrown <neilb at suse.de>

---

 Create.c      |    4 ++--
 super-ddf.c   |   13 ++++++++++---
 super-intel.c |    5 ++++-
 super0.c      |   16 +++++++++++++---
 super1.c      |    5 ++++-
 5 files changed, 33 insertions(+), 10 deletions(-)

diff --git a/Create.c b/Create.c
index 1fb4043..60e53f3 100644
--- a/Create.c
+++ b/Create.c
@@ -195,7 +195,7 @@ int Create(struct supertype *st, char *mddev,
 	if (st && st->ss->external && sparedisks) {
 		fprintf(stderr,
 			Name ": This metadata type does not support "
-			"spare disks are create time\n");
+			"spare disks at create time\n");
 		return 1;
 	}
 	if (subdevs > raiddisks+sparedisks) {
@@ -332,7 +332,7 @@ int Create(struct supertype *st, char *mddev,
 						       raiddisks,
 						       chunk, size*2, dname,
 						       &freesize,
-						       verbose > 0)) {
+						       verbose >= 0)) {
 
 				fprintf(stderr,
 					Name ": %s is not suitable for "
diff --git a/super-ddf.c b/super-ddf.c
index 80df570..fe83642 100644
--- a/super-ddf.c
+++ b/super-ddf.c
@@ -2555,8 +2555,12 @@ static int validate_geometry_ddf(struct supertype *st,
 		for (i=0; ddf_level_num[i].num1 != MAXINT; i++)
 			if (ddf_level_num[i].num2 == level)
 				break;
-		if (ddf_level_num[i].num1 == MAXINT)
+		if (ddf_level_num[i].num1 == MAXINT) {
+			if (verbose)
+				fprintf(stderr, Name ": DDF does not support level %d arrays\n",
+					level);
 			return 0;
+		}
 		/* Should check layout? etc */
 
 		if (st->sb && freesize) {
@@ -2604,7 +2608,7 @@ static int validate_geometry_ddf(struct supertype *st,
 		if (verbose)
 			fprintf(stderr,
 				Name ": ddf: Cannot create this array "
-				"on device %s\n",
+				"on device %s - a container is required.\n",
 				dev);
 		return 0;
 	}
@@ -2696,8 +2700,11 @@ static int validate_geometry_ddf_bvd(struct supertype *st,
 	struct extent *e;
 	int i;
 	/* ddf/bvd supports lots of things, but not containers */
-	if (level == LEVEL_CONTAINER)
+	if (level == LEVEL_CONTAINER) {
+		if (verbose)
+			fprintf(stderr, Name ": DDF cannot create a container within an container\n");
 		return 0;
+	}
 	/* We must have the container info already read in. */
 	if (!ddf)
 		return 0;
diff --git a/super-intel.c b/super-intel.c
index 9a99d60..2e119f8 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -3704,8 +3704,11 @@ static int validate_geometry_imsm(struct supertype *st, int level, int layout,
 		case 1:
 		case 10:
 		case 5:
-			break;
+			return 0;
 		default:
+			if (verbose)
+				fprintf(stderr, Name
+					": IMSM only supports levels 0,1,5,10\n");
 			return 1;
 		}
 
diff --git a/super0.c b/super0.c
index 955e832..15b3ca2 100644
--- a/super0.c
+++ b/super0.c
@@ -1079,12 +1079,22 @@ static int validate_geometry0(struct supertype *st, int level,
 	unsigned long long ldsize;
 	int fd;
 
-	if (level == LEVEL_CONTAINER)
+	if (level == LEVEL_CONTAINER) {
+		if (verbose)
+			fprintf(stderr, Name ": 0.90 metadata does not support containers\n");
 		return 0;
-	if (raiddisks > MD_SB_DISKS)
+	}
+	if (raiddisks > MD_SB_DISKS) {
+		if (verbose)
+			fprintf(stderr, Name ": 0.90 metadata supports at most %d devices per array\n",
+				MD_SB_DISKS);
 		return 0;
-	if (size > (0x7fffffffULL<<9))
+	}
+	if (size > (0x7fffffffULL<<9)) {
+		if (verbose)
+			fprintf(stderr, Name ": 0.90 metadata supports at most 2 terrabytes per device\n");
 		return 0;
+	}
 	if (!subdev)
 		return 1;
 
diff --git a/super1.c b/super1.c
index 8678e9f..5a2df0e 100644
--- a/super1.c
+++ b/super1.c
@@ -1609,8 +1609,11 @@ static int validate_geometry1(struct supertype *st, int level,
 	unsigned long long ldsize;
 	int fd;
 
-	if (level == LEVEL_CONTAINER)
+	if (level == LEVEL_CONTAINER) {
+		if (verbose)
+			fprintf(stderr, Name ": 1.x metadata does not support containers\n");
 		return 0;
+	}
 	if (!subdev)
 		return 1;
 




More information about the pkg-mdadm-commits mailing list