Merge branch 'master' into devel-3.0
authorNeilBrown <neilb@suse.de>
Tue, 2 Jun 2009 05:28:36 +0000 (15:28 +1000)
committerNeilBrown <neilb@suse.de>
Tue, 2 Jun 2009 05:28:36 +0000 (15:28 +1000)
Conflicts:
super0.c
super1.c

1  2 
Manage.c
Monitor.c

diff --cc Manage.c
+++ b/Manage.c
@@@ -460,14 -315,9 +464,14 @@@ int Manage_subdevs(char *devname, int f
                        return 1;
                case 'a':
                        /* add the device */
 -
 +                      if (tst->subarray[0]) {
 +                              fprintf(stderr, Name ": Cannot add disks to a"
 +                                      " \'member\' array, perform this"
 +                                      " operation on the parent container\n");
 +                              return 1;
 +                      }
                        /* Make sure it isn't in use (in 2.6 or later) */
-                       tfd = open(dv->devname, O_RDONLY|O_EXCL|O_DIRECT);
 -                      tfd = dev_open(dv->devname, O_RDONLY|O_EXCL);
++                      tfd = dev_open(dv->devname, O_RDONLY|O_EXCL|O_DIRECT);
                        if (tfd < 0) {
                                fprintf(stderr, Name ": Cannot open %s: %s\n",
                                        dv->devname, strerror(errno));
                        disc.minor = minor(stb.st_rdev);
                        disc.number =j;
                        disc.state = 0;
 -                      if (array.not_persistent==0) {
 +                      if (array.not_persistent==0 || tst->ss->external) {
 +                              int dfd;
                                if (dv->writemostly == 1)
                                        disc.state |= 1 << MD_DISK_WRITEMOSTLY;
-                               dfd = open(dv->devname, O_RDWR | O_EXCL|O_DIRECT);
 -                              tst->ss->add_to_super(tst, &disc);
 -                              if (tst->ss->write_init_super(tst, &disc,
 -                                                            dv->devname))
++                              dfd = dev_open(dv->devname, O_RDWR | O_EXCL|O_DIRECT);
 +                              if (tst->ss->add_to_super(tst, &disc, dfd,
 +                                                        dv->devname)) {
 +                                      close(dfd);
 +                                      return 1;
 +                              }
 +                              /* write_init_super will close 'dfd' */
 +                              if (tst->ss->external)
 +                                      /* mdmon will write the metadata */
 +                                      close(dfd);
 +                              else if (tst->ss->write_init_super(tst))
                                        return 1;
                        } else if (dv->re_add) {
                                /*  this had better be raid1.
diff --cc Monitor.c
Simple merge