From: NeilBrown Date: Wed, 1 Dec 2010 00:03:28 +0000 (+1100) Subject: Create: report failure if array cannot be started. X-Git-Tag: mdadm-3.1.5~31 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e42eb35545652f0031436e3df20651ca5889f218;p=thirdparty%2Fmdadm.git Create: report failure if array cannot be started. We weren't checking the result of writing 'active' to array_state Signed-off-by: NeilBrown --- diff --git a/Create.c b/Create.c index daf64d70..ba3b99b6 100644 --- a/Create.c +++ b/Create.c @@ -888,20 +888,27 @@ int Create(struct supertype *st, char *mddev, wait_for(chosen_name, mdfd); } else if (runstop == 1 || subdevs >= raiddisks) { if (st->ss->external) { + int err; switch(level) { case LEVEL_LINEAR: case LEVEL_MULTIPATH: case 0: - sysfs_set_str(&info, NULL, "array_state", - "active"); + err = sysfs_set_str(&info, NULL, "array_state", + "active"); need_mdmon = 0; break; default: - sysfs_set_str(&info, NULL, "array_state", - "readonly"); + err = sysfs_set_str(&info, NULL, "array_state", + "readonly"); break; } sysfs_set_safemode(&info, safe_mode_delay); + if (err) { + fprintf(stderr, Name ": failed to" + " activate array.\n"); + ioctl(mdfd, STOP_ARRAY, NULL); + goto abort; + } } else { /* param is not actually used */ mdu_param_t param; diff --git a/tests/10ddf-create b/tests/10ddf-create index 12c38208..58ca2646 100644 --- a/tests/10ddf-create +++ b/tests/10ddf-create @@ -7,6 +7,7 @@ # # add some data, tear down the array, reassemble # and make sure it is still there. +set -e mdadm -CR /dev/md/ddf0 -e ddf -n 5 $dev8 $dev9 $dev10 $dev11 $dev12 mdadm -CR r0 -l0 -n5 /dev/md/ddf0 -z 5000