]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Merge branch 'master' into devel-3.0
authorNeilBrown <neilb@suse.de>
Mon, 11 May 2009 06:05:41 +0000 (16:05 +1000)
committerNeilBrown <neilb@suse.de>
Mon, 11 May 2009 06:05:41 +0000 (16:05 +1000)
Conflicts:
Build.c
mdadm.c
mdadm.h
super1.c

Build.c
Makefile
Manage.c
bitmap.c
mdadm.c
mdadm.h
super1.c

diff --git a/Build.c b/Build.c
index 358f8e6f7fdf4e214caa750a3ef89ce43e83a7c2..2d9f68f0311515c5ae48f64c40130e850e445147 100644 (file)
--- a/Build.c
+++ b/Build.c
@@ -36,7 +36,7 @@
 int Build(char *mddev, int chunk, int level, int layout,
          int raiddisks, mddev_dev_t devlist, int assume_clean,
          char *bitmap_file, int bitmap_chunk, int write_behind,
-         int delay, int verbose, int autof)
+         int delay, int verbose, int autof, unsigned long long size)
 {
        /* Build a linear or raid0 arrays without superblocks
         * We cannot really do any checks, we just do it.
@@ -57,7 +57,6 @@ int Build(char *mddev, int chunk, int level, int layout,
        int subdevs = 0, missing_disks = 0;
        mddev_dev_t dv;
        int bitmap_fd;
-       unsigned long long size = ~0ULL;
        unsigned long long bitmapsize;
        int mdfd;
        char chosen_name[1024];
@@ -135,7 +134,7 @@ int Build(char *mddev, int chunk, int level, int layout,
        if (vers >= 9000) {
                mdu_array_info_t array;
                array.level = level;
-               array.size = 0;
+               array.size = size;
                array.nr_disks = raiddisks;
                array.raid_disks = raiddisks;
                array.md_minor = 0;
@@ -194,7 +193,7 @@ int Build(char *mddev, int chunk, int level, int layout,
                    (size == 0 || dsize < size))
                                size = dsize;
                close(fd);
-               if (vers>= 9000) {
+               if (vers >= 9000) {
                        mdu_disk_info_t disk;
                        disk.number = i;
                        disk.raid_disk = i;
index 63c9454206225192634afa1053b2733e8469abb0..a0d50b5e1bdb29f58bed609dbb0cb1cff909f0a3 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -127,13 +127,13 @@ mdadm.tcc : $(SRCS) mdadm.h
 
 mdadm.klibc : $(SRCS) mdadm.h
        rm -f $(OBJS) 
-       gcc -nostdinc -iwithprefix include -I$(KLIBC)/klibc/include -I$(KLIBC)/linux/include -I$(KLIBC)/klibc/arch/i386/include -I$(KLIBC)/klibc/include/bits32 $(CFLAGS) $(SRCS)
+       $(CC) -nostdinc -iwithprefix include -I$(KLIBC)/klibc/include -I$(KLIBC)/linux/include -I$(KLIBC)/klibc/arch/i386/include -I$(KLIBC)/klibc/include/bits32 $(CFLAGS) $(SRCS)
 
 mdadm.Os : $(SRCS) mdadm.h
-       gcc -o mdadm.Os $(CFLAGS)  -DHAVE_STDINT_H -Os $(SRCS)
+       $(CC) -o mdadm.Os $(CFLAGS)  -DHAVE_STDINT_H -Os $(SRCS)
 
 mdadm.O2 : $(SRCS) mdadm.h
-       gcc -o mdadm.O2 $(CFLAGS)  -DHAVE_STDINT_H -O2 $(SRCS)
+       $(CC) -o mdadm.O2 $(CFLAGS)  -DHAVE_STDINT_H -O2 $(SRCS)
 
 mdmon : $(MON_OBJS)
        $(CC) $(LDFLAGS) -o mdmon $(MON_OBJS) $(LDLIBS)
index 1f38fa54db91217af138eb528a448393eb26104a..65235bc1836f5e02c22c3e703cea2f39789b8023 100644 (file)
--- a/Manage.c
+++ b/Manage.c
@@ -588,6 +588,11 @@ int Manage_subdevs(char *devname, int fd,
                                                                fprintf(stderr, Name ": re-added %s\n", dv->devname);
                                                        continue;
                                                }
+                                               if (errno == ENOMEM || errno == EROFS) {
+                                                       fprintf(stderr, Name ": add new device failed for %s: %s\n",
+                                                               dv->devname, strerror(errno));
+                                                       return 1;
+                                               }
                                                /* fall back on normal-add */
                                        }
                                }
index b9bbaebdf09bfdaa8981314b280db33156ff2c42..850b0cedbf5fa8c9f4a1294e154377b4779581b0 100644 (file)
--- a/bitmap.c
+++ b/bitmap.c
@@ -271,6 +271,7 @@ int ExamineBitmap(char *filename, int brief, struct supertype *st)
        int rv = 1;
        char buf[64];
        int swap;
+       __u32 uuid32[4];
 
        info = bitmap_file_read(filename, brief, &st);
        if (!info)
@@ -298,19 +299,20 @@ int ExamineBitmap(char *filename, int brief, struct supertype *st)
 #else
                swap = 1;
 #endif
