linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] mdadm:checking level once mode has been set
@ 2017-03-08  7:48 Zhilong Liu
  2017-03-08  7:50 ` [PATCH 1/4] mdadm:bitmap cannot be set twice Zhilong Liu
                   ` (4 more replies)
  0 siblings, 5 replies; 15+ messages in thread
From: Zhilong Liu @ 2017-03-08  7:48 UTC (permalink / raw)
  To: Jes.Sorensen; +Cc: linux-raid, Zhilong Liu

mdadm: it would be better to check --level ealier,
because it would fall to different prompt if user
forgets to specify the --level. such as:
./mdadm -CR /dev/md0 -b internal -n2 -x1 /dev/loop[0-2]

Signed-off-by: Zhilong Liu <zlliu@suse.com>

diff --git a/Create.c b/Create.c
index 9a951b0..beec29f 100644
--- a/Create.c
+++ b/Create.c
@@ -125,10 +125,6 @@ int Create(struct supertype *st, char *mddev,
 	memset(&info, 0, sizeof(info));
 	if (s->level == UnSet && st && st->ss->default_geometry)
 		st->ss->default_geometry(st, &s->level, NULL, NULL);
-	if (s->level == UnSet) {
-		pr_err("a RAID level is needed to create an array.\n");
-		return 1;
-	}
 	if (s->raiddisks < 4 && s->level == 6) {
 		pr_err("at least 4 raid-devices needed for level 6\n");
 		return 1;
diff --git a/mdadm.c b/mdadm.c
index 19a06db..ad24bdf 100644
--- a/mdadm.c
+++ b/mdadm.c
@@ -350,6 +350,12 @@ int main(int argc, char *argv[])
 				pr_err("Must give -a/--add for devices to add: %s\n", optarg);
 				exit(2);
 			}
+			if (devs_found > 0 && s.level == UnSet && !devmode) {
+				if (mode == CREATE || mode == BUILD) {
+					pr_err("a RAID level is needed to create or build an array.\n");
+					exit(2);
+				}
+			}
 			dv = xmalloc(sizeof(*dv));
 			dv->devname = optarg;
 			dv->disposition = devmode;
-- 
2.10.2


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

end of thread, other threads:[~2017-03-17 19:30 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-08  7:48 [PATCH 0/4] mdadm:checking level once mode has been set Zhilong Liu
2017-03-08  7:50 ` [PATCH 1/4] mdadm:bitmap cannot be set twice Zhilong Liu
2017-03-08  8:07   ` [PATCH 5/5] mdadm:checking level once mode has been set Zhilong Liu
2017-03-08  7:51 ` [PATCH 2/4] mdadm:external bitmap only supports ext filesystem Zhilong Liu
2017-03-12 14:48   ` Liu Zhilong
2017-03-13  8:16   ` zhilong
2017-03-08  7:52 ` [PATCH 3/4] mdadm:triggers core dump when stat2devnm return NULL Zhilong Liu
2017-03-12 23:00   ` NeilBrown
2017-03-13  5:34     ` zhilong
2017-03-13  7:01     ` [PATCH 3/4 v1] " Zhilong Liu
2017-03-12 22:54 ` [PATCH 0/4] mdadm:checking level once mode has been set NeilBrown
2017-03-13  3:22   ` zhilong
2017-03-13  3:48     ` NeilBrown
2017-03-13  5:16       ` zhilong
2017-03-17 19:30 ` jes.sorensen

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).