mdadm-0.7

This commit is contained in:
Neil Brown 2002-03-08 00:03:52 +00:00
parent cd29a5c835
commit 9a9dab3670
21 changed files with 431 additions and 266 deletions

View File

@ -1,5 +1,5 @@
/*
* mdctl - manage Linux "md" devices aka RAID arrays.
* mdadm - manage Linux "md" devices aka RAID arrays.
*
* Copyright (C) 2001-2002 Neil Brown <neilb@cse.unsw.edu.au>
*
@ -27,7 +27,7 @@
* Australia
*/
#include "mdctl.h"
#include "mdadm.h"
#include "md_u.h"
#include "md_p.h"

View File

@ -1,5 +1,5 @@
/*
* mdctl - manage Linux "md" devices aka RAID arrays.
* mdadm - manage Linux "md" devices aka RAID arrays.
*
* Copyright (C) 2001-2002 Neil Brown <neilb@cse.unsw.edu.au>
*
@ -27,7 +27,7 @@
* Australia
*/
#include "mdctl.h"
#include "mdadm.h"
#define REGISTER_DEV _IO (MD_MAJOR, 1)
#define START_MD _IO (MD_MAJOR, 2)

View File

@ -1,7 +1,15 @@
Changes Prior to 0.7 release
- Fix makefile to install binary at /sbin and not /sbin/sbin
Also install man page.
- Add --zero-superblock based on --destroywithextremeprejudice
from Dale Stephenson <steph@snapserver.com>
- change name to mdadm. It is palandromic, and much nicer to pronouce.
Changes Prior to 0.6 release
- Remove the limit on the number of device names that can be
- Remove the limit on the number of device names that can be
given on the command line.
- Fix bug in --assemble --force where it would only update a
single superblock.

View File

@ -1,5 +1,5 @@
/*
* mdctl - manage Linux "md" devices aka RAID arrays.
* mdadm - manage Linux "md" devices aka RAID arrays.
*
* Copyright (C) 2001-2002 Neil Brown <neilb@cse.unsw.edu.au>
*
@ -27,7 +27,7 @@
* Australia
*/
#include "mdctl.h"
#include "mdadm.h"
#include "md_u.h"
#include "md_p.h"

View File

@ -1,5 +1,5 @@
/*
* mdctl - manage Linux "md" devices aka RAID arrays.
* mdadm - manage Linux "md" devices aka RAID arrays.
*
* Copyright (C) 2001-2002 Neil Brown <neilb@cse.unsw.edu.au>
*
@ -27,7 +27,7 @@
* Australia
*/
#include "mdctl.h"
#include "mdadm.h"
#include "md_p.h"
#include "md_u.h"

View File

