mdadm-1.1.0

This commit is contained in:
Neil Brown 2003-03-02 23:11:38 +00:00
parent 5787fa4906
commit d013a55e94
17 changed files with 236 additions and 301 deletions

41
ANNOUNCE-1.1.0 Normal file
View File

@ -0,0 +1,41 @@
Subject: ANNOUNCE: mdadm 1.1.0 - A tool for managing Soft RAID under Linux
I am pleased to announce the availability of
mdadm version 1.1.0
It is available at
http://www.cse.unsw.edu.au/~neilb/source/mdadm/
and
http://www.{countrycode}.kernel.org/pub/utils/raid/mdadm/
as a source tar-ball and (at the first site) as an SRPM, and as an RPM for i386.
mdadm is a tool for creating, managing and monitoring
device arrays using the "md" driver in Linux, also
known as Software RAID arrays.
Release 1.1.0 contains a number of spell corrections, and bug fixes.
It has improved support for MULTIPATH arrays.
It has some new features including:
--daemonise for use with --monitor
--config=partitions to find devices by examining /proc/partitions
--update=super-minor to change the recorded minor-number for an array
Much of the improvements are due to user feed-back. Thanks are due to all who
gave suggestions and reported problems.
I expect the next major release to be 2.0.0 which will include support for
a new super-block format soon to be supported by 2.5 series kernels.
Development of mdadm is sponsored by CSE@UNSW:
The School of Computer Science and Engineering
at
The University of New South Wales
NeilBrown 03/03/03
The third day
of the third month
of the third year
of the third millenium

View File

