Codebase list mdadm / aa88f53
mdadm-1.3.0 Neil Brown 20 years ago
17 changed file(s) with 203 addition(s) and 48 deletion(s). Raw diff Collapse all Expand all
0 Subject: ANNOUNCE: mdadm 1.3.0 - A tools for managing Soft RAID under Linux
1
2
3 I am pleased to announce the availability of
4 mdadm version 1.3.0
5 It is available at
6 http://www.cse.unsw.edu.au/~neilb/source/mdadm/
7 and
8 http://www.{countrycode}.kernel.org/pub/utils/raid/mdadm/
9
10 as a source tar-ball and (at the first site) as an SRPM, and as an RPM for i386.
11
12 mdadm is a tool for creating, managing and monitoring
13 device arrays using the "md" driver in Linux, also
14 known as Software RAID arrays.
15
16 Release 1.3.0 is a bug-fix and minor feature update release over 1.2.0.
17
18 Development of mdadm is sponsored by CSE@UNSW:
19 The School of Computer Science and Engineering
20 at
21 The University of New South Wales
22
23 NeilBrown 29 Jul 2003
108108 int *best = NULL; /* indexed by raid_disk */
109109 int bestcnt = 0;
110110 int devcnt = 0, okcnt, sparecnt;
111 int req_cnt;
111112 int i;
112113 int most_recent = 0;
113114 int chosen_drive;
364365 * as they don't make sense
365366 */
366367 if (first_super.level != -4)
367 if (!(devices[j].state & (1<<MD_DISK_SYNC)))
368 if (!(devices[j].state & (1<<MD_DISK_SYNC))) {
369 if (!(devices[j].state & (1<<MD_DISK_FAULTY)))
370 sparecnt++;
368371 continue;
372 }
369373 if (devices[j].events+event_margin >=
370374 devices[most_recent].events) {
371375 devices[j].uptodate = 1;
533537 close(fd);
534538 change = 0;
535539 }
540
541 /* count number of in-sync devices according to the superblock.
542 * We must have this number to start the array without -s or -R
543 */
544 req_cnt = 0;
545 for (i=0; i<MD_SB_DISKS; i++)
546 if ((first_super.disks[i].state & (1<<MD_DISK_SYNC)) &&
547 (first_super.disks[i].state & (1<<MD_DISK_ACTIVE)) &&
548 !(first_super.disks[i].state & (1<<MD_DISK_FAULTY)))
549 req_cnt ++;
550
536551
537552 /* Almost ready to actually *do* something */
538553 if (!old_linux) {
575590
576591 if (runstop == 1 ||
577592 (runstop == 0 &&
578 ( first_super.raid_disks == okcnt
579 || (start_partial_ok && enough(first_super.level, first_super.raid_disks, okcnt)))
580 )) {
593 ( enough(first_super.level, first_super.raid_disks, okcnt) &&
594 (okcnt >= req_cnt || start_partial_ok)
595 ))) {
581596 if (ioctl(mdfd, RUN_ARRAY, NULL)==0) {
582597 fprintf(stderr, Name ": %s has been started with %d drive%s",
583598 mddev, okcnt, okcnt==1?"":"s");
599 if (okcnt < first_super.raid_disks)
600 fprintf(stderr, " (out of %d)", first_super.raid_disks);
584601 if (sparecnt)
585602 fprintf(stderr, " and %d spare%s", sparecnt, sparecnt==1?"":"s");
586603 fprintf(stderr, ".\n");
595612 mddev, okcnt, okcnt==1?"":"s");
596613 return 0;
597614 }
598 fprintf(stderr, Name ": %s assembled from %d drive%s - not enough to start it (use --run to insist).\n",
599 mddev, okcnt, okcnt==1?"":"s");
615 fprintf(stderr, Name ": %s assembled from %d drive%s", mddev, okcnt, okcnt==1?"":"s");
616 if (sparecnt)
617 fprintf(stderr, " and %d spare%s", sparecnt, sparecnt==1?"":"s");
618 if (!enough(first_super.level, first_super.raid_disks, okcnt))
619 fprintf(stderr, " - not enough to start the array.\n");
620 else {
621 if (req_cnt == first_super.raid_disks)
622 fprintf(stderr, " - need all %d to start it", req_cnt);
623 else
624 fprintf(stderr, " - need %d of %d to start", req_cnt, first_super.raid_disks);
625 fprintf(stderr, " (use --run to insist).\n");
626 }
600627 return 1;
601628 } else {
602629 /* The "chosen_drive" is a good choice, and if necessary, the superblock has
0 Changes Prior to 1.3.0 release
1 - Make 'size' and unsigned long in Create to allow creation of
2 larger arrays.
3 - Explicitly flag spare devices as 'spare' in --detail and --examine
4 output. Previously they simply had no flags lists.
5 - Make MailCmd (for monitor) configurable in Makefile, and default
6 to "/usr/sbin/sendmail -t". Also split out the warning related
7 flags into CWFLAGS for easier build configurability.
8 - Minor bugfix in Manage code.
9 - --monitor now notices and reports degraded arrays at startup using
10 "DegradedArray" event, and also has a --oneshot option to only
11 report DegradedArrays, and then exit.
12 - Small man-page clarification w.r.t. raid levels and raid4 in
13 particular.
14 - Disallow creation of arrays with only one device as this is
15 probably a mistake. --force will override this check.
16 - Correct some misleading documentation in the "mdadm --create --help"
17 message.
18 - Ignore chunksize if raid1 or multipath.
19 - Explicit statement in man page that raid-disks cannot be changed
20 after array is created.
21 - Improve message when attempting to start an array with
22 insufficient devices. Instead of required the array to be full,
23 we only require it has as many active devices as last time.
24
025 Changes Prior to 1.2.0 release
126 - Fix bug where --daemonise required an argument.
227 - In --assemble --verbose, print appropriate message if device is
3131 #include "md_p.h"
3232
3333 int Create(char *mddev, int mdfd,
34 int chunk, int level, int layout, int size, int raiddisks, int sparedisks,
34 int chunk, int level, int layout, unsigned long size, int raiddisks, int sparedisks,
3535 int subdevs, mddev_dev_t devlist,
3636 int runstop, int verbose, int force)
3737 {
5151 * if runstop==run, or raiddisks diskswere used,
5252 * RUN_ARRAY
5353 */
54 int minsize=0, maxsize=0;
54 unsigned long minsize=0, maxsize=0;
5555 char *mindisc = NULL;
5656 char *maxdisc = NULL;
5757 int dnum;
114114 break;
115115 }
116116
117 if (chunk == 0) {
118 chunk = 64;
119 if (verbose)
120 fprintf(stderr, Name ": chunk size defaults to 64K\n");
117 switch(level) {
118 case 4:
119 case 5:
120 case 0:
121 case -1: /* linear */
122 if (chunk == 0) {
123 chunk = 64;
124 if (verbose)
125 fprintf(stderr, Name ": chunk size defaults to 64K\n");
126 }
127 break;
128 default: /* raid1, multipath */
129 if (chunk) {
130 chunk = 0;
131 if (verbose)
132 fprintf(stderr, Name ": chunk size ignored for this level\n");
133 }
134 break;
121135 }
122136
123137 /* now look at the subdevs */
126140 dnum = 0;
127141 for (dv=devlist; dv; dv=dv->next, dnum++) {
128142 char *dname = dv->devname;
129 int dsize, freesize;
143 unsigned long dsize, freesize;
130144 int fd;
131145 if (strcasecmp(dname, "missing")==0) {
132146 if (first_missing > dnum)
152166 continue;
153167 }
154168 if (dsize < MD_RESERVED_SECTORS*2) {
155 fprintf(stderr, Name ": %s is too small: %dK\n",
169 fprintf(stderr, Name ": %s is too small: %luK\n",
156170 dname, dsize/2);
157171 fail = 1;
158172 close(fd);
163177
164178 if (size && freesize < size) {
165179 fprintf(stderr, Name ": %s is smaller that given size."
166 " %dK < %dK + superblock\n", dname, freesize, size);
180 " %luK < %luK + superblock\n", dname, freesize, size);
167181 fail = 1;
168182 close(fd);
169183 continue;
192206 }
193207 size = minsize;
194208 if (verbose && level>0)
195 fprintf(stderr, Name ": size set to %dK\n", size);
209 fprintf(stderr, Name ": size set to %luK\n", size);
196210 }
197211 if (level >= 1 && ((maxsize-size)*100 > maxsize)) {
198 fprintf(stderr, Name ": largest drive (%s) exceed size (%dK) by more than 1%%\n",
212 fprintf(stderr, Name ": largest drive (%s) exceed size (%luK) by more than 1%%\n",
199213 maxdisc, size);
200214 warn = 1;
201215 }
161161 if (disk.state & (1<<MD_DISK_ACTIVE)) printf(" active");
162162 if (disk.state & (1<<MD_DISK_SYNC)) printf(" sync");
163163 if (disk.state & (1<<MD_DISK_REMOVED)) printf(" removed");
164 if (disk.state == 0) printf(" spare");
164165 }
165166 if ((dv=map_dev(disk.major, disk.minor))) {
166167 if (brief) {
204204 if (dp->state & (1<<MD_DISK_ACTIVE)) printf(" active");
205205 if (dp->state & (1<<MD_DISK_SYNC)) printf(" sync");
206206 if (dp->state & (1<<MD_DISK_REMOVED)) printf(" removed");
207 if (dp->state == 0) printf(" spare");
207208 if ((dv=map_dev(dp->major, dp->minor)))
208209 printf(" %s", dv);
209210 printf("\n");
3333
3434 CC = gcc
3535 CXFLAGS = -ggdb
36 CWFLAGS = -Wall -Werror -Wstrict-prototypes
3637 SYSCONFDIR = /etc
3738 CONFFILE = $(SYSCONFDIR)/mdadm.conf
38 CFLAGS = -Wall -Werror -Wstrict-prototypes -DCONFFILE=\"$(CONFFILE)\" $(CXFLAGS)
39 MAILCMD =/usr/sbin/sendmail -t
40 CFLAGS = $(CWFLAGS) -DCONFFILE=\"$(CONFFILE)\" $(CXFLAGS) -DSendmail=\""$(MAILCMD)"\"
3941
4042 # If you want a static binary, you might uncomment these
4143 # LDFLAGS = -static
9395 $(INSTALL) -D -m 644 mdadm.conf.5 $(DESTDIR)$(MAN5DIR)/mdadm.conf.5
9496
9597 clean :
96 rm -f mdadm $(OBJS) core *.man mdadm.tcc mdadm.uclibc mdadm.static
98 rm -f mdadm $(OBJS) core *.man mdadm.tcc mdadm.uclibc mdadm.static *.orig *.porig *.rej
9799
98100 dist : clean
99101 ./makedist
176176 * in case
177177 */
178178 for (j=0; j<array.nr_disks; j++) {
179 disc.number = j;
179180 if (ioctl(fd, GET_DISK_INFO, &disc))
180181 break;
181182 if (disc.major==0 && disc.minor==0)
4444
4545 int Monitor(mddev_dev_t devlist,
4646 char *mailaddr, char *alert_cmd,
47 int period, int daemonise, int scan,
47 int period, int daemonise, int scan, int oneshot,
4848 char *config)
4949 {
5050 /*
175175
176176
177177 while (! finished) {
178 int new_found = 0;
178179 struct state *st;
179180
180181 if (mdstat)
240241 st->err = 0;
241242 continue;
242243 }
244 if (st->utime == 0 && /* new array */
245 mse && /* is in /proc/mdstat */
246 mse->pattern && strchr(mse->pattern, '_') /* degraded */
247 )
248 alert("DegradedArray", dev, NULL, mailaddr, alert_cmd);
249
243250 if (mse &&
244251 st->percent == -1 &&
245252 mse->percent >= 0)
322329 st->spare_group = NULL;
323330 statelist = st;
324331 alert("NewArray", st->devname, NULL, mailaddr, alert_cmd);
332 new_found = 1;
325333 }
326334 }
327335 /* If an array has active < raid && spare == 0 && spare_group != NULL
373381 close(fd2);
374382 }
375383 }
376
377 sleep(period);
384 if (!new_found) {
385 if (oneshot)
386 break;
387 else
388 sleep(period);
389 }
378390 }
379391 return 0;
380392 }
400412 exit(2);
401413 }
402414 }
403 if (mailaddr && strncmp(event, "Fail", 4)==0) {
415 if (mailaddr &&
416 (strncmp(event, "Fail", 4)==0 ||
417 strncmp(event, "Degrade", 7)==0)) {
404418 FILE *mp = popen(Sendmail, "w");
405419 if (mp) {
406420 char hname[256];
2828
2929 #include "mdadm.h"
3030
31 char Version[] = Name " - v1.2.0 - 13 Mar 2003\n";
31 char Version[] = Name " - v1.3.0 - 29 Jul 2003\n";
3232 /*
3333 * File: ReadMe.c
3434 *
8585 * This mode never exits but just monitors arrays and reports changes.
8686 */
8787
88 char short_options[]="-ABCDEFGQhVvbc:l:p:m:n:x:u:c:d:z:U:sarfRSow";
88 char short_options[]="-ABCDEFGQhVvbc:l:p:m:n:x:u:c:d:z:U:sarfRSow1";
8989 struct option long_options[] = {
9090 {"manage", 0, 0, '@'},
9191 {"misc", 0, 0, '#'},
148148 {"delay", 1, 0, 'd'},
149149 {"daemonise", 0, 0, 'f'},
150150 {"daemonize", 0, 0, 'f'},
151
151 {"oneshot", 0, 0, '1'},
152152
153153 {0, 0, 0, 0}
154154 };
247247 char Help_create[] =
248248 "Usage: mdadm --create device -chunk=X --level=Y --raid-devices=Z devices\n"
249249 "\n"
250 " This usage will initialise a new md array and associate some\n"
251 " devices with it. If enough devices are given to complete the array,\n"
252 " the array will be activated. Otherwise it will be left inactive\n"
253 " to be completed and activated by subsequent management commands.\n"
254 "\n"
255 " As devices are added, they are checked to see if they already contain\n"
250 " This usage will initialise a new md array, associate some\n"
251 " devices with it, and activate the array. In order to create an\n"
252 " array with some devices missing, use the special word 'missing' in\n"
253 " place of the relevant device name.\n"
254 "\n"
255 " Before devices are added, they are checked to see if they already contain\n"
256256 " raid superblocks or filesystems. They are also checked to see if\n"
257257 " the variance in device size exceeds 1%.\n"
258 " If any discrepancy is found, the array will not automatically\n"
259 " be run, though the presence of a '--run' can override this\n"
258 " If any discrepancy is found, the user will be prompted for confirmation\n"
259 " before the array is created. The presence of a '--run' can override this\n"
260260 " caution.\n"
261261 "\n"
262262 " If the --size option is given then only that many kilobytes of each\n"
269269 " --chunk= -c : chunk size of kibibytes\n"
270270 " --rounding= : rounding factor for linear array (==chunk size)\n"
271271 " --level= -l : raid level: 0,1,4,5,linear,multipath and synonyms\n"
272 " --parity= -p : raid5 parity algorithm: {left,right}-{,a}symmetric\n"
272 " --parity= -p : raid5 parity algorithm: {left,right}-{,a}symmetric\n"
273273 " --layout= : same as --parity\n"
274274 " --raid-devices= -n : number of active devices in array\n"
275275 " --spare-devices= -x: number of spares (eXtras) devices in initial array\n"
276276 " --size= -z : Size (in K) of each drive in RAID1/4/5 - optional\n"
277277 " --force -f : Honour devices as listed on command line. Don't\n"
278278 " : insert a missing drive for RAID5.\n"
279 " --run : insist of running the array even if not all\n"
279 " --run -R : insist of running the array even if not all\n"
280280 " : devices are present or some look odd.\n"
281 " --readonly : start the array readonly - not supported yet.\n"
281 " --readonly -o : start the array readonly - not supported yet.\n"
282282 "\n"
283283 ;
284284
406406 " --config= -c : specify a different config file\n"
407407 " --scan -s : find mail-address/program in config file\n"
408408 " --daemonise -f : Fork and continue in child, parent exits\n"
409 " --oneshot -1 : Check for degraded arrays, then exit\n"
409410 ;
410411
411412
0 * mdadm --monitor to monitor failed multipath paths and re-instate them.
1
02 * Maybe make "--help" fit in 80x24 and have a --long-help with more info. DONE
13
24
3434 exit 1
3535 fi
3636 trap "rm $target/$base; exit" 1 2 3
37 ( cd .. ; ln -s mdadm mdadm-$version ; tar chvf - --exclude="TAGS" --exclude='*,v' --exclude='*.o' --exclude mdadm --exclude=mdadm'.[^ch0-9]' --exclude=RCS mdadm-$version ; rm mdadm-$version ) | gzip --best > $target/$base
37 ( cd .. ; ln -s mdadm mdadm-$version ; tar chvf - --exclude="TAGS" --exclude='*~' --exclude=.patches --exclude='*,v' --exclude='*.o' --exclude mdadm --exclude=mdadm'.[^ch0-9]' --exclude=RCS mdadm-$version ; rm mdadm-$version ) | gzip --best > $target/$base
3838 chmod a+r $target/$base
3939 ls -l $target/$base
4040
112112 .SS RAID4
113113
114114 A RAID4 array is like a RAID0 array with an extra device for storing
115 parity. Unlike RAID0, RAID4 also requires that all stripes span all
115 parity. This device is the last of the active devices in the
116 array. Unlike RAID0, RAID4 also requires that all stripes span all
116117 drives, so extra space on devices that are larger than the smallest is
117118 wasted.
118119
00 .\" -*- nroff -*-
1 .TH MDADM 8 "" v1.2.0
1 .TH MDADM 8 "" v1.3.0
22 .SH NAME
33 mdadm \- manage MD devices
44 .I aka
231231
232232 .TP
233233 .BR -l ", " --level=
234 Set raid level. Options are: linear, raid0, 0, stripe, raid1, 1, mirror, raid5, 4,
234 Set raid level. When used with
235 .IR --create ,
236 options are: linear, raid0, 0, stripe, raid1, 1, mirror, raid5, 4,
235237 raid5, 5, multipath, mp. Obviously some of these are synonymous.
236 Only the first 4 are valid when Building.
238
239 When used with
240 .IR --build ,
241 only linear, raid0, 0, stripe are valid.
237242
238243 .TP
239244 .BR -p ", " --parity=
254259 number of spare devices (see below) must equal the number of
255260 .I component-devices
256261 (including "\fBmissing\fP" devices)
257 that are listed on the command line.
262 that are listed on the command line. Setting a value of 1 is probably
263 a mistake and so requires that
264 .B --force
265 be specified first. A value of 1 will then be allowed for linear,
266 multipath, raid0 and raid1. It is never allowed for raid4 or raid5.
267 .br
268 Note that this number cannot be changed once the array has been created.
258269
259270 .TP
260271 .BR -x ", " --spare-devices=
427438 .B --scan
428439 which will only continue monitoring if a mail address or alert program
429440 is found in the config file.
441
442 .TP
443 .BR -1 ", " --oneshot
444 Check arrays only once. This will generate
445 .B NewArray
446 events and more significantly
447 .B DegradedArray
448 events. Running
449 .in +5
450 .B " mdadm --monitor --scan -1"
451 .in -5
452 from a cron script will ensure regular notification of any degraded arrays.
430453
431454 .SH ASSEMBLE MODE
432455
773796 A new md array has been detected in the
774797 .B /proc/mdstat
775798 file.
799
800 .TP
801 .B DegradedArray
802 A newly noticed array appears to be degraded. This message is not
803 generated when
804 .I mdadm
805 notices a drive failure which causes degradation, but only when
806 .I mdadm
807 notices that an array is degraded when it first sees the array.
776808
777809 .TP
778810 .B MoveSpare
8282 char *program = NULL;
8383 int delay = 0;
8484 int daemonise = 0;
85 int oneshot = 0;
8586
8687 int mdfd = -1;
8788
319320 optarg);
320321 exit(2);
321322 }
323 if (raiddisks == 1 && !force) {
324 fprintf(stderr, Name ": '1' is an unusual number of drives for an array, so it is probably\n"
325 " a mistake. If you really mean it you will need to specify --force before\n"
326 " setting the number of drives.\n");
327 exit(2);
328 }
322329 ident.raid_disks = raiddisks;
323330 continue;
324331
340347 exit(2);
341348 }
342349 continue;
350 case O(BUILD,'f'): /* force honouring '-n 1' */
343351 case O(CREATE,'f'): /* force honouring of device list */
344352 case O(ASSEMBLE,'f'): /* force assembly */
345353 case O(MISC,'f'): /* force zero */
440448 case O(MONITOR,'f'): /* daemonise */
441449 daemonise = 1;
442450 continue;
443
451 case O(MONITOR,'1'): /* oneshot */
452 oneshot = 1;
453 continue;
444454
445455 /* now the general management options. Some are applicable
446456 * to other modes. None have arguments.
716726 break;
717727 }
718728 rv= Monitor(devlist, mailaddr, program,
719 delay?delay:60, daemonise, scan, configfile);
729 delay?delay:60, daemonise, scan, oneshot, configfile);
720730 break;
721731 }
722732 exit(rv);
158158
159159
160160 extern int Create(char *mddev, int mdfd,
161 int chunk, int level, int layout, int size, int raiddisks, int sparedisks,
161 int chunk, int level, int layout, unsigned long size, int raiddisks, int sparedisks,
162162 int subdevs, mddev_dev_t devlist,
163163 int runstop, int verbose, int force);
164164
167167 extern int Examine(mddev_dev_t devlist, int brief, int scan, int SparcAdjust);
168168 extern int Monitor(mddev_dev_t devlist,
169169 char *mailaddr, char *alert_cmd,
170 int period, int daemonise, int scan,
170 int period, int daemonise, int scan, int oneshot,
171171 char *config);
172172
173173 extern int Kill(char *dev, int force);
00 Summary: mdadm is used for controlling Linux md devices (aka RAID arrays)
11 Name: mdadm
2 Version: 1.2.0
2 Version: 1.3.0
33 Release: 1
44 Source: http://www.cse.unsw.edu.au/~neilb/source/mdadm/mdadm-%{version}.tgz
55 URL: http://www.cse.unsw.edu.au/~neilb/source/mdadm/