summaryrefslogtreecommitdiff
path: root/Create.c
diff options
context:
space:
mode:
Diffstat (limited to 'Create.c')
-rw-r--r--Create.c80
1 files changed, 41 insertions, 39 deletions
diff --git a/Create.c b/Create.c
index 330c5b42..1e4a6ee0 100644
--- a/Create.c
+++ b/Create.c
@@ -87,7 +87,7 @@ int Create(struct supertype *st, char *mddev,
unsigned long long minsize=0, maxsize=0;
char *mindisc = NULL;
char *maxdisc = NULL;
- int dnum;
+ int dnum, raid_disk_num;
struct mddev_dev *dv;
int fail=0, warn=0;
struct stat stb;
@@ -114,6 +114,8 @@ int Create(struct supertype *st, char *mddev,
unsigned long long newsize;
int major_num = BITMAP_MAJOR_HI;
+ if (s->bitmap_file && strcmp(s->bitmap_file, "clustered") == 0)
+ major_num = BITMAP_MAJOR_CLUSTERED;
memset(&info, 0, sizeof(info));
if (s->level == UnSet && st && st->ss->default_geometry)
@@ -177,15 +179,14 @@ int Create(struct supertype *st, char *mddev,
close(fd);
}
if (st && st->ss->external && s->sparedisks) {
- pr_err("This metadata type does not support "
- "spare disks at create time\n");
+ pr_err("This metadata type does not support spare disks at create time\n");
return 1;
}
- if (subdevs > s->raiddisks+s->sparedisks) {
+ if (subdevs > s->raiddisks+s->sparedisks+s->journaldisks) {
pr_err("You have listed more devices (%d) than are in the array(%d)!\n", subdevs, s->raiddisks+s->sparedisks);
return 1;
}
- if (!have_container && subdevs < s->raiddisks+s->sparedisks) {
+ if (!have_container && subdevs < s->raiddisks+s->sparedisks+s->journaldisks) {
pr_err("You haven't given enough devices (real or missing) to create this array\n");
return 1;
}
@@ -261,8 +262,7 @@ int Create(struct supertype *st, char *mddev,
if (do_default_chunk) {
/* default chunk was just set */
if (c->verbose > 0)
- pr_err("chunk size "
- "defaults to %dK\n", s->chunk);
+ pr_err("chunk size defaults to %dK\n", s->chunk);
s->size &= ~(unsigned long long)(s->chunk - 1);
do_default_chunk = 0;
}
@@ -330,7 +330,7 @@ int Create(struct supertype *st, char *mddev,
}
close(dfd);
info.array.working_disks++;
- if (dnum < s->raiddisks)
+ if (dnum < s->raiddisks && dv->disposition != 'j')
info.array.active_disks++;
if (st == NULL) {
struct createinfo *ci = conf_get_create_info();
@@ -375,8 +375,7 @@ int Create(struct supertype *st, char *mddev,
dname, strerror(errno));
exit(2);
}
- pr_err("device %s not suitable "
- "for any style of array\n",
+ pr_err("device %s not suitable for any style of array\n",
dname);
exit(2);
}
@@ -393,14 +392,16 @@ int Create(struct supertype *st, char *mddev,
dname, &freesize,
c->verbose >= 0)) {
- pr_err("%s is not suitable for "
- "this array.\n",
+ pr_err("%s is not suitable for this array.\n",
dname);
fail = 1;
continue;
}
}
+ if (dv->disposition == 'j')
+ goto skip_size_check; /* skip write journal for size check */
+
freesize /= 2; /* convert to K */
if (s->chunk && s->chunk != UnSet) {
/* round to chunk size */
@@ -408,8 +409,7 @@ int Create(struct supertype *st, char *mddev,
if (do_default_chunk) {
/* default chunk was just set */
if (c->verbose > 0)
- pr_err("chunk size "
- "defaults to %dK\n", s->chunk);
+ pr_err("chunk size defaults to %dK\n", s->chunk);
s->size &= ~(unsigned long long)(s->chunk - 1);
do_default_chunk = 0;
}
@@ -421,8 +421,7 @@ int Create(struct supertype *st, char *mddev,
}
if (s->size && freesize < s->size) {
- pr_err("%s is smaller than given size."
- " %lluK < %lluK + metadata\n",
+ pr_err("%s is smaller than given size. %lluK < %lluK + metadata\n",
dname, freesize, s->size);
fail = 1;
continue;
@@ -435,6 +434,7 @@ int Create(struct supertype *st, char *mddev,
mindisc = dname;
minsize = freesize;
}
+ skip_size_check:
if (c->runstop != 1 || c->verbose >= 0) {
int fd = open(dname, O_RDONLY);
if (fd <0 ) {
@@ -473,8 +473,7 @@ int Create(struct supertype *st, char *mddev,
}
}
if (s->raiddisks + s->sparedisks > st->max_devs) {
- pr_err("Too many devices:"
- " %s metadata only supports %d\n",
+ pr_err("Too many devices: %s metadata only supports %d\n",
st->ss->name, st->max_devs);
return 1;
}
@@ -538,6 +537,8 @@ int Create(struct supertype *st, char *mddev,
st->ss->name);
warn = 1;
}
+ st->nodes = c->nodes;
+ st->cluster_name = c->homecluster;
if (warn) {
if (c->runstop!= 1) {
@@ -618,8 +619,7 @@ int Create(struct supertype *st, char *mddev,
memset(&inf, 0, sizeof(inf));
ioctl(mdfd, GET_ARRAY_INFO, &inf);
if (inf.working_disks != 0) {
- pr_err("another array by this name"
- " is already running.\n");
+ pr_err("another array by this name is already running.\n");
goto abort_locked;
}
}
@@ -741,8 +741,7 @@ int Create(struct supertype *st, char *mddev,
mdi?mdi->text_version:"managed", devnm);
sysfs_free(mdi);
} else
- pr_err("Defaulting to version"
- " %s metadata\n", info.text_version);
+ pr_err("Defaulting to version %s metadata\n", info.text_version);
}
map_update(&map, fd2devnm(mdfd), info.text_version,
@@ -759,7 +758,8 @@ int Create(struct supertype *st, char *mddev,
#endif
}
- if (s->bitmap_file && strcmp(s->bitmap_file, "internal")==0) {
+ if (s->bitmap_file && (strcmp(s->bitmap_file, "internal")==0 ||
+ strcmp(s->bitmap_file, "clustered")==0)) {
if ((vers%100) < 2) {
pr_err("internal bitmaps not supported by this kernel.\n");
goto abort_locked;
@@ -797,14 +797,12 @@ int Create(struct supertype *st, char *mddev,
*/
container_fd = open_dev_excl(st->container_devnm);
if (container_fd < 0) {
- pr_err("Cannot get exclusive "
- "open on container - weird.\n");
+ pr_err("Cannot get exclusive open on container - weird.\n");
goto abort_locked;
}
if (mdmon_running(st->container_devnm)) {
if (c->verbose)
- pr_err("reusing mdmon "
- "for %s.\n",
+ pr_err("reusing mdmon for %s.\n",
st->container_devnm);
st->update_tail = &st->updates;
} else
@@ -845,7 +843,7 @@ int Create(struct supertype *st, char *mddev,
for (pass=1; pass <=2 ; pass++) {
struct mddev_dev *moved_disk = NULL; /* the disk that was moved out of the insert point */
- for (dnum=0, dv = devlist ; dv ;
+ for (dnum=0, raid_disk_num=0, dv = devlist ; dv ;
dv=(dv->next)?(dv->next):moved_disk, dnum++) {
int fd;
struct stat stb;
@@ -854,11 +852,14 @@ int Create(struct supertype *st, char *mddev,
if (dnum >= total_slots)
abort();
if (dnum == insert_point) {
+ raid_disk_num += 1;
moved_disk = dv;
continue;
}
- if (strcasecmp(dv->devname, "missing")==0)
+ if (strcasecmp(dv->devname, "missing")==0) {
+ raid_disk_num += 1;
continue;
+ }
if (have_container)
moved_disk = NULL;
if (have_container && dnum < info.array.raid_disks - 1)
@@ -870,8 +871,13 @@ int Create(struct supertype *st, char *mddev,
*inf = info;
inf->disk.number = dnum;
- inf->disk.raid_disk = dnum;
- if (inf->disk.raid_disk < s->raiddisks)
+ inf->disk.raid_disk = raid_disk_num++;
+
+ if (dv->disposition == 'j') {
+ inf->disk.raid_disk = MD_DISK_ROLE_JOURNAL;
+ inf->disk.state = (1<<MD_DISK_JOURNAL);
+ raid_disk_num--;
+ } else if (inf->disk.raid_disk < s->raiddisks)
inf->disk.state = (1<<MD_DISK_ACTIVE) |
(1<<MD_DISK_SYNC);
else
@@ -890,8 +896,7 @@ int Create(struct supertype *st, char *mddev,
fd = open(dv->devname, O_RDWR|O_EXCL);
if (fd < 0) {
- pr_err("failed to open %s "
- "after earlier success - aborting\n",
+ pr_err("failed to open %s after earlier success - aborting\n",
dv->devname);
goto abort_locked;
}
@@ -928,8 +933,7 @@ int Create(struct supertype *st, char *mddev,
rv = add_disk(mdfd, st, &info, inf);
if (rv) {
- pr_err("ADD_NEW_DISK for %s "
- "failed: %s\n",
+ pr_err("ADD_NEW_DISK for %s failed: %s\n",
dv->devname, strerror(errno));
goto abort_locked;
}
@@ -1007,8 +1011,7 @@ int Create(struct supertype *st, char *mddev,
}
sysfs_set_safemode(&info, safe_mode_delay);
if (err) {
- pr_err("failed to"
- " activate array.\n");
+ pr_err("failed to activate array.\n");
ioctl(mdfd, STOP_ARRAY, NULL);
goto abort;
}
@@ -1029,8 +1032,7 @@ int Create(struct supertype *st, char *mddev,
pr_err("RUN_ARRAY failed: %s\n",
strerror(errno));
if (info.array.chunk_size & (info.array.chunk_size-1)) {
- cont_err("Problem may be that "
- "chunk size is not a power of 2\n");
+ cont_err("Problem may be that chunk size is not a power of 2\n");
}
ioctl(mdfd, STOP_ARRAY, NULL);
goto abort;