unsigned int num_devs;
mddev_dev_t tmpdev;
struct mdinfo info;
+ struct mddev_ident_s ident2;
vers = md_get_version(mdfd);
if (vers <= 0) {
devname);
close(dfd);
} else {
- tst->ss->getinfo_super(&info, super);
+ tst->ss->getinfo_super(&info, &ident2, super);
close(dfd);
}
devname);
continue;
}
+ if (ident->name[0] &&
+ (!super || strncmp(ident2.name, ident->name, 32)!=0)) {
+ if (inargv || verbose)
+ fprintf(stderr, Name ": %s has wrong name.\n",
+ devname);
+ continue;
+ }
if (ident->super_minor != UnSet &&
(!super || ident->super_minor != info.array.md_minor)) {
if (inargv || verbose)
return 1;
}
- st->ss->getinfo_super(&info, first_super);
+ st->ss->getinfo_super(&info, &ident2, first_super);
/* now we have some devices that might be suitable.
* I wonder how many
fprintf(stderr, Name ": No suitable drives found for %s\n", mddev);
return 1;
}
- st->ss->getinfo_super(&info, super);
+ st->ss->getinfo_super(&info, &ident2, super);
for (i=0; i<bestcnt; i++) {
int j = best[i];
unsigned int desired_state;
- Support assembling from byte-swapped superblocks
metadata type "0.swap" and --update=byteorder
- write-mostly and write-behind support for raid1.
+ - Support --name= and 'name=' config entry for identifying
+ arrays be name.
Changes Prior to 2.0-devel-3 release
- Assorted fixes for multiple bugs...
int Create(struct supertype *st, char *mddev, int mdfd,
int chunk, int level, int layout, unsigned long size, int raiddisks, int sparedisks,
+ char *name,
int subdevs, mddev_dev_t devlist,
int runstop, int verbose, int force,
char *bitmap_file, int bitmap_chunk, int write_behind, int delay)
array.chunk_size = chunk*1024;
- if (!st->ss->init_super(st, &super, &array))
+ if (!st->ss->init_super(st, &super, &array, name))
return 1;
if (bitmap_file && strcmp(bitmap_file, "internal")==0) {
if (fd2 >=0 && st &&
st->ss->load_super(st, fd2, &super, NULL) == 0) {
struct mdinfo info;
- st->ss->getinfo_super(&info, super);
+ struct mddev_ident_s ident;
+ st->ss->getinfo_super(&info, &ident, super);
if (info.array.ctime != array.ctime ||
info.array.level != array.level) {
free(super);
void *super;
struct supertype *st;
struct mdinfo info;
+ struct mddev_ident_s ident;
void *devs;
struct array *next;
int spares;
ap->spares = 0;
ap->st = st;
arrays = ap;
- st->ss->getinfo_super(&ap->info, super);
+ st->ss->getinfo_super(&ap->info, &ap->ident, super);
} else {
- st->ss->getinfo_super(&ap->info, super);
+ st->ss->getinfo_super(&ap->info, &ap->ident, super);
free(super);
}
if (!(ap->info.disk.state & MD_DISK_SYNC))
mdu_array_info_t info;
info.major_version = -1; /* zero superblock */
free(super);
- st->ss->init_super(st, &super, &info);
+ st->ss->init_super(st, &super, &info, "");
if (st->ss->store_super(st, fd, super)) {
fprintf(stderr, Name ": Could not zero superblock on %s\n",
dev);
int ioctlerr;
int superror, superrno;
struct mdinfo info;
+ struct mddev_ident_s ident;
mdu_array_info_t array;
void *super;
struct supertype *st = NULL;
close(fd);
if (superror == 0) {
/* array might be active... */
- st->ss->getinfo_super(&info, super);
+ st->ss->getinfo_super(&info, &ident, super);
if (st->ss->major == 0) {
mddev = get_md_name(info.array.md_minor);
disc.number = info.disk.number;
/* For assemble */
{"uuid", 1, 0, 'u'},
{"super-minor",1,0, 'm'},
+ {"name", 1, 0, 'N'},
{"config", 1, 0, 'c'},
{"scan", 0, 0, 's'},
{"force", 0, 0, 'f'},
" --bitmap-chunk= : chunksize of bitmap in bitmap file (Kilobytes)\n"
" --delay= -d : seconds between bitmap updates\n"
" --write-behind= : number of simultaneous write-behind requests to allow (requires bitmap)\n"
+" --name= -N : Textual name for array - max 32 characters\n"
"\n"
" For assemble:\n"
" --bitmap= -b : File to find bitmap information in\n"
" have this uuid are excluded\n"
" --super-minor= -m : minor number to look for in super-block when\n"
" choosing devices to use.\n"
+" --name= -N : Array name to look for in super-block.\n"
" --config= -c : config file\n"
" --scan -s : scan config file for missing information\n"
" --force -f : Assemble the array even if some superblocks appear out-of-date\n"
" --run -R : insist of running the array even if not all\n"
" : devices are present or some look odd.\n"
" --readonly -o : start the array readonly - not supported yet.\n"
+" --name= -N : Textual name for array - max 32 characters\n"
" --bitmap-chunk= : bitmap chunksize in Kilobytes.\n"
" --delay= -d : bitmap update delay in seconds.\n"
"\n"
" have this uuid are excluded\n"
" --super-minor= -m : minor number to look for in super-block when\n"
" choosing devices to use.\n"
+" --name= -N : Array name to look for in super-block.\n"
" --config= -c : config file\n"
" --scan -s : scan config file for missing information\n"
" --run -R : Try to start the array even if not enough devices\n"
mis.next = NULL;
mis.st = NULL;
mis.bitmap_fd = -1;
+ mis.name[0] = 0;
for (w=dl_next(line); w!=line; w=dl_next(w)) {
if (w[0] == '/') {
mis.super_minor = UnSet;
}
}
+ } else if (strncasecmp(w, "name=", 5)==0) {
+ if (mis.name[0])
+ fprintf(stderr, Name ": only specify name once, %s ignored.\n",
+ w);
+ else if (strlen(w+5) > 32)
+ fprintf(stderr, Name ": name too long, ignoring %s\n", w);
+ else
+ strcpy(mis.name, w+5);
+
} else if (strncasecmp(w, "devices=", 8 ) == 0 ) {
if (mis.devices)
fprintf(stderr, Name ": only specify devices once (use a comma separated list). %s ignored\n",
}
if (mis.devname == NULL)
fprintf(stderr, Name ": ARRAY line with no device\n");
- else if (mis.uuid_set == 0 && mis.devices == NULL && mis.super_minor == UnSet)
+ else if (mis.uuid_set == 0 && mis.devices == NULL && mis.super_minor == UnSet && mis.name[0] == 0)
fprintf(stderr, Name ": ARRAY line %s has no identity information.\n", mis.devname);
else {
mi = malloc(sizeof(*mi));
really useful for Building RAID1 array. Only use this if you really
know what you are doing. This is currently only supported for --build.
+.TP
+.BR -N ", " --name=
+Set a
+.B name
+for the array. This is currently only effective when creating an
+array with a version-1 superblock. The name is a simple textual
+string that can be used to identify array components when assembling.
+
.TP
.BR -R ", " --run
Insist that
.M --super-minor=dev
will look for super blocks with a minor number of 0.
+.TP
+.BR -N ", " --name=
+Specify the name of the array to assemble. This must be the name
+that was specified when creating the array.
+
.TP
.BR -f ", " --force
Assemble the array even if some superblocks appear out-of-date
ident.autof = 0;
ident.st = NULL;
ident.bitmap_fd = -1;
+ ident.name[0] = 0;
while ((option_index = -1) ,
(opt=getopt_long(argc, argv,
}
continue;
+ case O(CREATE,'N'):
+ case O(ASSEMBLE,'N'):
+ if (ident.name[0]) {
+ fprintf(stderr, Name ": name cannot be set twice. "
+ "Second value %s.\n", optarg);
+ exit(2);
+ }
+ if (strlen(optarg) > 32) {
+ fprintf(stderr, Name ": name '%s' is too long, 32 chars max.\n",
+ optarg);
+ exit(2);
+ }
+ strcpy(ident.name, optarg);
+ continue;
+
case O(ASSEMBLE,'m'): /* super-minor for array */
if (ident.super_minor != UnSet) {
fprintf(stderr, Name ": super-minor cannot be set twice. "
break;
case ASSEMBLE:
if (devs_found == 1 && ident.uuid_set == 0 &&
- ident.super_minor == UnSet && !scan ) {
+ ident.super_minor == UnSet && ident.name[0] == 0 && !scan ) {
/* Only a device has been given, so get details from config file */
mddev_ident_t array_ident = conf_get_ident(configfile, devlist->devname);
if (array_ident == NULL) {
}
rv = Create(ss, devlist->devname, mdfd, chunk, level, layout, size<0 ? 0 : size,
- raiddisks, sparedisks,
+ raiddisks, sparedisks, ident.name,
devs_found-1, devlist->next, runstop, verbose, force,
bitmap_file, bitmap_chunk, write_behind, delay);
break;
interspersed if desired. This must match the uuid stored in the
superblock.
.TP
+.B name=
+The value should be a simple textual name as was given to
+.I mdadm
+when the array was created. This must match the name stored in the
+superblock on a device for that device to be included in the array.
+Not all superblock-formats support names.
+.TP
.B super-minor=
The value is an integer which indicates the minor number that was
stored in the superblock when the array was created. When an array is
int uuid_set;
int uuid[4];
+ char name[33];
unsigned int super_minor;
void (*detail_super)(void *sbv);
void (*brief_detail_super)(void *sbv);
void (*uuid_from_super)(int uuid[4], void *sbv);
- void (*getinfo_super)(struct mdinfo *info, void *sbv);
+ void (*getinfo_super)(struct mdinfo *info, mddev_ident_t ident, void *sbv);
int (*update_super)(struct mdinfo *info, void *sbv, char *update, char *devname, int verbose);
__u64 (*event_super)(void *sbv);
- int (*init_super)(struct supertype *st, void **sbp, mdu_array_info_t *info);
+ int (*init_super)(struct supertype *st, void **sbp, mdu_array_info_t *info, char *name);
void (*add_to_super)(void *sbv, mdu_disk_info_t *dinfo);
int (*store_super)(struct supertype *st, int fd, void *sbv);
int (*write_init_super)(struct supertype *st, void *sbv, mdu_disk_info_t *dinfo, char *devname);
extern int Create(struct supertype *st, char *mddev, int mdfd,
int chunk, int level, int layout, unsigned long size, int raiddisks, int sparedisks,
+ char *name,
int subdevs, mddev_dev_t devlist,
int runstop, int verbose, int force,
char *bitmap_file, int bitmap_chunk, int write_behind, int delay);
}
}
-static void getinfo_super0(struct mdinfo *info, void *sbv)
+static void getinfo_super0(struct mdinfo *info, mddev_ident_t ident, void *sbv)
{
mdp_super_t *sb = sbv;
int working = 0;
info->events = md_event(sb);
uuid_from_super0(info->uuid, sbv);
-
+
+ ident->name[0] = 0;
/* work_disks is calculated rather than read directly */
for (i=0; i < MD_SB_DISKS; i++)
if ((sb->disks[i].state & (1<<MD_DISK_SYNC)) &&
-static int init_super0(struct supertype *st, void **sbp, mdu_array_info_t *info)
+static int init_super0(struct supertype *st, void **sbp, mdu_array_info_t *info, char *ignored_name)
{
mdp_super_t *sb = malloc(MD_SB_BYTES + sizeof(bitmap_super_t));
int spares;
printf("%02x", sb->set_uuid[i]);
if ((i&3)==0 && i != 0) printf(":");
}
+ if (sb->set_name[0])
+ printf(" name=%.32s", sb->set_name);
printf("\n");
}
struct mdp_superblock_1 *sb = sbv;
int i;
+ printf(" Name : %.32s\n", sb->set_name);
printf(" UUID : ");
for (i=0; i<16; i++) {
printf("%02x", sb->set_uuid[i]);
struct mdp_superblock_1 *sb = sbv;
int i;
+ if (sb->set_name[0])
+ printf(" name=%.32s", sb->set_name);
printf(" UUID=");
for (i=0; i<16; i++) {
printf("%02x", sb->set_uuid[i]);
cuuid[i] = super->set_uuid[i];
}
-static void getinfo_super1(struct mdinfo *info, void *sbv)
+static void getinfo_super1(struct mdinfo *info, mddev_ident_t ident, void *sbv)
{
struct mdp_superblock_1 *sb = sbv;
int working = 0;
memcpy(info->uuid, sb->set_uuid, 16);
+ strncpy(ident->name, sb->set_name, 32);
+ ident->name[32] = 0;
+
for (i=0; i< __le32_to_cpu(sb->max_dev); i++) {
role = __le16_to_cpu(sb->dev_roles[i]);
if (/*role == 0xFFFF || */role < info->array.raid_disks)
return __le64_to_cpu(sb->events);
}
-static int init_super1(struct supertype *st, void **sbp, mdu_array_info_t *info)
+static int init_super1(struct supertype *st, void **sbp, mdu_array_info_t *info, char *name)
{
struct mdp_superblock_1 *sb = malloc(1024);
int spares;
*(__u32*)(sb->set_uuid+8) = random();
*(__u32*)(sb->set_uuid+12) = random();
- /* FIXME name */
+ memset(sb->set_name, 0, 32);
+ strcpy(sb->set_name, name);
sb->ctime = __cpu_to_le64((unsigned long long)time(0));
sb->level = __cpu_to_le32(info->level);
--- /dev/null
+set -x
+
+# create an array with a name
+
+$mdadm -CR $md0 -l0 -n2 --metadata=1 --name="Fred" $dev0 $dev1
+$mdadm -E $dev0 | grep 'Name : Fred$' > /dev/null || exit 1
+$mdadm -D $md0 | grep 'Name : Fred$' > /dev/null || exit 1
+$mdadm -S $md0
+
+$mdadm -A $md0 --name="Fred" $devlist
+$mdadm -Db $md0
+$mdadm -S $md0
+
{
void *super;
struct mdinfo info;
+ struct mddev_ident_s ident;
time_t crtime;
struct supertype *st = guess_super(fd);
/* Looks like a raid array .. */
fprintf(stderr, Name ": %s appears to be part of a raid array:\n",
name);
- st->ss->getinfo_super(&info, super);
+ st->ss->getinfo_super(&info, &ident, super);
free(super);
crtime = info.array.ctime;
fprintf(stderr, " level=%d devices=%d ctime=%s",
rv = ss->load_super(st, fd, &sbp, NULL);
if (rv == 0) {
struct mdinfo info;
- ss->getinfo_super(&info, sbp);
+ struct mddev_ident_s ident;
+ ss->getinfo_super(&info, &ident, sbp);
if (bestsuper == -1 ||
besttime < info.array.ctime) {
bestsuper = i;