diff options
-rw-r--r-- | Detail.c | 2 | ||||
-rw-r--r-- | Incremental.c | 5 | ||||
-rw-r--r-- | bitmap.c | 2 | ||||
-rw-r--r-- | mdadm.8.in | 54 | ||||
-rw-r--r-- | mdstat.c | 9 | ||||
-rw-r--r-- | super0.c | 6 | ||||
-rw-r--r-- | super1.c | 2 |
7 files changed, 54 insertions, 26 deletions
@@ -409,7 +409,7 @@ int Detail(char *dev, int brief, int export, int test, char *homehost) #if 0 This is pretty boring printf(" Reshape pos'n : %llu%s\n", (unsigned long long) info.reshape_progress<<9, - human_size(info.reshape_progress<<9)); + human_size((unsigned long long)info.reshape_progress<<9)); #endif if (info.delta_disks > 0) printf(" Delta Devices : %d, (%d->%d)\n", diff --git a/Incremental.c b/Incremental.c index abfea24..35490e7 100644 --- a/Incremental.c +++ b/Incremental.c @@ -892,6 +892,7 @@ int Incremental_container(struct supertype *st, char *devname, int verbose, int IncrementalRemove(char *devname, int verbose) { int mdfd; + int rv; struct mdstat_ent *ent; struct mddev_dev_s devlist; @@ -916,5 +917,7 @@ int IncrementalRemove(char *devname, int verbose) devlist.disposition = 'f'; Manage_subdevs(ent->dev, mdfd, &devlist, verbose, 0); devlist.disposition = 'r'; - return Manage_subdevs(ent->dev, mdfd, &devlist, verbose, 0); + rv = Manage_subdevs(ent->dev, mdfd, &devlist, verbose, 0); + close(mdfd); + return rv; } @@ -373,7 +373,7 @@ int CreateBitmap(char *filename, int force, char uuid[16], */ chunksize = DEFAULT_BITMAP_CHUNK; /* <<20 for 2^20 chunks, >>9 to convert bytes to sectors */ - while (array_size > (chunksize << (20-9))) + while (array_size > ((unsigned long long)chunksize << (20-9))) chunksize <<= 1; } @@ -1011,25 +1011,49 @@ homehost to match the current host. .SH For Manage mode: .TP +.BR \-t ", " \-\-test +Unless a more serious error occurred, +.I mdadm +will exit with a status of 2 if no changes were made to the array and +0 if at least one change was made. +This can be useful when an indirect specifier such as +.BR missing , +.B detached +or +.B faulty +is used in requesting an operation on the array. +.B \-\-test +will report failure if these specifiers didn't find any match. + +.TP .BR \-a ", " \-\-add -hot-add listed devices. For arrays with redundancy, the listed -devices become available as spares. If the array is degraded, it will -immediately start recovering data on to one of these spares. +hot-add listed devices. +If a device appears to have recently been part of the array +(possibly it failed or was removed) the device is re-added as describe +in the next point. +If that fails or the device was never part of the array, the device is +added as a hot-spare. +If the array is degraded, it will immediately start to rebuild data +onto that spare. + +Note that this and the following options are only meaningful on array +with redundancy. They don't apply to RAID0 or Linear. .TP .BR \-\-re\-add -re\-add a device that was recently removed from an array. This is -normally only needed for arrays that have be built (i.e. with -.BR --build ). -For created arrays, devices are always re\-added if that is possible, -however using \-\-re\-add will ensure the device isn't made into a -spare if the \-\-re\-add failed. - -When re\-adding a device, if nothing has changed on the array since the -device was removed, no recovery is performed. Also, if the array has -a write-intent bitmap, then the recovery performed after a re\-add will -be limited to those blocks which, according to the bitmap, might have -changed since the device was removed. +re\-add a device that was previous removed from an array. +If the metadata on the device reports that it is a member of the +array, and the slot that it used is still vacant, then the device will +be added back to the array in the same position. This will normally +cause the data for that device to be recovered. However based on the +event count on the device, the recovery may only require sections that +are flagged a write-intent bitmap to be recovered or may not require +any recovery at all. + +When used on an array that has no metadata (i.e. it was built with +.BR \-\-build) +it will be assumed that bitmap-based recovery is enough to make the +device fully consistent with the array. If the device name given is .B missing @@ -94,19 +94,20 @@ static void free_member_devnames(struct dev_member *m) } } -static void add_member_devname(struct dev_member **m, char *name) +static int add_member_devname(struct dev_member **m, char *name) { struct dev_member *new; char *t; if ((t = strchr(name, '[')) == NULL) /* not a device */ - return; + return 0; new = malloc(sizeof(*new)); new->name = strndup(name, t - name); new->next = *m; *m = new; + return 1; } void free_mdstat(struct mdstat_ent *ms) @@ -207,8 +208,8 @@ struct mdstat_ent *mdstat_read(int hold, int start) } else if (in_devs && strcmp(w, "blocks")==0) in_devs = 0; else if (in_devs) { - ent->devcnt++; - add_member_devname(&ent->members, w); + ent->devcnt += + add_member_devname(&ent->members, w); if (strncmp(w, "md", 2)==0) { /* This has an md device as a component. * If that device is already in the @@ -113,7 +113,7 @@ static void examine_super0(struct supertype *st, char *homehost) printf(" Creation Time : %.24s\n", ctime(&atime)); c=map_num(pers, sb->level); printf(" Raid Level : %s\n", c?c:"-unknown-"); - if ((int)sb->level >= 0) { + if ((int)sb->level > 0) { int ddsks=0; printf(" Used Dev Size : %d%s\n", sb->size, human_size((long long)sb->size<<10)); @@ -962,7 +962,7 @@ static int add_internal_bitmap0(struct supertype *st, int *chunkp, * size is in sectors, chunk is in bytes !!! */ unsigned long long bits; - unsigned long long max_bits = 60*1024*8; + unsigned long long max_bits = (60*1024 - sizeof(bitmap_super_t))*8; unsigned long long min_chunk; int chunk = *chunkp; mdp_super_t *sb = st->sb; @@ -1048,7 +1048,7 @@ static int write_bitmap0(struct supertype *st, int fd) memset(buf, 0xff, 4096); memcpy(buf, ((char*)sb)+MD_SB_BYTES, sizeof(bitmap_super_t)); - towrite = 64*1024; + towrite = 60*1024; while (towrite > 0) { n = towrite; if (n > 4096) @@ -239,7 +239,7 @@ static void examine_super1(struct supertype *st, char *homehost) printf(" Avail Dev Size : %llu%s\n", (unsigned long long)__le64_to_cpu(sb->data_size), human_size(__le64_to_cpu(sb->data_size)<<9)); - if (__le32_to_cpu(sb->level) >= 0) { + if (__le32_to_cpu(sb->level) > 0) { int ddsks=0; switch(__le32_to_cpu(sb->level)) { case 1: ddsks=1;break; |