Merge branch 'master' into devel-3.0

Conflicts:
	Build.c
	mdadm.c
	mdadm.h
	super1.c
This commit is contained in:
NeilBrown 2009-05-11 16:05:41 +10:00
commit 8320878543
7 changed files with 39 additions and 36 deletions

View File

@ -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;

View File

@ -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)

View File

@ -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 */
}
}

View File

@ -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));

View File

@ -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;

View File

@ -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,

View File

@ -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;