]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Fix write_init_super usage when hot-adding a spare
authorNeil Brown <neilb@suse.de>
Sat, 12 Jul 2008 10:27:36 +0000 (20:27 +1000)
committerNeil Brown <neilb@suse.de>
Sat, 12 Jul 2008 10:27:36 +0000 (20:27 +1000)
Using write_init_super to add a spare to an active array is quite
different to how it is used when creating an array.

It mostly works, but if we are adding two devices to an array,
then when we add the second, there are still traces of the first
which confuse write_init_super.

So get write_init_super to ignore those traces.  Longer term, we
probably want to do this differently as for DDF, hot-adding to
an active array will have to be quite different - it will want to
write to all metadata, possibly via mdmon.

super0.c
super1.c

index 1ca35368bb4f92ca8d5b4d2b7d728bef60b11588..e8cc3f3f62a7b7ea218b5a2c6010cd3a85b91680 100644 (file)
--- a/super0.c
+++ b/super0.c
@@ -698,6 +698,8 @@ static int write_init_super0(struct supertype *st)
 
                if (di->disk.state == 1)
                        continue;
+               if (di->fd == -1)
+                       continue;
                Kill(di->devname, 0, 1, 1);
                Kill(di->devname, 0, 1, 1);
 
index 0fe54e97c22fda05c350774d8ea23f8cca93440b..bebd5f961f2e2d8079e57f5f07ceb8d468e90483 100644 (file)
--- a/super1.c
+++ b/super1.c
@@ -900,16 +900,12 @@ static int write_init_super1(struct supertype *st)
        for (di = st->info; di && ! rv ; di = di->next) {
                if (di->disk.state == 1)
                        continue;
+               if (di->fd < 0)
+                       continue;
 
                Kill(di->devname, 0, 1, 1);
                Kill(di->devname, 0, 1, 1);
 
-               if (di->fd < 0) {
-                       fprintf(stderr,
-                               Name": Failed to open %s to write superblock\n",
-                               di->devname);
-                       return -1;
-               }
                sb->dev_number = __cpu_to_le32(di->disk.number);
                if (di->disk.state & (1<<MD_DISK_WRITEMOSTLY))
                        sb->devflags |= __cpu_to_le32(WriteMostly1);