@ -103,6 +103,7 @@ int Assemble(char *mddev, int mdfd,
long long events;
time_t utime;
int uptodate;
int state;
int raid_disk;
} *devices;
int *best; /* indexed by raid_disk */
@ -310,6 +311,7 @@ int Assemble(char *mddev, int mdfd,
devices[devcnt].utime = super.utime;
devices[devcnt].raid_disk = super.this_disk.raid_disk;
devices[devcnt].uptodate = 0;
devices[devcnt].state = super.this_disk.state;
if (most_recent < devcnt) {
if (devices[devcnt].events
> devices[most_recent].events)
@ -342,6 +344,12 @@ int Assemble(char *mddev, int mdfd,
int j = best[i];
int event_margin = !force;
if (j < 0) continue;
/* note: we ignore error flags in multipath arrays
* as they don't make sense
*/
if (first_super.level != -4)
if (!(devices[j].state & (1<<MD_DISK_SYNC)))
continue;
if (devices[j].events+event_margin >=
devices[most_recent].events) {
devices[j].uptodate = 1;
@ -391,7 +399,7 @@ int Assemble(char *mddev, int mdfd,
super.events_lo = (devices[most_recent].events)&0xFFFFFFFF;
if (super.level == 5 || super.level == 4) {
/* need to force clean */
super.state = 0;
super.state = (1<<MD_SB_CLEAN);
}
super.sb_csum = calc_sb_csum(&super);
/*DRYRUN*/ if (store_super(fd, &super)) {
@ -484,6 +492,11 @@ This doesnt work yet
i, mddev);
}
}
if (force && (super.level == 4 || super.level == 5) &&
okcnt == super.raid_disks-1) {
super.state = (1<< MD_SB_CLEAN);
change |= 2;
}
if ((force && (change & 2))
|| (old_linux && (change & 1))) {

View File

@ -1,4 +1,14 @@
Changes Prior to this release
Changes Prior to 1.1.0 release
- add --deamonise flag for --monitor - forks and prints pid to stdout
- Fix bug so we REALLY clear dirty flag with -Af
- -Db now prints a 'devices=' word for each array.
- "mdadm -A /dev/md0" will get info from configfile, even without scan
- When assembling multipath arrays, ignore devices which are flagged
as having errors.
- take --super-minor=dev to mean "use the minor number of the mddev
being assembled.
- take --config=none to mean "completely ignore config file"
- Make --monitor require --scan or a device list.
Changes Prior to 1.0.9 release
- Documentation updates including kernel parameters documented
in md.4
@ -12,13 +22,13 @@ Changes Prior to 1.0.9 release
- Fix printing of Gibibytes - calc was wrong.
- Fix printing of Array Size in --detail when very big.
- --monitor no longer tries to work for raid0 or linear as these
have nothing to be monitors.
have nothing to be monitored.
- The word 'partitions' on a DEVICE line will cause all partitions
listed in /proc/partitions to be considered
- If the config file is called 'partitions' then it will be treated
as though it contained exactly 'device partitions' so e.g.
mdadm -Ebsc partitions
will fill all raid partitions easily.
will find all raid partitions easily.
- successfully assemble multipath devices by ignoring raid_disk
value from superblock (it is always the same).
- --assemble not tied to MD_SB_DISKS limit quite so much

View File

@ -44,6 +44,7 @@ int Detail(char *dev, int brief)
int d;
time_t atime;
char *c;
char *devices = NULL;
mdp_super_t super;
int have_super = 0;
@ -163,7 +164,15 @@ int Detail(char *dev, int brief)
if (disk.state & (1<<MD_DISK_REMOVED)) printf(" removed");
}
if ((dv=map_dev(disk.major, disk.minor))) {
if (!brief) printf(" %s", dv);
if (brief) {
if (devices) {
devices = realloc(devices,
strlen(devices)+1+strlen(dv)+1);
strcat(strcat(devices,","),dv);
} else
devices = strdup(dv);
} else
printf(" %s", dv);
if (!have_super && (disk.state & (1<<MD_DISK_ACTIVE))) {
/* try to read the superblock from this device
* to get more info
@ -189,6 +198,7 @@ int Detail(char *dev, int brief)
if (!brief)
printf("\n Events : %d.%d\n", super.events_hi, super.events_lo);
}
if (brief && devices) printf("\n devices=%s", devices);
if (brief) printf("\n");
return 0;
}

View File

@ -50,6 +50,9 @@ MAN4DIR = $(MANDIR)/man4
MAN5DIR = $(MANDIR)/man5
MAN8DIR = $(MANDIR)/man8
KLIBC=/home/src/klibc/klibc-0.77
OBJS = mdadm.o config.o mdstat.o ReadMe.o util.o Manage.o Assemble.o Build.o Create.o Detail.o Examine.o Monitor.o dlink.o Kill.o Query.o
SRCS = mdadm.c config.c mdstat.c ReadMe.c util.c Manage.c Assemble.c Build.c Create.c Detail.c Examine.c Monitor.c dlink.c Kill.c Query.c
@ -69,6 +72,10 @@ mdadm.tcc : $(SRCS) mdadm.h
mdadm.uclibc : $(SRCS) mdadm.h
$(UCLIBC_GCC) -DUCLIBC -o mdadm.uclibc $(SRCS)
mdadm.klibc : $(SRCS) mdadm.h
rm -f $(OBJS)
gcc -nostdinc -iwithprefix include -I$(KLIBC)/klibc/include -I$(KLIBC)/linux/include -I$(KLIBC)/klibc/arch/i386/include -I$(KLIBC)/klibc/include/bits32 $(CFLAGS) $(SRCS)
mdadm.man : mdadm.8
nroff -man mdadm.8 > mdadm.man
@ -87,7 +94,7 @@ install : mdadm mdadm.8 md.4 mdadm.conf.5
$(INSTALL) -D -m 644 mdadm.conf.5 $(DESTDIR)$(MAN5DIR)/mdadm.conf.5
clean :
rm -f mdadm $(OBJS) core *.man mdadm.tcc mdadm.uclibc
rm -f mdadm $(OBJS) core *.man mdadm.tcc mdadm.uclibc mdadm.static
dist : clean
./makedist

View File

@ -45,7 +45,7 @@ static char *percentalerts[] = {
int Monitor(mddev_dev_t devlist,
char *mailaddr, char *alert_cmd,
int period, int scan,
int period, int daemonise, int scan,
char *config)
{
/*
@ -105,12 +105,37 @@ int Monitor(mddev_dev_t devlist,
int finished = 0;
struct mdstat_ent *mdstat = NULL;
if (!mailaddr && scan)
if (!mailaddr) {
mailaddr = conf_get_mailaddr(config);
if (!alert_cmd && scan)
if (mailaddr && ! scan)
printf("mdadm: Monitor using email address \"%s\" from config file\n",
mailaddr);
}
if (!alert_cmd) {
alert_cmd = conf_get_program(config);
if (alert_cmd && ! scan)
printf("mdadm: Monitor using program \"%s\" from config file\n",
alert_cmd);
}
if (scan && !mailaddr && !alert_cmd)
return 0;
return 1;
if (daemonise) {
int pid = fork();
if (pid > 0) {
printf("%d\n", pid);
return 0;
}
if (pid < 0) {
perror("daemonise");
return 1;
}
close(0);
open("/dev/null", 3);
dup2(0,1);
dup2(0,2);
setsid();
}
if (devlist == NULL) {
mddev_ident_t mdlist = conf_get_ident(config, NULL);
@ -121,7 +146,7 @@ int Monitor(mddev_dev_t devlist,
st->devname = strdup(mdlist->devname);
st->utime = 0;
st->next = statelist;
st->err = 1;
st->err = 0;
st->devnum = -1;
st->percent = -2;
if (mdlist->spare_group)
@ -139,7 +164,7 @@ int Monitor(mddev_dev_t devlist,
st->devname = strdup(dv->devname);
st->utime = 0;
st->next = statelist;
st->err = 1;
st->err = 0;
st->devnum = -1;
st->percent = -2;
st->spare_group = NULL;

View File

@ -29,7 +29,7 @@
#include "mdadm.h"
char Version[] = Name " - v1.0.9 - 12 Feb 2003\n";
char Version[] = Name " - v1.1.0 - 3 Mar 2003\n";
/*
* File: ReadMe.c
*
@ -146,6 +146,8 @@ struct option long_options[] = {
{"program", 1, 0, 'p'},
{"alert", 1, 0, 'p'},
{"delay", 1, 0, 'd'},
{"daemonise", 1, 0, 'f'},
{"daemonize", 1, 0, 'f'},
{0, 0, 0, 0}
@ -398,6 +400,7 @@ char Help_monitor[] =
" --delay= -d : seconds of delay between polling state. default=60\n"
" --config= -c : specify a different config file\n"
" --scan -s : find mail-address/program in config file\n"
" --daemonise -f : Fork and continue in child, parent exits\n"
;

260
TAGS
View File

@ -1,260 +0,0 @@
Assemble.c,22
int Assemble(34,1176
Build.c,100
#define REGISTER_DEV 32,1140
#define START_MD 33,1181
#define STOP_MD 34,1222
int Build(36,1264
COPYING,99
program will will52,2561
program proprietary.proprietary53,2632
PROGRAM PROVE PROVE267,14397
ChangeLog,294
- When --assemble --force,13,443
- When marking drives as not-failed in the superblock,16,627
are passed as unsigned lock,23,1044
- If HOT_ADD_DISK failes for -a,24,1100
if we cannot read from the array,25,1166
and mdctl.conf compatible description with uuid=31,1443
Create.c,20
int Create(34,1176
Detail.c,20
int Detail(34,1176
Examine.c,21
int Examine(38,1285
Kill.c,18
int Kill(37,1237
Makefile,12
CC 30,1091
Manage.c,161
#define REGISTER_DEV 34,1176
#define START_MD 35,1217
#define STOP_MD 36,1258
int Manage_ro(38,1300
int Manage_runstop(75,2154
int Manage_subdevs(118,3161
Monitor.c,49
int Monitor(37,1283
static void alert(175,4727
ReadMe.c,266
char Version[32,1140
char short_options[81,3226
struct option long_options[82,3290
char Usage[140,4885
char Help[145,4942
char Help_create[218,8393
char Help_build[245,9615
char Help_assemble[258,10155
mapping_t r5layout[317,13101
mapping_t pers[331,13317
TODO,590
* write proc.c to parse /proc/mdstat file,5,65
Build list of arrays: name,6,140
* --detail --scan to read mdctl.conf,8,189
* --detail --scan to read mdctl.conf, and then iterate over these,8,189
- set md_minor,34,933
- for create raid5,35,976
all working,36,1019
one missing,37,1050
one missing, one spare,37,1050
- when RUN_ARRAY,40,1152
- get --detail to extract extra stuff from superblock,42,1206
- when --assemble --scan,48,1368
- when --assemble --scan, if an underlying device is an md device,48,1368
ARRAY lines in config file to have super_minor=62,1797
config.c,479
char DefaultConfFile[68,2401
char *keywords[70,2446
int match_keyword(77,2645
char *conf_word(97,3153
char *conf_line(163,4744
void free_line(184,5046
struct conf_dev conf_dev195,5188
} *cdevlist 198,5249
int devline(202,5272
mddev_ident_t mddevlist 220,5595
mddev_ident_t *mddevlp 221,5627
void arrayline(223,5665
int loaded 303,7978
void load_conffile(305,7995
mddev_ident_t conf_get_ident(338,8486
mddev_dev_t conf_get_devs(348,8688
int match_oneof(383,9316
dlink.c,177
void *dl_head(11,180
void dl_free(20,289
void dl_init(26,363
void dl_insert(32,430
void dl_add(40,598
void dl_del(48,763
char *dl_strndup(57,969
char *dl_strdup(73,1176
dlink.h,193
struct __dl_head__dl_head5,100
#define dl_alloc(dl_alloc11,187
#define dl_new(dl_new12,297
#define dl_newv(dl_newv13,341
#define dl_next(dl_next15,391
#define dl_prev(dl_prev16,461
makedist,127
target=3,11
( cd .. ; ln -s mdctl mdctl-$version 19,352
( cd .. ; ln -s mdctl mdctl-$version ; tar czhvf - --exclude=19,352
md_p.h,1316
#define _MD_P_H16,582
#define MD_RESERVED_BYTES 44,1414
#define MD_RESERVED_SECTORS 45,1453
#define MD_RESERVED_BLOCKS 46,1508
#define MD_NEW_SIZE_SECTORS(MD_NEW_SIZE_SECTORS48,1570
#define MD_NEW_SIZE_BLOCKS(MD_NEW_SIZE_BLOCKS49,1659
#define MD_SB_BYTES 51,1746
#define MD_SB_WORDS 52,1773
#define MD_SB_BLOCKS 53,1813
#define MD_SB_SECTORS 54,1863
#define MD_SB_GENERIC_OFFSET 59,1960
#define MD_SB_PERSONALITY_OFFSET 60,1992
#define MD_SB_DISKS_OFFSET 61,2028
#define MD_SB_DESCRIPTOR_OFFSET 62,2060
#define MD_SB_GENERIC_CONSTANT_WORDS 64,2098
#define MD_SB_GENERIC_STATE_WORDS 65,2138
#define MD_SB_GENERIC_WORDS 66,2175
#define MD_SB_PERSONALITY_WORDS 67,2263
#define MD_SB_DESCRIPTOR_WORDS 68,2299
#define MD_SB_DISKS 69,2334
#define MD_SB_DISKS_WORDS 70,2359
#define MD_SB_RESERVED_WORDS 71,2423
#define MD_SB_EQUAL_WORDS 72,2553
#define MD_DISK_FAULTY 77,2691
#define MD_DISK_ACTIVE 78,2752
#define MD_DISK_SYNC 79,2814
#define MD_DISK_REMOVED 80,2878
typedef struct mdp_device_descriptor_s mdp_device_descriptor_s82,2946
} mdp_disk_t;mdp_disk_t89,3310
#define MD_SB_MAGIC 91,3325
#define MD_SB_CLEAN 96,3390
#define MD_SB_ERRORS 97,3413
typedef struct mdp_superblock_s mdp_superblock_s99,3438
} mdp_super_t;mdp_super_t164,5835
static inline __u64 md_event(166,5851
md_u.h,1118
#define _MD_U_H16,590
#define RAID_VERSION 21,634
#define GET_ARRAY_INFO 22,693
#define GET_DISK_INFO 23,757
#define PRINT_RAID_DEBUG 24,819
#define RAID_AUTORUN 25,865
#define CLEAR_ARRAY 28,929
#define ADD_NEW_DISK 29,971
#define HOT_REMOVE_DISK 30,1032
#define SET_ARRAY_INFO 31,1078
#define SET_DISK_INFO 32,1142
#define WRITE_RAID_INFO 33,1186
#define UNPROTECT_ARRAY 34,1232
#define PROTECT_ARRAY 35,1278
#define HOT_ADD_DISK 36,1322
#define SET_DISK_FAULTY 37,1365
#define RUN_ARRAY 40,1424
#define START_ARRAY 41,1478
#define STOP_ARRAY 42,1520
#define STOP_ARRAY_RO 43,1561
#define RESTART_ARRAY_RW 44,1605
typedef struct mdu_version_s mdu_version_s46,1652
} mdu_version_t;mdu_version_t50,1724
typedef struct mdu_array_info_s mdu_array_info_s52,1742
} mdu_array_info_t;mdu_array_info_t83,2516
typedef struct mdu_disk_info_s mdu_disk_info_s85,2537
} mdu_disk_info_t;mdu_disk_info_t95,2693
typedef struct mdu_start_info_s mdu_start_info_s97,2713
} mdu_start_info_t;mdu_start_info_t106,2857
typedef struct mdu_param_smdu_param_s108,2878
} mdu_param_t;mdu_param_t113,3014
mdctl.8,252
real block devices. This allows multiple devices 14,241
{left,right}-{,a}symmetric,185,4006
{left,right}-{,a}symmetric, la,185,4006
{left,right}-{,a}symmetric, la, ra,185,4006
{left,right}-{,a}symmetric, la, ra, ls,185,4006
.BR --layout=188,4087
mdctl.c,64
int open_mddev(33,1158
int main(50,1477
#define O(O177,4288
mdctl.h,855
#define __USE_LARGEFILE6430,1120
#define MD_MAJOR 47,1496
#define Name 52,1536
extern char short_options[54,1558
extern struct option long_options[55,1587
extern char Version[56,1624
extern char Version[], Usage[56,1624
extern char Version[], Usage[], Help[56,1624
extern char Version[], Usage[], Help[], Help_create[56,1624
extern char Version[], Usage[], Help[], Help_create[], Help_build[56,1624
extern char Version[], Usage[], Help[], Help_create[], Help_build[], Help_assemble[56,1624
typedef struct mddev_ident_s mddev_ident_s68,2060
} *mddev_ident_t;mddev_ident_t83,2389
typedef struct mddev_dev_s mddev_dev_s86,2456
} *mddev_dev_t;mddev_dev_t92,2644
typedef struct mapping mapping94,2661
} mapping_t;mapping_t97,2709
#define Sendmail 100,2740
extern mapping_t r5layout[105,2884
extern mapping_t r5layout[], pers[105,2884
mdctl.spec,235
Summary: mdctl is used for controlling Linux md devices 1,0
option of using a configuration file,18,630
raidtools uses a configuration file to describe how to create a RAID array,21,718
Further,23,871
stopping a raid array,24,941
raid5extend.c,39
int phys2log(2,1
raid5_extend(46,902
util.c,600
int parse_uuid(40,1359
int md_get_version(82,2122
int get_linux_version(101,2481
int enough(113,2678
int same_uuid(129,2928
void uuid_from_super(139,3057
int compare_super(153,3334
int load_super(187,4297
int store_super(227,4955
int check_ext2(253,5326
int check_reiser(284,6089
int check_raid(308,6645
int ask(324,7008
char *map_num(344,7373
int map_name(354,7508
struct devmap devmap369,7837
} *devlist 373,7916
int devlist_ready 374,7935
#define __USE_XOPEN_EXTENDED376,7959
int add_dev(380,8008
char *map_dev(396,8375
int calc_sb_csum(412,8650
char *human_size(428,9046

11
TODO
View File

@ -1,4 +1,13 @@
* --assemble could have a --update option.
* maybe "missing" instead of <bold>missing</> in doco DONE
* possibly wait for resync to start, or even finish while assembling.- NO
* -Db should have a devices= entry if possible. - DONE
* when assembling multipath arrays, ignore any error indicators. - DONE
* rationalise --monitor usage:
mdadm --monitor
doesn't do as expected. DONE
* --assemble could have a --update option. - DONE
following word can be:
sparc2.2
super-minor

View File

@ -379,8 +379,13 @@ void load_conffile(char *conffile)
if (conffile == NULL)
conffile = DefaultConfFile;
if (strcmp(conffile, "none") == 0) {
loaded = 1;
return;
}
if (strcmp(conffile, "partitions")==0) {
load_partitions();
loaded = 1;
return;
}
f = fopen(conffile, "r");

View File

@ -21,7 +21,7 @@ then
exit 1
fi
trap "rm $target/$base; exit" 1 2 3
( cd .. ; ln -s mdadm mdadm-$version ; tar chvf - --exclude='*,v' --exclude='*.o' --exclude mdadm --exclude=mdadm'.[^ch0-9]' --exclude=RCS mdadm-$version ; rm mdadm-$version ) | gzip --best > $target/$base
( 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
chmod a+r $target/$base
ls -l $target/$base

72
mdadm.8
View File

@ -1,5 +1,5 @@
.\" -*- nroff -*-
.TH MDADM 8
.TH MDADM 8 "" v1.1.0
.SH NAME
mdadm \- manage MD devices
.I aka
@ -27,14 +27,16 @@ md devices,
(striping),
.B RAID1
(mirroring),
.B RAID4
.BR RAID4 ,
.BR RAID5 ,
and
.B RAID5.
Recent kernels (2002) also support a mode known as
.BR MULTIPATH .
.B mdadm
only provides limited support for MULTIPATH as yet.
.B MULTIPATH is not a Software RAID mechanism, but does involve
multiple devices. For
.B MULTIPATH
each device is a path to one common physical storage device.
.B mdadm
is a program that can be used to create, manage, and monitor
@ -186,6 +188,11 @@ will act as though the config file contained exactly
and will read
.B /proc/partitions
to find a list of devices to scan.
If the word
.B none
is given for the config file, then
.I mdadm
will act as though the config file were empty.
.TP
.BR -s ", " --scan
@ -241,9 +248,8 @@ same as --parity
Specify the number of active devices in the array. This, plus the
number of spare devices (see below) must equal the number of
.I component-devices
(including
.B missing
devices) that are listed on the command line.
(including "\fBmissing\fP" devices)
that are listed on the command line.
.TP
.BR -x ", " --spare-devices=
@ -278,6 +284,16 @@ don't have this minor number are excluded. If you create an array as
/dev/md1, then all superblocks will contain the minor number 1, even if
the array is later assembled as /dev/md2.
Giving the literal word "dev" for
.B --super-minor
will cause
.I mdadm
to use the minor number of the md device that is being assembled.
e.g. when assembling
.BR /dev/md0 ,
.M --super-minor=dev
will look for super blocks with a minor number of 0.
.TP
.BR -f ", " --force
Assemble the array even if some superblocks appear out-of-date
@ -395,6 +411,18 @@ Give a delay in seconds.
polls the md arrays and then waits this many seconds before polling
again. The default is 60 seconds.
.TP
.BR -f ", " --daemonise
Tell
.B mdadm
to run as a background daemon if it decides to monitor anything. This
causes it to fork and run in the child, and to disconnect form the
terminal. The process id of the child is written to stdout.
This is useful with
.B --scan
which will only continue monitoring if a mail address or alert program
is found in the config file.
.SH ASSEMBLE MODE
.HP 12
@ -423,6 +451,14 @@ devices and assembly is attempted.
In the third (where no devices are listed) all md devices that are
listed in the configuration file are assembled.
If precisely one device is listed, but
.B --scan
is not given, that
.I mdadm
acts as though
.B --scan
was given and identify information is extracted from the configuration file.
The identity can be given with the
.B --uuid
option, with the
@ -438,7 +474,7 @@ any array.
The config file is only used if explicitly named with
.B --config
or requested with
or requested with (a possibly implicit)
.B --scan.
In the later case,
.B /etc/mdadm.conf
@ -507,16 +543,15 @@ the presence of a
can override this caution.
To create a "degraded" array in which some devices are missing, simply
give the word
.B missing
give the word "\fBmissing\fP"
in place of a device name. This will cause
.B mdadm
to leave the corresponding slot in the array empty.
For a RAID4 or RAID5 array at most one slot can be
.BR missing .
"\fBmissing\fP".
For a RAID1 array, only one real device needs to be given. All of the
others can be
.BR missing .
"\fBmissing\fP".
'''If the
'''.B --size
@ -851,6 +886,13 @@ and assemble
.B /dev/md0
out of all such devices with a RAID superblock with a minor number of 0.
.B " mdadm --monitor --scan --daemonise > /var/run/mdadm"
.br
If config file contains a mail address or alert program, run mdadm in
the background in monitor mode monitoring all md devices. Also write
pid of mdadm daemon to
.BR /var/run/mdadm .
.B " mdadm --create --help"
.br
Providew help about the Create mode.

48
mdadm.c
View File

@ -82,6 +82,7 @@ int main(int argc, char *argv[])
char *mailaddr = NULL;
char *program = NULL;
int delay = 0;
int daemonise = 0;
int mdfd = -1;
@ -358,15 +359,19 @@ int main(int argc, char *argv[])
continue;
case O(ASSEMBLE,'m'): /* super-minor for array */
if (ident.super_minor >= 0) {
if (ident.super_minor != -1) {
fprintf(stderr, Name ": super-minor cannot be set twice. "
"Second value: %s.\n", optarg);
exit(2);
}
ident.super_minor = strtoul(optarg, &cp, 10);
if (!optarg[0] || *cp) {
fprintf(stderr, Name ": Bad super-minor number: %s.\n", optarg);
exit(2);
if (strcmp(optarg, "dev")==0)
ident.super_minor = -2;
else {
ident.super_minor = strtoul(optarg, &cp, 10);
if (!optarg[0] || *cp) {
fprintf(stderr, Name ": Bad super-minor number: %s.\n", optarg);
exit(2);
}
}
continue;
@ -429,6 +434,9 @@ int main(int argc, char *argv[])
}
}
continue;
case O(MONITOR,'f'): /* daemonise */
daemonise = 1;
continue;
/* now the general management options. Some are applicable
@ -535,6 +543,11 @@ int main(int argc, char *argv[])
mdfd = open_mddev(devlist->devname);
if (mdfd < 0)
exit(1);
if (ident.super_minor == -2) {
struct stat stb;
fstat(mdfd, &stb);
ident.super_minor = MINOR(stb.st_rdev);
}
}
rv = 0;
@ -552,7 +565,25 @@ int main(int argc, char *argv[])
rv = Manage_runstop(devlist->devname, mdfd, runstop);
break;
case ASSEMBLE:
if (!scan)
if (devs_found == 1 && ident.uuid_set == 0 &&
ident.super_minor == -1 && !scan ) {
/* Only a device has been given, so get details from config file */
mddev_ident_t array_ident = conf_get_ident(configfile, devlist->devname);
mdfd = open_mddev(devlist->devname);
if (mdfd < 0)
rv |= 1;
else {
if (array_ident == NULL) {
fprintf(stderr, Name ": %s not identified in config file.\n",
devlist->devname);
rv |= 1;
}
else
rv |= Assemble(devlist->devname, mdfd, array_ident, configfile,
NULL,
readonly, runstop, update, verbose, force);
}
} else if (!scan)
rv = Assemble(devlist->devname, mdfd, &ident, configfile,
devlist->next,
readonly, runstop, update, verbose, force);
@ -676,14 +707,13 @@ int main(int argc, char *argv[])
}
break;
case MONITOR:
/*
if (!devlist && !scan) {
fprintf(stderr, Name ": Cannot monitor: need --scan or at least one device\n");
rv = 1;
break;
}
*/ rv= Monitor(devlist, mailaddr, program,
delay?delay:60, scan, configfile);
rv= Monitor(devlist, mailaddr, program,
delay?delay:60, daemonise, scan, configfile);
break;
}
exit(rv);

View File

@ -168,7 +168,7 @@ extern int Query(char *dev);
extern int Examine(mddev_dev_t devlist, int brief, int scan, int SparcAdjust);
extern int Monitor(mddev_dev_t devlist,
char *mailaddr, char *alert_cmd,
int period, int scan,
int period, int daemonise, int scan,
char *config);
extern int Kill(char *dev, int force);

View File

@ -1,6 +1,6 @@
Summary: mdadm is used for controlling Linux md devices (aka RAID arrays)
Name: mdadm
Version: 1.0.9
Version: 1.1.0
Release: 1
Source: http://www.cse.unsw.edu.au/~neilb/source/mdadm/mdadm-%{version}.tgz
URL: http://www.cse.unsw.edu.au/~neilb/source/mdadm/

Binary file not shown.