@ -1,5 +1,5 @@
/*
* mdctl - manage Linux "md" devices aka RAID arrays.
* mdadm - manage Linux "md" devices aka RAID arrays.
*
* Copyright (C) 2001-2002 Neil Brown <neilb@cse.unsw.edu.au>
*
@ -27,7 +27,7 @@
* Australia
*/
#include "mdctl.h"
#include "mdadm.h"
#include "dlink.h"
#if ! defined(__BIG_ENDIAN) && ! defined(__LITTLE_ENDIAN)
@ -50,7 +50,7 @@ int Examine(mddev_dev_t devlist, int brief, char *conffile)
*
* utime, state etc
*
* If (brief) gather devices for same array and just print a mdctl.conf line including devices=
* If (brief) gather devices for same array and just print a mdadm.conf line including devices=
* if devlist==NULL, use conf_get_devs(
*/
int fd;

83
Kill.c Normal file
View File

@ -0,0 +1,83 @@
/*
* mdadm - manage Linux "md" devices aka RAID arrays.
*
* Copyright (C) 2001-2002 Neil Brown <neilb@cse.unsw.edu.au>
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Neil Brown
* Email: <neilb@cse.unsw.edu.au>
* Paper: Neil Brown
* School of Computer Science and Engineering
* The University of New South Wales
* Sydney, 2052
* Australia
*
* Added by Dale Stephenson
* steph@snapserver.com
*/
#include "mdadm.h"
#include "md_u.h"
#include "md_p.h"
int Kill(char *dev, int force)
{
/*
* Nothing fancy about Kill. It just zeroes out a superblock
* Definitely not safe.
*/
mdp_super_t super;
int fd, rv = 0;
fd = open(dev, O_RDWR);
if (fd < 0) {
fprintf(stderr, Name ": Couldn't open %s for write - not zeroing\n",
dev);
return 1;
}
rv = load_super(fd, &super);
if (force && rv >= 5)
rv = 0; /* ignore bad data in superblock */
switch(rv) {
case 1:
fprintf(stderr, Name ": cannot file device size for %s: %s\n",
dev, strerror(errno));
break;
case 2:
fprintf(stderr, Name ": %s is too small for md.\n", dev);
break;
case 3:
case 4:
fprintf(stderr, Name ": cannot access superblock on %s.\n", dev);
break;
case 5:
case 6:
fprintf(stderr, Name ": %s does not appear to have an MD superblock.\n", dev);
break;
}
if (!rv) {
memset(&super, 0, sizeof(super));
if (store_super(fd, &super)) {
fprintf(stderr, Name ": Could not zero superblock on %s\n",
dev);
rv = 1;
}
}
close(fd);
return rv;
}

View File

@ -1,5 +1,5 @@
#
# mdctl - manage Linux "md" devices aka RAID arrays.
# mdadm - manage Linux "md" devices aka RAID arrays.
#
# Copyright (C) 2001-2002 Neil Brown <neilb@cse.unsw.edu.au>
#
@ -31,25 +31,28 @@ CC = gcc
CFLAGS = -Wall,error,strict-prototypes -ggdb
INSTALL = /usr/bin/install
DESTDIR = /sbin
DESTDIR = /.
BINDIR = /sbin
MANDIR = /usr/share/man/man8
OBJS = mdctl.o config.o ReadMe.o util.o Manage.o Assemble.o Build.o Create.o Detail.o Examine.o Monitor.o dlink.o
OBJS = mdadm.o config.o ReadMe.o util.o Manage.o Assemble.o Build.o Create.o Detail.o Examine.o Monitor.o dlink.o Kill.o
all : mdctl mdctl.man
all : mdadm mdadm.man
mdctl : $(OBJS)
$(CC) -o mdctl $^
mdadm : $(OBJS)
$(CC) -o mdadm $^
mdctl.man : mdctl.8
nroff -man mdctl.8 > mdctl.man
mdadm.man : mdadm.8
nroff -man mdadm.8 > mdadm.man
$(OBJS) : mdctl.h
$(OBJS) : mdadm.h
install : mdctl
$(INSTALL) -m 755 mdctl $(DESTDIR)/sbin
install : mdadm mdadm.8
$(INSTALL) -m 755 mdadm $(DESTDIR)/$(BINDIR)
$(INSTALL) -m 644 mdadm.8 $(DESTDIR)/$(MANDIR)
clean :
rm -f mdctl $(OBJS) core mdctl.man
rm -f mdadm $(OBJS) core mdadm.man
dist : clean
./makedist

View File

@ -1,5 +1,5 @@
/*
* mdctl - manage Linux "md" devices aka RAID arrays.
* mdadm - manage Linux "md" devices aka RAID arrays.
*
* Copyright (C) 2001-2002 Neil Brown <neilb@cse.unsw.edu.au>
*
@ -27,7 +27,7 @@
* Australia
*/
#include "mdctl.h"
#include "mdadm.h"
#include "md_u.h"
#include "md_p.h"

View File

@ -1,5 +1,5 @@
/*
* mdctl - manage Linux "md" devices aka RAID arrays.
* mdadm - manage Linux "md" devices aka RAID arrays.
*
* Copyright (C) 2001-2002 Neil Brown <neilb@cse.unsw.edu.au>
*
@ -27,7 +27,7 @@
* Australia
*/
#include "mdctl.h"
#include "mdadm.h"
#include "md_p.h"
#include "md_u.h"
#include <sys/signal.h>

View File

@ -1,5 +1,5 @@
/*
* mdctl - manage Linux "md" devices aka RAID arrays.
* mdadm - manage Linux "md" devices aka RAID arrays.
*
* Copyright (C) 2001-2002 Neil Brown <neilb@cse.unsw.edu.au>
*
@ -27,19 +27,19 @@
* Australia
*/
#include "mdctl.h"
#include "mdadm.h"
char Version[] = Name " - v0.6 - 7 March 2002\n";
char Version[] = Name " - v0.7 - 8 March 2002\n";
/*
* File: ReadMe.c
*
* This file contains general comments about the implementation
* and the various usage messages that can be displayed by mdctl
* and the various usage messages that can be displayed by mdadm
*
* mdctl is a single program that can be used to control Linux md devices.
* mdadm is a single program that can be used to control Linux md devices.
* It is intended to provide all the functionality of the mdtools and
* raidtools but with a very different interface.
* mdctl can perform all functions without a configuration file.
* mdadm can perform all functions without a configuration file.
* There is the option of using a configuration file, but not in the same
* way that raidtools uses one
* raidtools uses a configuration file to describe how to create a RAID
@ -48,7 +48,7 @@ char Version[] = Name " - v0.6 - 7 March 2002\n";
* file for such things as stopping a raid array which needs to know
* nothing about the array.
*
* The configuration file that can be used by mdctl lists two
* The configuration file that can be used by mdadm lists two
* different things:
* 1/ a mapping from uuid to md device to identify which arrays are
* expect and what names (numbers) they should be given
@ -58,7 +58,7 @@ char Version[] = Name " - v0.6 - 7 March 2002\n";
*/
/*
* mdctl has 4 major modes of operation:
* mdadm has 4 major modes of operation:
* 1/ Create
* This mode is used to create a new array with a superbock
* It can progress in several step create-add-add-run
@ -66,7 +66,7 @@ char Version[] = Name " - v0.6 - 7 March 2002\n";
* 2/ Assemble
* This mode is used to assemble the parts of a previously created
* array into an active array. Components can be explicitly given
* or can be searched for. mdctl (optionally) check that the components
* or can be searched for. mdadm (optionally) check that the components
* do form a bonafide array, and can, on request, fiddle superblock
* version numbers so as to assemble a faulty array.
* 3/ Build
@ -87,6 +87,8 @@ struct option long_options[] = {
{"detail", 0, 0, 'D'},
{"examine", 0, 0, 'E'},
{"follow", 0, 0, 'F'},
{"grow", 0, 0, 'G'}, /* not yet implemented */
{"zero-superblock", 0, 0, 'H'},
/* synonyms */
{"monitor", 0, 0, 'F'},
@ -136,21 +138,21 @@ struct option long_options[] = {
};
char Usage[] =
"Usage: mdctl --help\n"
"Usage: mdadm --help\n"
" for help\n"
;
char Help[] =
"Usage: mdctl --create device options...\n"
" mdctl --assemble device options...\n"
" mdctl --build device options...\n"
" mdctl --detail device\n"
" mdctl --examine device\n"
" mdctl --follow options...\n"
" mdctl device options...\n"
" mdctl is used for controlling Linux md devices (aka RAID arrays)\n"
"Usage: mdadm --create device options...\n"
" mdadm --assemble device options...\n"
" mdadm --build device options...\n"
" mdadm --detail device\n"
" mdadm --examine device\n"
" mdadm --follow options...\n"
" mdadm device options...\n"
" mdadm is used for controlling Linux md devices (aka RAID arrays)\n"
" For detail help on major modes use, e.g.\n"
" mdctl --assemble --help\n"
" mdadm --assemble --help\n"
"\n"
"Any parameter that does not start with '-' is treated as a device name\n"
"The first such name is normally the name of an md device. Subsequent\n"
@ -167,7 +169,7 @@ char Help[] =
"\n"
" --help -h : This help message or, after above option,\n"
" mode specific help message\n"
" --version -V : Print version information for mdctl\n"
" --version -V : Print version information for mdadm\n"
" --verbose -v : Be more verbose about what is happening\n"
"\n"
" For create or build:\n"
@ -209,11 +211,12 @@ char Help[] =
" --stop -S : deactive array, releasing all resources\n"
" --readonly -o : mark array as readonly\n"
" --readwrite -w : mark array as readwrite\n"
" --zero-superblock : erase the MD superblock from a device.\n"
;
char Help_create[] =
"Usage: mdctl --create device -chunk=X --level=Y --raid-disks=Z devices\n"
"Usage: mdadm --create device -chunk=X --level=Y --raid-disks=Z devices\n"
"\n"
" This usage will initialise a new md array and possibly associate some\n"
" devices with it. If enough devices are given to complete the array,\n"
@ -240,7 +243,7 @@ char Help_create[] =
;
char Help_build[] =
"Usage: mdctl --build device -chunk=X --level=Y --raid-disks=Z devices\n"
"Usage: mdadm --build device -chunk=X --level=Y --raid-disks=Z devices\n"
"\n"
" This usage is similar to --create. The difference is that it creates\n"
" a legacy array with a superblock. With these arrays there is no\n"
@ -253,12 +256,12 @@ char Help_build[] =
;
char Help_assemble[] =
"Usage: mdctl --assemble device options...\n"
" mdctl --assemble --scan options...\n"
"Usage: mdadm --assemble device options...\n"
" mdadm --assemble --scan options...\n"
"\n"
"This usage assembles one or more raid arrays from pre-existing\n"
"components.\n"
"For each array, mdctl needs to know the md device, the identify of\n"
"For each array, mdadm needs to know the md device, the identify of\n"
"the array, and a number of sub devices. These can be found in a number\n"
"of ways.\n"
"\n"

291
TAGS
View File

@ -1,4 +1,110 @@
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
@ -7,6 +113,11 @@ struct __dl_head__dl_head5,100
#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
@ -41,8 +152,8 @@ typedef struct mdp_device_descriptor_s mdp_device_descriptor_s82,2946
#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,5820
static inline __u64 md_event(166,5836
} mdp_super_t;mdp_super_t164,5835
static inline __u64 md_event(166,5851
md_u.h,1118
#define _MD_U_H16,590
@ -77,123 +188,73 @@ typedef struct mdu_start_info_s mdu_start_info_s97,2713
typedef struct mdu_param_smdu_param_s108,2878
} mdu_param_t;mdu_param_t113,3014
mdctl.h,826
#define __USE_LARGEFILE6430,1115
#define MD_MAJOR 47,1491
#define Name 52,1531
extern char short_options[54,1553
extern struct option long_options[55,1582
extern char Version[56,1619
extern char Version[], Usage[56,1619
extern char Version[], Usage[], Help[56,1619
extern char Version[], Usage[], Help[], Help_create[56,1619
extern char Version[], Usage[], Help[], Help_create[], Help_build[56,1619
extern char Version[], Usage[], Help[], Help_create[], Help_build[], Help_assemble[56,1619
typedef struct mddev_ident_s mddev_ident_s68,2055
} *mddev_ident_t;mddev_ident_t80,2292
typedef struct mddev_dev_s mddev_dev_s83,2359
} *mddev_dev_t;mddev_dev_t86,2431
typedef struct mapping mapping88,2448
} mapping_t;mapping_t91,2496
extern mapping_t r5layout[95,2606
extern mapping_t r5layout[], pers[95,2606
Assemble.c,22
int Assemble(34,1171
Build.c,100
#define REGISTER_DEV 32,1135
#define START_MD 33,1176
#define STOP_MD 34,1217
int Build(36,1259
Create.c,20
int Create(34,1171
Detail.c,20
int Detail(34,1171
Examine.c,21
int Examine(37,1261
Manage.c,161
#define REGISTER_DEV 34,1171
#define START_MD 35,1212
#define STOP_MD 36,1253
int Manage_ro(38,1295
int Manage_runstop(75,2149
int Manage_subdevs(118,3161
ReadMe.c,265
char Version[32,1135
char short_options[81,3222
struct option long_options[82,3280
char Usage[123,4484
char Help[128,4541
char Help_create[185,7233
char Help_build[212,8453
char Help_assemble[225,8993
mapping_t r5layout[284,11939
mapping_t pers[298,12155
config.c,479
char DefaultConfFile[68,2396
char *keywords[70,2441
int match_keyword(77,2640
char *conf_word(97,3148
char *conf_line(163,4739
void free_line(184,5041
struct conf_dev conf_dev195,5183
} *cdevlist 198,5244
int devline(202,5267
mddev_ident_t mddevlist 220,5590
mddev_ident_t *mddevlp 221,5622
void arrayline(223,5660
int loaded 289,7453
void load_conffile(291,7470
mddev_ident_t conf_get_ident(324,7961
mddev_dev_t conf_get_devs(334,8163
int match_oneof(369,8791
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
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,1153
int main(50,1472
#define O(O149,3610
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,573
int parse_uuid(40,1354
int md_get_version(82,2117
int get_linux_version(101,2476
int enough(113,2673
int same_uuid(129,2923
void uuid_from_super(139,3052
int compare_super(153,3329
int load_super(187,4292
int store_super(227,4950
int check_ext2(253,5321
int check_reiser(284,6084
int check_raid(308,6640
int ask(324,7003
char *map_num(344,7368
int map_name(354,7503
struct devmap devmap369,7832
} *devlist 373,7911
int devlist_ready 374,7930
#define __USE_XOPEN_EXTENDED376,7954
int add_dev(380,8003
char *map_dev(396,8370
int calc_sb_csum(412,8645
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

8
TODO
View File

@ -5,7 +5,7 @@
* write proc.c to parse /proc/mdstat file, and maybe /proc/partitions too.
Build list of arrays: name, rebuild-percent
* --detail --scan to read mdctl.conf, and then iterate over these,
* --detail --scan to read mdadm.conf, and then iterate over these,
but assume --brief. --verbose can override
check each subdevice to see if it is in conf_get_devs.
Warn if not.
@ -23,7 +23,7 @@
spare added
------------------------------------
- --examine --scan scans all drives and build an mdctl.conf file DONE
- --examine --scan scans all drives and build an mdadm.conf file DONE
- check superblock checksum in examine DONE
- report "chunk" or "rounding" depending on raid level DONE
@ -49,9 +49,9 @@
then try to assemble that device first.
- mdctl -S /dev/md0 /dev/md1 gives internal error FIXED
- mdadm -S /dev/md0 /dev/md1 gives internal error FIXED
- mdctl --detail --scan print summary of what it can find?
- mdadm --detail --scan print summary of what it can find?
---------

View File

@ -1,5 +1,5 @@
/*
* mdctl - manage Linux "md" devices aka RAID arrays.
* mdadm - manage Linux "md" devices aka RAID arrays.
*
* Copyright (C) 2001-2002 Neil Brown <neilb@cse.unsw.edu.au>
*
@ -27,7 +27,7 @@
* Australia
*/
#include "mdctl.h"
#include "mdadm.h"
#include "dlink.h"
#include <glob.h>
#include <fnmatch.h>
@ -65,7 +65,7 @@
*
*/
char DefaultConfFile[] = "/etc/mdctl.conf";
char DefaultConfFile[] = "/etc/mdadm.conf";
char *keywords[] = { "device", "array", NULL };

View File

@ -1,6 +1,6 @@
#!/bin/sh
target=${1-~/public_html/source/mdctl}
target=${1-~/public_html/source/mdadm}
if [ -d $target ]
then :
else echo $target is not a directory
@ -9,13 +9,13 @@ fi
set `grep '^char Version' ReadMe.c `
version=`echo $7 | sed 's/v//'`
echo version = $version
base=mdctl-$version.tgz
base=mdadm-$version.tgz
if [ -f $target/$base ]
then
echo $target/$base exists.
exit 1
fi
trap "rm $target/$base; exit" 1 2 3
( cd .. ; ln -s mdctl mdctl-$version ; tar czhvf - --exclude='*,v' --exclude='*.o' --exclude mdctl --exclude=RCS mdctl-$version ; rm mdctl-$version ) > $target/$base
( cd .. ; ln -s mdadm mdadm-$version ; tar czhvf - --exclude='*,v' --exclude='*.o' --exclude mdadm --exclude=RCS mdadm-$version ; rm mdadm-$version ) > $target/$base
chmod a+r $target/$base
ls -l $target/$base

View File

@ -1,13 +1,13 @@
.\" -*- nroff -*-
.TH mdctl 8
.TH mdadm 8
.SH NAME
mdctl \- manage MD devices
mdadm \- manage MD devices
.I aka
Linux Software Raid.
.SH SYNOPSIS
.BI mdctl " [mode] <raiddevice> [options] <subdevices>"
.BI mdadm " [mode] <raiddevice> [options] <subdevices>"
.SH DESCRIPTION
RAID devices are virtual devices created from two or more
@ -32,29 +32,29 @@ and
Recent kernels (2002) also support a mode known as
.BR MULTIPATH .
.B mdctl
.B mdadm
does not support MULTIPATH as yet.
.B mdctl
.B mdadm
is a program that can be used to create and manage MD devices. As
such it provides a similar set of functionality to the
.B raidtools
packages.
The key differences between
.B mdctl
.B mdadm
and
.B raidtools
are:
.IP \(bu 4
.B mdctl
.B mdadm
is a single program and not a collection of programs.
.IP \(bu 4
.B mdctl
.B mdadm
can perform (almost) all of its functions without having a
configuration file. Also mdctl helps with management of the configuration
configuration file. Also mdadm helps with management of the configuration
file.
.IP \(bu 4
.B mdctl
.B mdadm
can provide information about your arrays (through Detail and Examine)
that
.B raidtools
@ -62,17 +62,17 @@ cannot.
.IP \(bu 4
.B raidtools
can manage MULTIPATH devices which
.B mdctl
.B mdadm
cannot yet manage.
.SH MODES
mdctl has 7 major modes of operation:
mdadm has 7 major modes of operation:
.TP
.B Assemble
Assemble the parts of a previously created
array into an active array. Components can be explicitly given
or can be searched for.
.B mdctl
.B mdadm
checks that the components
do form a bona fide array, and can, on request, fiddle superblock
information so as to assemble a faulty array.
@ -99,7 +99,7 @@ Examine a device to see if it is part of an md array, and print out
the details of that array.
This mode can also be used to examine a large number of devices and to
print out a summary of the arrays found in a format suitable for the
.B mdctl.conf
.B mdadm.conf
configuration file.
.TP
@ -150,7 +150,7 @@ Display help message or, after above option, mode specific help message.
.TP
.BR -V ", " --version
Print version information for mdctl.
Print version information for mdadm.
.TP
.BR -v ", " --verbose
@ -224,7 +224,7 @@ the array is later assembled as /dev/md2.
.TP
.BR -c ", " --config=
config file. Default is
.BR /etc/mdctl.conf .
.BR /etc/mdadm.conf .
.TP
.BR -s ", " --scan
@ -285,22 +285,22 @@ mark array as readwrite.
.HP 12
Usage:
.B mdctl --assemble
.B mdadm --assemble
.I device options...
.HP 12
Usage:
.B mdctl --assemble --scan
.B mdadm --assemble --scan
.I options...
.PP
This usage assembles one or more raid arrays from pre-existing components.
For each array, mdctl needs to know the md device, the identity of the
For each array, mdadm needs to know the md device, the identity of the
array, and a number of sub devices. These can be found in a number of ways.
The md device is either given before
.B --scan
or is found from the config file. In the latter case, multiple md devices
can be started with a single mdctl command.
can be started with a single mdadm command.
The identity can be given with the
.B --uuid
@ -319,7 +319,7 @@ The config file is only used if explicitly named with
or requested with
.B --scan.
In the later case,
.B /etc/mdctl.conf
.B /etc/mdadm.conf
is used.
If
@ -341,7 +341,7 @@ flag.
.HP 12
Usage:
.B mdctl --build
.B mdadm --build
.I device
.BI --chunk= X
.BI --level= Y
@ -363,7 +363,7 @@ and the array will be started once complete.
.HP 12
Usage:
.B mdctl --create
.B mdadm --create
.I device
.BI --chunk= X
.BI --level= Y
@ -406,29 +406,29 @@ start the array readonly - not supported yet.
.SH DETAIL MODE
.HP 12
Usage:
.B mdctl --detail
.B mdadm --detail
.RB [ --brief ]
.I device ...
.PP
This usage sill print out the details of the given array including a
list of component devices. To determine names for the devices,
.B mdctl
.B mdadm
searches
.B /dev
for device files with the right major and minor numbers.
With
.B --brief
.B mdctl
.B mdadm
prints a single line that identifies the level, number of disks, and
UUID of the array. This line is suitable for inclusion in
.BR /etc/mdctl.conf .
.BR /etc/mdadm.conf .
.SH EXAMINE MODE
.HP 12
Usage:
.B mdctl --examine
.B mdadm --examine
.RB [ --scan ]
.RB [ --brief ]
.I device ...
@ -449,7 +449,7 @@ but this implication can be countered by specifying
With
.B --brief
.B mdctl
.B mdadm
will output an config file entry of each distinct array that was
found. This entry will list the UUID, the raid level, and a list of
the individual devices on which a superblock for that array was found.
@ -458,7 +458,7 @@ configuration file, but should
.B NOT
be used blindly. Often the array description that you want in the
configuration file is much less specific than that given by
.BR "mdctl -Bs" .
.BR "mdadm -Bs" .
For example, you normally do not want to list the devices,
particularly if they are SCSI devices.
@ -475,9 +475,9 @@ filesystem,
.B /proc/mdstat
gives you informations about md devices status.
This file is not currently used by
.BR mdctl .
.BR mdadm .
.SS /etc/mdctl.conf
.SS /etc/mdadm.conf
The config file is line oriented with, as usual, blank lines and lines
beginning with a hash (or pound sign or sharp or number sign,
@ -495,7 +495,7 @@ The DEVICE lines usually come first. All remaining words on the line
are treated as names of devices, possibly containing wild cards (see
.IR glob (7)).
These list all the devices that
.B mdctl
.B mdadm
is allowed to scan
when looking for devices with RAID superblocks.
Each line can contain multiple device names, and there can be multiple
@ -534,14 +534,14 @@ listed there must also be listed on a DEVICE line.
.B level=
The value is a raid level. This is normally used to identify an
array, but is supported so that the output of
.B "mdctl --examine --scan"
.B "mdadm --examine --scan"
can be use directly in the configuration file.
.TP
.B disks=
The value is the number of disks in a complete active array. As with
.B level=
this is mainly for compatibility with the output of
.BR "mdctl --examine --scan" .
.BR "mdadm --examine --scan" .
.SH TODO

View File

@ -1,5 +1,5 @@
/*
* mdctl - manage Linux "md" devices aka RAID arrays.
* mdadm - manage Linux "md" devices aka RAID arrays.
*
* Copyright (C) 2001-2002 Neil Brown <neilb@cse.unsw.edu.au>
*
@ -27,7 +27,7 @@
* Australia
*/
#include "mdctl.h"
#include "mdadm.h"
#include "md_p.h"
int open_mddev(char *dev)
@ -101,6 +101,7 @@ int main(int argc, char *argv[])
case 'D':
case 'E':
case 'F':
case 'H':
/* setting mode - only once */
if (mode) {
fprintf(stderr, Name ": --%s/-%c not allowed, mode already set to %s\n",
@ -291,13 +292,12 @@ int main(int argc, char *argv[])
}
continue;
case O('C','f'): /* force honouring of device list */
case O('A','f'): /* force assembly */
case O('H','f'): /* force zero */
force=1;
continue;
/* now for the Assemble options */
case O('A','f'): /* force assembly */
force = 1;
continue;
case O('A','u'): /* uuid of array */
if (ident.uuid_set) {
fprintf(stderr, Name ": uuid cannot be set twice. "
@ -535,6 +535,11 @@ int main(int argc, char *argv[])
case 'F': /* Follow */
rv= Monitor(devlist, mailaddr, program,
delay?delay:60, configfile);
break;
case 'H': /* Zero superblock */
for (dv=devlist ; dv; dv=dv->next)
rv |= Kill(dv->devname, force);
break;
}
exit(rv);
}

View File

@ -1,5 +1,5 @@
/*
* mdctl - manage Linux "md" devices aka RAID arrays.
* mdadm - manage Linux "md" devices aka RAID arrays.
*
* Copyright (C) 2001-2002 Neil Brown <neilb@cse.unsw.edu.au>
*
@ -49,7 +49,7 @@ extern __off64_t lseek64 __P ((int __fd, __off64_t __offset, int __whence));
#include "md_u.h"
#define Name "mdctl"
#define Name "mdadm"
extern char short_options[];
extern struct option long_options[];
@ -137,6 +137,8 @@ extern int Monitor(mddev_dev_t devlist,
int period,
char *config);
extern int Kill(char *dev, int force);
extern int md_get_version(int fd);
extern int get_linux_version();
extern int parse_uuid(char *str, int uuid[4]);

View File

@ -1,13 +1,13 @@
mdctl(8) mdctl(8)
mdadm(8) mdadm(8)
NNAAMMEE
mdctl - manage MD devices _a_k_a Linux Software Raid.
mdadm - manage MD devices _a_k_a Linux Software Raid.
SSYYNNOOPPSSIISS
mmddccttll _[_m_o_d_e_] _<_r_a_i_d_d_e_v_i_c_e_> _[_o_p_t_i_o_n_s_] _<_s_u_b_d_e_v_i_c_e_s_>
mmddaaddmm _[_m_o_d_e_] _<_r_a_i_d_d_e_v_i_c_e_> _[_o_p_t_i_o_n_s_] _<_s_u_b_d_e_v_i_c_e_s_>
DDEESSCCRRIIPPTTIIOONN
@ -25,34 +25,34 @@ DDEESSCCRRIIPPTTIIOONN
ing), RRAAIIDD11 (mirroring), RRAAIIDD44 and RRAAIIDD55..
Recent kernels (2002) also support a mode known as MMUULLTTII--
PPAATTHH. mmddccttll does not support MULTIPATH as yet.
PPAATTHH. mmddaaddmm does not support MULTIPATH as yet.
mmddccttll is a program that can be used to create and manage
mmddaaddmm is a program that can be used to create and manage
MD devices. As such it provides a similar set of func-
tionality to the rraaiiddttoooollss packages. The key differences
between mmddccttll and rraaiiddttoooollss are:
between mmddaaddmm and rraaiiddttoooollss are:
+o mmddccttll is a single program and not a collection of pro-
+o mmddaaddmm is a single program and not a collection of pro-
grams.
+o mmddccttll can perform (almost) all of its functions with-
out having a configuration file. Also mdctl helps
+o mmddaaddmm can perform (almost) all of its functions with-
out having a configuration file. Also mdadm helps
with management of the configuration file.
+o mmddccttll can provide information about your arrays
+o mmddaaddmm can provide information about your arrays
(through Detail and Examine) that rraaiiddttoooollss cannot.
+o rraaiiddttoooollss can manage MULTIPATH devices which mmddccttll
+o rraaiiddttoooollss can manage MULTIPATH devices which mmddaaddmm
cannot yet manage.
MMOODDEESS
mdctl has 7 major modes of operation:
mdadm has 7 major modes of operation:
AAsssseemmbbllee
Assemble the parts of a previously created array
into an active array. Components can be explicitly
given or can be searched for. mmddccttll checks that
given or can be searched for. mmddaaddmm checks that
the components do form a bona fide array, and can,
on request, fiddle superblock information so as to
assemble a faulty array.
@ -76,7 +76,7 @@ MMOODDEESS
This mode can also be used to examine a large num-
ber of devices and to print out a summary of the
arrays found in a format suitable for the
mmddccttll..ccoonnff configuration file.
mmddaaddmm..ccoonnff configuration file.
FFoollllooww oorr MMoonniittoorr
@ -122,7 +122,7 @@ OOPPTTIIOONNSS
--VV, ----vveerrssiioonn
Print version information for mdctl.
Print version information for mdadm.
--vv, ----vveerrbboossee
@ -197,7 +197,7 @@ FFoorr aasssseemmbbllee::
--cc, ----ccoonnffiigg==
config file. Default is //eettcc//mmddccttll..ccoonnff.
config file. Default is //eettcc//mmddaaddmm..ccoonnff.
--ss, ----ssccaann
@ -254,19 +254,19 @@ GGeenneerraall mmaannaaggeemmeenntt
AASSSSEEMMBBLLYY MMOODDEE
Usage: mmddccttll ----aasssseemmbbllee _d_e_v_i_c_e _o_p_t_i_o_n_s_._._.
Usage: mmddaaddmm ----aasssseemmbbllee _d_e_v_i_c_e _o_p_t_i_o_n_s_._._.
Usage: mmddccttll ----aasssseemmbbllee ----ssccaann _o_p_t_i_o_n_s_._._.
Usage: mmddaaddmm ----aasssseemmbbllee ----ssccaann _o_p_t_i_o_n_s_._._.
This usage assembles one or more raid arrays from pre-
existing components. For each array, mdctl needs to know
existing components. For each array, mdadm needs to know
the md device, the identity of the array, and a number of
sub devices. These can be found in a number of ways.
The md device is either given before ----ssccaann or is found
from the config file. In the latter case, multiple md
devices can be started with a single mdctl command.
devices can be started with a single mdadm command.
The identity can be given with the ----uuuuiidd option, with the
----ssuuppeerr--mmiinnoorr option, can be found in in the config file,
@ -280,7 +280,7 @@ AASSSSEEMMBBLLYY MMOODDEE
The config file is only used if explicitly named with
----ccoonnffiigg or requested with ----ssccaann.. In the later case,
//eettcc//mmddccttll..ccoonnff is used.
//eettcc//mmddaaddmm..ccoonnff is used.
If ----ssccaann is not given, then the config file will only be
used to find the identity of md arrays.
@ -295,7 +295,7 @@ AASSSSEEMMBBLLYY MMOODDEE
BBUUIILLDD MMOODDEE
Usage: mmddccttll ----bbuuiilldd _d_e_v_i_c_e ----cchhuunnkk==_X ----lleevveell==_Y ----rraaiidd--
Usage: mmddaaddmm ----bbuuiilldd _d_e_v_i_c_e ----cchhuunnkk==_X ----lleevveell==_Y ----rraaiidd--
ddiisskkss==_Z _d_e_v_i_c_e_s
@ -312,7 +312,7 @@ BBUUIILLDD MMOODDEE
CCRREEAATTEE MMOODDEE
Usage: mmddccttll ----ccrreeaattee _d_e_v_i_c_e ----cchhuunnkk==_X ----lleevveell==_Y
Usage: mmddaaddmm ----ccrreeaattee _d_e_v_i_c_e ----cchhuunnkk==_X ----lleevveell==_Y
----rraaiidd--ddiisskkss==_Z _d_e_v_i_c_e_s
@ -340,21 +340,21 @@ CCRREEAATTEE MMOODDEE
DDEETTAAIILL MMOODDEE
Usage: mmddccttll ----ddeettaaiill [----bbrriieeff] _d_e_v_i_c_e _._._.
Usage: mmddaaddmm ----ddeettaaiill [----bbrriieeff] _d_e_v_i_c_e _._._.
This usage sill print out the details of the given array
including a list of component devices. To determine names
for the devices, mmddccttll searches //ddeevv for device files with
for the devices, mmddaaddmm searches //ddeevv for device files with
the right major and minor numbers.
With ----bbrriieeff mmddccttll prints a single line that identifies
With ----bbrriieeff mmddaaddmm prints a single line that identifies
the level, number of disks, and UUID of the array. This
line is suitable for inclusion in //eettcc//mmddccttll..ccoonnff.
line is suitable for inclusion in //eettcc//mmddaaddmm..ccoonnff.
EEXXAAMMIINNEE MMOODDEE
Usage: mmddccttll ----eexxaammiinnee [----ssccaann] [----bbrriieeff] _d_e_v_i_c_e _._._.
Usage: mmddaaddmm ----eexxaammiinnee [----ssccaann] [----bbrriieeff] _d_e_v_i_c_e _._._.
This usage will examine some block devices to see if that
have a valid RAID superblock on them. The information in
@ -365,14 +365,14 @@ EEXXAAMMIINNEE MMOODDEE
tion file are checked. ----ssccaann implies ----bbrriieeff but this
implication can be countered by specifying ----vveerrbboossee.
With ----bbrriieeff mmddccttll will output an config file entry of
With ----bbrriieeff mmddaaddmm will output an config file entry of
each distinct array that was found. This entry will list
the UUID, the raid level, and a list of the individual
devices on which a superblock for that array was found.
This output will by syntactically suitable for inclusion
in the configuration file, but should NNOOTT be used blindly.
Often the array description that you want in the configu-
ration file is much less specific than that given by mmddccttll
ration file is much less specific than that given by mmddaaddmm
--BBss. For example, you normally do not want to list the
devices, particularly if they are SCSI devices.
@ -382,10 +382,10 @@ FFIILLEESS
//pprroocc//mmddssttaatt
If you're using the //pprroocc filesystem, //pprroocc//mmddssttaatt gives
you informations about md devices status. This file is
not currently used by mmddccttll.
not currently used by mmddaaddmm.
//eettcc//mmddccttll..ccoonnff
//eettcc//mmddaaddmm..ccoonnff
The config file is line oriented with, as usual, blank
lines and lines beginning with a hash (or pound sign or
sharp or number sign, whichever you like to call it)
@ -403,7 +403,7 @@ FFIILLEESS
The DEVICE lines usually come first. All remaining words
on the line are treated as names of devices, possibly con-
taining wild cards (see _g_l_o_b(7)). These list all the
devices that mmddccttll is allowed to scan when looking for
devices that mmddaaddmm is allowed to scan when looking for
devices with RAID superblocks. Each line can contain mul-
tiple device names, and there can be multiple DEVICE
lines. For example:
@ -439,12 +439,12 @@ FFIILLEESS
lleevveell== The value is a raid level. This is normally used
to identify an array, but is supported so that the
output of mmddccttll ----eexxaammiinnee ----ssccaann can be use
output of mmddaaddmm ----eexxaammiinnee ----ssccaann can be use
directly in the configuration file.
ddiisskkss== The value is the number of disks in a complete
active array. As with lleevveell== this is mainly for
compatibility with the output of mmddccttll ----eexxaammiinnee
compatibility with the output of mmddaaddmm ----eexxaammiinnee
----ssccaann.
@ -473,4 +473,4 @@ SSEEEE AALLSSOO
mdctl(8)
mdadm(8)

View File

@ -1,20 +1,20 @@
Summary: mdctl is used for controlling Linux md devices (aka RAID arrays)
Name: mdctl
Summary: mdadm is used for controlling Linux md devices (aka RAID arrays)
Name: mdadm
Version: 0.5
Release: 1
Source0: http://www.cse.unsw.edu.au/~neilb/source/mdctl/mdctl-%{version}.tgz
URL: http://www.cse.unsw.edu.au/~neilb/source/mdctl/
Source0: http://www.cse.unsw.edu.au/~neilb/source/mdadm/mdadm-%{version}.tgz
URL: http://www.cse.unsw.edu.au/~neilb/source/mdadm/
Copyright: GPL
Group: Utilities/System
BuildRoot: /var/tmp/%{name}-root
Packager: Danilo Godec <danci@agenda.si>
%description
mdctl is a single program that can be used to control Linux md devices. It
mdadm is a single program that can be used to control Linux md devices. It
is intended to provide all the functionality of the mdtools and raidtools
but with a very different interface.
mdctl can perform all functions without a configuration file. There is the
mdadm can perform all functions without a configuration file. There is the
option of using a configuration file, but not in the same way that raidtools
uses one.
@ -25,7 +25,7 @@ stopping a raid array, which needs to know nothing about the array.
%prep
%setup -q -n mdctl
%setup -q -n mdadm
%build
make
@ -33,7 +33,7 @@ make
%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/sbin
install -m755 mdctl $RPM_BUILD_ROOT/sbin/
install -m755 mdadm $RPM_BUILD_ROOT/sbin/
%clean
rm -rf $RPM_BUILD_ROOT

4
util.c
View File

@ -1,5 +1,5 @@
/*
* mdctl - manage Linux "md" devices aka RAID arrays.
* mdadm - manage Linux "md" devices aka RAID arrays.
*
* Copyright (C) 2001-2002 Neil Brown <neilb@cse.unsw.edu.au>
*
@ -27,7 +27,7 @@
* Australia
*/
#include "mdctl.h"
#include "mdadm.h"
#include "md_p.h"
#include <sys/utsname.h>