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>
This commit is contained in:
parent
e27d562bcc
commit
6409687b55
2
Create.c
2
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)) {
|
||||
|
|
6
Kill.c
6
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,12 +47,14 @@ int Kill(char *dev, int force)
|
|||
|
||||
fd = open(dev, O_RDWR|O_EXCL);
|
||||
if (fd < 0) {
|
||||
if (!quiet)
|
||||
fprintf(stderr, Name ": Couldn't open %s for write - not zeroing\n",
|
||||
dev);
|
||||
return 1;
|
||||
}
|
||||
st = guess_super(fd);
|
||||
if (st == NULL) {
|
||||
if (!quiet)
|
||||
fprintf(stderr, Name ": Unrecognised md component device - %s\n", dev);
|
||||
return 1;
|
||||
}
|
||||
|
@ -65,10 +67,12 @@ int Kill(char *dev, int force)
|
|||
free(super);
|
||||
st->ss->init_super(st, &super, &info, 0, "");
|
||||
if (st->ss->store_super(st, fd, super)) {
|
||||
if (!quiet)
|
||||
fprintf(stderr, Name ": Could not zero superblock on %s\n",
|
||||
dev);
|
||||
rv = 1;
|
||||
} else if (rv) {
|
||||
if (!quiet)
|
||||
fprintf(stderr, Name ": superblock zeroed anyway\n");
|
||||
rv = 0;
|
||||
}
|
||||
|
|
2
mdadm.c
2
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':
|
||||
|
|
2
mdadm.h
2
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,
|
||||
|
|
Loading…
Reference in New Issue