summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeil Brown <neilb@suse.de>2006-03-28 23:22:58 +0000
committerNeil Brown <neilb@suse.de>2006-03-28 23:22:58 +0000
commit6409687b554687b89700e7a907dc3fcbcf5171a2 (patch)
treeaec99649a9c006f96ae26ef7da6578bb24092b46
parente27d562bcc3936d8988a46943881e2641d3d9036 (diff)
downloadmdadm-6409687b554687b89700e7a907dc3fcbcf5171a2.tar.gz
mdadm-6409687b554687b89700e7a907dc3fcbcf5171a2.tar.xz
mdadm-6409687b554687b89700e7a907dc3fcbcf5171a2.zip
Kill old superblocks on create.
Make sure old-version superblocks are not around to confuse anything when a new array is created. Signed-off-by: Neil Brown <neilb@suse.de>
-rw-r--r--Create.c2
-rw-r--r--Kill.c18
-rw-r--r--mdadm.c2
-rw-r--r--mdadm.h2
4 files changed, 15 insertions, 9 deletions
diff --git a/Create.c b/Create.c
index 71bab18..df6d850 100644
--- a/Create.c
+++ b/Create.c
@@ -502,6 +502,8 @@ int Create(struct supertype *st, char *mddev, int mdfd,
break;
case 2:
if (disk.state == 1) break;
+ Kill(dv->devname, 0, 1); /* Just be sure it is clean */
+ Kill(dv->devname, 0, 1); /* and again, there could be two superblocks */
st->ss->write_init_super(st, super, &disk, dv->devname);
if (ioctl(mdfd, ADD_NEW_DISK, &disk)) {
diff --git a/Kill.c b/Kill.c
index 95ab15c..2f28b99 100644
--- a/Kill.c
+++ b/Kill.c
@@ -34,7 +34,7 @@
#include "md_u.h"
#include "md_p.h"
-int Kill(char *dev, int force)
+int Kill(char *dev, int force, int quiet)
{
/*
* Nothing fancy about Kill. It just zeroes out a superblock
@@ -47,13 +47,15 @@ int Kill(char *dev, int force)
fd = open(dev, O_RDWR|O_EXCL);
if (fd < 0) {
- fprintf(stderr, Name ": Couldn't open %s for write - not zeroing\n",
- dev);
+ if (!quiet)
+ fprintf(stderr, Name ": Couldn't open %s for write - not zeroing\n",
+ dev);
return 1;
}
st = guess_super(fd);
if (st == NULL) {
- fprintf(stderr, Name ": Unrecognised md component device - %s\n", dev);
+ if (!quiet)
+ fprintf(stderr, Name ": Unrecognised md component device - %s\n", dev);
return 1;
}
rv = st->ss->load_super(st, fd, &super, dev);
@@ -65,11 +67,13 @@ int Kill(char *dev, int force)
free(super);
st->ss->init_super(st, &super, &info, 0, "");
if (st->ss->store_super(st, fd, super)) {
- fprintf(stderr, Name ": Could not zero superblock on %s\n",
- dev);
+ if (!quiet)
+ fprintf(stderr, Name ": Could not zero superblock on %s\n",
+ dev);
rv = 1;
} else if (rv) {
- fprintf(stderr, Name ": superblock zeroed anyway\n");
+ if (!quiet)
+ fprintf(stderr, Name ": superblock zeroed anyway\n");
rv = 0;
}
}
diff --git a/mdadm.c b/mdadm.c
index b32158e..6a5fac3 100644
--- a/mdadm.c
+++ b/mdadm.c
@@ -1124,7 +1124,7 @@ int main(int argc, char *argv[])
case 'D':
rv |= Detail(dv->devname, brief?1+verbose:0, test); continue;
case 'K': /* Zero superblock */
- rv |= Kill(dv->devname, force); continue;
+ rv |= Kill(dv->devname, force, quiet); continue;
case 'Q':
rv |= Query(dv->devname); continue;
case 'X':
diff --git a/mdadm.h b/mdadm.h
index a9ae698..b16c75a 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -346,7 +346,7 @@ extern int Monitor(mddev_dev_t devlist,
int period, int daemonise, int scan, int oneshot,
int dosyslog, char *config, int test, char *pidfile);
-extern int Kill(char *dev, int force);
+extern int Kill(char *dev, int force, int quiet);
extern int CreateBitmap(char *filename, int force, char uuid[16],
unsigned long chunksize, unsigned long daemon_sleep,