diff options
author | Neil Brown <neilb@suse.de> | 2006-03-29 01:22:58 +0200 |
---|---|---|
committer | Neil Brown <neilb@suse.de> | 2006-03-29 01:22:58 +0200 |
commit | 6409687b554687b89700e7a907dc3fcbcf5171a2 (patch) | |
tree | aec99649a9c006f96ae26ef7da6578bb24092b46 | |
parent | Reduce dependance on MD_SB_DISKS (diff) | |
download | 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.c | 2 | ||||
-rw-r--r-- | Kill.c | 18 | ||||
-rw-r--r-- | mdadm.c | 2 | ||||
-rw-r--r-- | mdadm.h | 2 |
4 files changed, 15 insertions, 9 deletions
@@ -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)) { @@ -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; } } @@ -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': @@ -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, |