-       if (swap) {
-       printf("            UUID : %08x:%08x:%08x:%08x\n",
-                                       swapl(*(__u32 *)(sb->uuid+0)),
-                                       swapl(*(__u32 *)(sb->uuid+4)),
-                                       swapl(*(__u32 *)(sb->uuid+8)),
-                                       swapl(*(__u32 *)(sb->uuid+12)));
-       } else {
-       printf("            UUID : %08x:%08x:%08x:%08x\n",
-                                       *(__u32 *)(sb->uuid+0),
-                                       *(__u32 *)(sb->uuid+4),
-                                       *(__u32 *)(sb->uuid+8),
-                                       *(__u32 *)(sb->uuid+12));
-       }
+       memcpy(uuid32, sb->uuid, 16);
+       if (swap)
+               printf("            UUID : %08x:%08x:%08x:%08x\n",
+                      swapl(uuid32[0]),
+                      swapl(uuid32[1]),
+                      swapl(uuid32[2]),
+                      swapl(uuid32[3]));
+       else
+               printf("            UUID : %08x:%08x:%08x:%08x\n",
+                      uuid32[0],
+                      uuid32[1],
+                      uuid32[2],
+                      uuid32[3]);
+
        printf("          Events : %llu\n", (unsigned long long)sb->events);
        printf("  Events Cleared : %llu\n", (unsigned long long)sb->events_cleared);
        printf("           State : %s\n", bitmap_state(sb->state));
diff --git a/mdadm.c b/mdadm.c
index 3b14ea5103494f6bccd4b8f1af671d41ae7cfa17..99a177186bb60fd336ea2a4a10801eafce2fa7fd 100644 (file)
--- a/mdadm.c
+++ b/mdadm.c
@@ -378,7 +378,8 @@ int main(int argc, char *argv[])
 
 
                case O(GROW,'z'):
-               case O(CREATE,'z'): /* size */
+               case O(CREATE,'z'):
+               case O(BUILD,'z'): /* size */
                        if (size >= 0) {
                                fprintf(stderr, Name ": size may only be specified once. "
                                        "Second value is %s.\n", optarg);
@@ -1202,7 +1203,7 @@ int main(int argc, char *argv[])
                rv = Build(devlist->devname, chunk, level, layout,
                           raiddisks, devlist->next, assume_clean,
                           bitmap_file, bitmap_chunk, write_behind,
-                          delay, verbose-quiet, autof);
+                          delay, verbose-quiet, autof, size);
                break;
        case CREATE:
                if (delay == 0) delay = DEFAULT_BITMAP_DELAY;
diff --git a/mdadm.h b/mdadm.h
index 8aa38c5a7e1cf9cdbe29fd396f10f44abdcbb377..89ec77a4b140815af8019b84e0de2ec0b7a78763 100644 (file)
--- a/mdadm.h
+++ b/mdadm.h
@@ -730,7 +730,7 @@ extern int Assemble(struct supertype *st, char *mddev,
 extern int Build(char *mddev, int chunk, int level, int layout,
                 int raiddisks, mddev_dev_t devlist, int assume_clean,
                 char *bitmap_file, int bitmap_chunk, int write_behind,
-                int delay, int verbose, int autof);
+                int delay, int verbose, int autof, unsigned long long size);
 
 
 extern int Create(struct supertype *st, char *mddev,
index bf9e4c87fc6910ef6204b4698e736c345b325f85..35ef771a613c9b29db436737ae621a9ada692822 100644 (file)
--- a/super1.c
+++ b/super1.c
@@ -687,10 +687,8 @@ static int update_super1(struct supertype *st, struct mdinfo *info,
 
                if ((rfd = open("/dev/urandom", O_RDONLY)) < 0 ||
                    read(rfd, sb->device_uuid, 16) != 16) {
-                       *(__u32*)(sb->device_uuid) = random();
-                       *(__u32*)(sb->device_uuid+4) = random();
-                       *(__u32*)(sb->device_uuid+8) = random();
-                       *(__u32*)(sb->device_uuid+12) = random();
+                       __u32 r[4] = {random(), random(), random(), random()};
+                       memcpy(sb->device_uuid, r, 16);
                }
 
                sb->dev_roles[i] =
@@ -816,10 +814,8 @@ static int init_super1(struct supertype *st, mdu_array_info_t *info,
        else {
                if ((rfd = open("/dev/urandom", O_RDONLY)) < 0 ||
                    read(rfd, sb->set_uuid, 16) != 16) {
-                       *(__u32*)(sb->set_uuid) = random();
-                       *(__u32*)(sb->set_uuid+4) = random();
-                       *(__u32*)(sb->set_uuid+8) = random();
-                       *(__u32*)(sb->set_uuid+12) = random();
+                       __u32 r[4] = {random(), random(), random(), random()};
+                       memcpy(sb->set_uuid, r, 16);
                }
                if (rfd >= 0) close(rfd);
        }
@@ -1023,12 +1019,12 @@ static int write_init_super1(struct supertype *st)
 
                if ((rfd = open("/dev/urandom", O_RDONLY)) < 0 ||
                    read(rfd, sb->device_uuid, 16) != 16) {
-                       *(__u32*)(sb->device_uuid) = random();
-                       *(__u32*)(sb->device_uuid+4) = random();
-                       *(__u32*)(sb->device_uuid+8) = random();
-                       *(__u32*)(sb->device_uuid+12) = random();
+                       __u32 r[4] = {random(), random(), random(), random()};
+                       memcpy(sb->device_uuid, r, 16);
                }
-               if (rfd >= 0) close(rfd);
+               if (rfd >= 0)
+                       close(rfd);
+
                sb->events = 0;
 
                refst =*st;