]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Create: improve messages from validate_geometry.
authorNeilBrown <neilb@suse.de>
Wed, 21 Sep 2011 04:39:01 +0000 (14:39 +1000)
committerNeilBrown <neilb@suse.de>
Wed, 21 Sep 2011 04:39:01 +0000 (14:39 +1000)
When validate_geometry finds that we haven't committed to
a metadata yet and that the subdev is a member of 'our'
container, it needs to report any errors it finds as Create()
cannot report them effectively.

So make a slight change to the semantics of the 'verbose' flag
and allow validate_geometry to report if it printed any error
messages.

Signed-off-by: NeilBrown <neilb@suse.de>
Create.c
mdadm.h
super-intel.c

index 8d88aa12be5d6b0bae5b495073982967f99eb0da..79564c544ca04d3fd6fac9b24ac0f279f51559bb 100644 (file)
--- a/Create.c
+++ b/Create.c
@@ -332,15 +332,25 @@ int Create(struct supertype *st, char *mddev,
                        char *name = "default";
                        for(i=0; !st && superlist[i]; i++) {
                                st = superlist[i]->match_metadata_desc(name);
+                               if (!st)
+                                       continue;
                                if (do_default_layout)
                                        layout = default_layout(st, level, verbose);
-                               if (st && !st->ss->validate_geometry
-                                               (st, level, layout, raiddisks,
-                                                &chunk, size*2, dname, &freesize,
-                                                verbose > 0)) {
+                               switch (st->ss->validate_geometry(
+                                               st, level, layout, raiddisks,
+                                               &chunk, size*2, dname, &freesize,
+                                               verbose > 0)) {
+                               case -1: /* Not valid, message printed, and not
+                                         * worth checking any further */
+                                       exit(2);
+                                       break;
+                               case 0: /* Geometry not valid */
                                        free(st);
                                        st = NULL;
                                        chunk = do_default_chunk ? UnSet : chunk;
+                                       break;
+                               case 1: /* All happy */
+                                       break;
                                }
                        }
 
diff --git a/mdadm.h b/mdadm.h
index bd3063baf4d25d110d89f352a975525fe82ad35e..8dd37d9b4c6c8e54f6ea1c07582c29c62a2158a9 100644 (file)
--- a/mdadm.h
+++ b/mdadm.h
@@ -702,6 +702,12 @@ extern struct superswitch {
         * inter-device dependencies, it should record sufficient details
         * so these can be validated.
         * Both 'size' and '*freesize' are in sectors.  chunk is KiB.
+        * Return value is:
+        *  1: everything is OK
+        *  0: not OK for some reason - if 'verbose', then error was reported.
+        * -1: st->sb was NULL, 'subdev' is a member of a container of this
+        *     types, but array is not acceptable for some reason
+        *     message was reported even if verbose is 0.
         */
        int (*validate_geometry)(struct supertype *st, int level, int layout,
                                 int raiddisks,
index e57d18fe2d5b15c307fda3460fa58fe0fad564b4..e9d9af80343a3b7d4fb3d31632c9839d021504a2 100644 (file)
@@ -5369,7 +5369,8 @@ static int validate_geometry_imsm(struct supertype *st, int level, int layout,
                        return validate_geometry_imsm_volume(st, level, layout,
                                                             raiddisks, chunk,
                                                             size, dev,
-                                                            freesize, verbose);
+                                                            freesize, 1)
+                               ? 1 : -1;
                }
        }