From: NeilBrown Date: Thu, 30 Oct 2008 02:59:11 +0000 (+1100) Subject: Merge branch 'master' into devel-3.0 X-Git-Tag: mdadm-3.0-devel2~61 X-Git-Url: http://git.ipfire.org/?p=thirdparty%2Fmdadm.git;a=commitdiff_plain;h=6c766cf10178b9bae4ddcfd6b8de2d70f9d84568 Merge branch 'master' into devel-3.0 Conflicts: Incremental.c super0.c super1.c --- 6c766cf10178b9bae4ddcfd6b8de2d70f9d84568 diff --cc Detail.c index dc111028,9ba8af1d..c97172c7 --- a/Detail.c +++ b/Detail.c @@@ -151,58 -132,30 +151,58 @@@ int Detail(char *dev, int brief, int ex c = map_num(pers, array.level); if (export) { - if (c) - printf("MD_LEVEL=%s\n", c); - printf("MD_DEVICES=%d\n", array.raid_disks); - if (sra && sra->array.major_version < 0) - printf("MD_METADATA=%s\n", sra->text_version); - else - printf("MD_METADATA=%d.%02d\n", - array.major_version, array.minor_version); + if (array.raid_disks) { + if (c) + printf("MD_LEVEL=%s\n", c); + printf("MD_DEVICES=%d\n", array.raid_disks); + } else { + printf("MD_LEVEL=container\n"); + printf("MD_DEVICES=%d\n", array.nr_disks); + } + if (container) { + printf("MD_CONTAINER=%s\n", container); + printf("MD_MEMBER=%s\n", member); + } else { + if (sra && sra->array.major_version < 0) + printf("MD_METADATA=%s\n", sra->text_version); + else - printf("MD_METADATA=%02d.%02d\n", ++ printf("MD_METADATA=%d.%02d\n", + array.major_version, array.minor_version); + } + + if (st && st->sb) { + struct mdinfo info; + char nbuf[64]; + st->ss->getinfo_super(st, &info); + fname_from_uuid(st, &info, nbuf, ':'); + printf("MD_UUID=%s\n", nbuf+5); - if (st && st->sb) - st->ss->export_detail_super(st); + if (st->ss->export_detail_super) + st->ss->export_detail_super(st); + } goto out; } if (brief) { mdu_bitmap_file_t bmf; - printf("ARRAY %s level=%s num-devices=%d", dev, - c?c:"-unknown-", - array.raid_disks ); - if (sra && sra->array.major_version < 0) - printf(" metadata=%s", sra->text_version); + if (array.raid_disks) + printf("ARRAY %s level=%s num-devices=%d", dev, + c?c:"-unknown-", + array.raid_disks ); else - printf(" metadata=%d.%02d", - array.major_version, array.minor_version); + printf("ARRAY %s level=container num-devices=%d", + dev, array.nr_disks); + + if (container) { + printf(" container=%s", container); + printf(" member=%s", member); + } else { + if (sra && sra->array.major_version < 0) + printf(" metadata=%s", sra->text_version); + else - printf(" metadata=%02d.%02d", ++ printf(" metadata=%d.%02d", + array.major_version, array.minor_version); + } /* Only try GET_BITMAP_FILE for 0.90.01 and later */ if (vers >= 9001 && @@@ -233,13 -183,11 +233,13 @@@ if (sra && sra->array.major_version < 0) printf(" Version : %s\n", sra->text_version); else - printf(" Version : %02d.%02d\n", + printf(" Version : %d.%02d\n", array.major_version, array.minor_version); + } atime = array.ctime; - printf(" Creation Time : %.24s\n", ctime(&atime)); + if (atime) + printf(" Creation Time : %.24s\n", ctime(&atime)); if (array.raid_disks == 0) c = "container"; printf(" Raid Level : %s\n", c?c:"-unknown-"); if (larray_size) diff --cc Incremental.c index 80a0a07f,7148a734..cea693a1 --- a/Incremental.c +++ b/Incremental.c @@@ -85,16 -83,11 +85,14 @@@ int Incremental(char *devname, int verb int dfd, mdfd; char *avail; int active_disks; + int uuid_for_name = 0; + char *name_to_use; + char nbuf[64]; + struct createinfo *ci = conf_get_create_info(); - char *name; - if (autof == 0) - autof = ci->autof; - /* 1/ Check if devices is permitted by mdadm.conf */ + /* 1/ Check if device is permitted by mdadm.conf */ if (!conf_test_dev(devname)) { if (verbose >= 0) @@@ -216,34 -200,41 +214,46 @@@ match = array_list; } - /* 3a/ if not, check for homehost match. If no match, reject. */ + /* 3a/ if not, check for homehost match. If no match, continue + * but don't trust the 'name' in the array. Thus a 'random' minor + * number will be assigned, and the device name will be based + * on that. */ - name = info.name; if (!match) { if (homehost == NULL || - st->ss->match_home(st, homehost) == 0) { - if (verbose >= 0) - fprintf(stderr, Name - ": not found in mdadm.conf and not identified by homehost.\n"); - name = NULL; - } + st->ss->match_home(st, homehost) != 1) + uuid_for_name = 1; } /* 4/ Determine device number. */ - /* - If in mdadm.conf with std name, use that */ - /* - UUID in /var/run/mdadm.map use that */ + /* - If in mdadm.conf with std name, get number from name. */ + /* - UUID in /var/run/mdadm.map get number from mapping */ /* - If name is suggestive, use that. unless in use with */ /* different uuid. */ /* - Choose a free, high number. */ /* - Use a partitioned device unless strong suggestion not to. */ /* e.g. auto=md */ + mp = map_by_uuid(&map, info.uuid); + + if (uuid_for_name && ! mp) { + name_to_use = fname_from_uuid(st, &info, nbuf, '-'); + if (verbose >= 0) + fprintf(stderr, Name + ": not found in mdadm.conf and not identified by homehost" + " - using uuid based name\n"); + } else + name_to_use = info.name; - if (match && is_standard(match->devname, &devnum)) - /* We have devnum now */; - else if (mp != NULL) + /* There are three possible sources for 'autof': command line, + * ARRAY line in mdadm.conf, or CREATE line in mdadm.conf. + * They have precedence in that order. + */ + if (autof == 0 && match) + autof = match->autof; + if (autof == 0) + autof = ci->autof; + + if (match && (rv = is_standard(match->devname, &devnum))) { + devnum = (rv > 0) ? (-1-devnum) : devnum; - } else if ((mp = map_by_uuid(&map, info.uuid)) != NULL) ++ } else if (mp != NULL) devnum = mp->devnum; else { /* Have to guess a bit. */ @@@ -490,7 -457,8 +500,8 @@@ close(bmfd); } sra = sysfs_read(mdfd, devnum, 0); - if (sra == NULL || active_disks >= info.array.working_disks) + if ((sra == NULL || active_disks >= info.array.working_disks) - && name != NULL) ++ && uuid_for_name == 0) rv = ioctl(mdfd, RUN_ARRAY, NULL); else rv = sysfs_set_str(sra, NULL, diff --cc mdopen.c index 0b9498cc,9250e4ba..eee1eea1 --- a/mdopen.c +++ b/mdopen.c @@@ -282,7 -282,7 +282,7 @@@ int open_mddev_devnum(char *devname, in if (devname) strcpy(chosen_name, devname); - else if (name && name[0] && strchr(name,'/') == NULL) { - else if (name && *name && strchr(name,'/') == NULL) { ++ else if (name && *name && name[0] && strchr(name,'/') == NULL) { char *n = strchr(name, ':'); if (n) n++; else n = name; if (isdigit(*n) && devnum < 0)