Add --auto-detect for in-kernel autodetect.
This is equivalent to raidautorun that some distros provide.
This commit is contained in:
parent
69646c1483
commit
1f48664b8e
|
@ -7,6 +7,7 @@ Changes Prior to this release
|
|||
- --help now goes to stdout so you can direct it to a pager.
|
||||
- Various manpage updates.
|
||||
- Make "--grow --add" for linear arrays really work.
|
||||
- --auto-detect to trigger in-kernel autodetect.
|
||||
|
||||
Changes Prior to 2.6.1 release
|
||||
- --monitor was producing some meaningless warnings due to a bug.
|
||||
|
|
13
Manage.c
13
Manage.c
|
@ -507,4 +507,17 @@ int Manage_subdevs(char *devname, int fd,
|
|||
return 0;
|
||||
|
||||
}
|
||||
|
||||
int autodetect(void)
|
||||
{
|
||||
/* Open any md device, and issue the RAID_AUTORUN ioctl */
|
||||
int rv = 1;
|
||||
int fd = dev_open("9:0", O_RDONLY);
|
||||
if (fd >= 0) {
|
||||
if (ioctl(fd, RAID_AUTORUN, 0) == 0)
|
||||
rv = 0;
|
||||
close(fd);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
#endif
|
||||
|
|
3
ReadMe.c
3
ReadMe.c
|
@ -109,6 +109,7 @@ struct option long_options[] = {
|
|||
{"zero-superblock", 0, 0, 'K'}, /* deliberately no a short_option */
|
||||
{"query", 0, 0, 'Q'},
|
||||
{"examine-bitmap", 0, 0, 'X'},
|
||||
{"auto-detect", 0, 0, AutoDetect},
|
||||
|
||||
/* synonyms */
|
||||
{"monitor", 0, 0, 'F'},
|
||||
|
@ -255,6 +256,7 @@ char OptionHelp[] =
|
|||
" --incremental -I : add a single device to an array as appropriate\n"
|
||||
" --query -Q : Display general information about how a\n"
|
||||
" device relates to the md driver\n"
|
||||
" --auto-detect : Start arrays auto-detected by the kernel\n"
|
||||
;
|
||||
/*
|
||||
"\n"
|
||||
|
@ -624,6 +626,7 @@ mapping_t modes[] = {
|
|||
{ "monitor", MONITOR},
|
||||
{ "grow", GROW},
|
||||
{ "incremental", INCREMENTAL},
|
||||
{ "auto-detect", AUTODETECT},
|
||||
};
|
||||
|
||||
mapping_t faultylayout[] = {
|
||||
|
|
21
mdadm.8
21
mdadm.8
|
@ -154,6 +154,10 @@ information gathering operations.
|
|||
'''This mode allows operations on independent devices such as examine MD
|
||||
'''superblocks, erasing old superblocks and stopping active arrays.
|
||||
|
||||
.TP
|
||||
.B Auto-detect
|
||||
This mode does not act on a specific device or array, but rather it
|
||||
requests the Linux Kernel to activate any auto-detected arrays.
|
||||
.SH OPTIONS
|
||||
|
||||
.SH Options for selecting a mode are:
|
||||
|
@ -181,9 +185,24 @@ mode.
|
|||
Change the size or shape of an active array.
|
||||
|
||||
.TP
|
||||
.BE \-I ", " \-\-incremental
|
||||
.BR \-I ", " \-\-incremental
|
||||
Add a single device into an appropriate array, and possibly start the array.
|
||||
|
||||
.TP
|
||||
.B \-\-auto-detect
|
||||
Request that the kernel starts any auto-detected arrays. This can only
|
||||
work if
|
||||
.I md
|
||||
is compiled into the kernel \(em not if it is a module.
|
||||
Arrays can be auto-detected by the kernel if all the components are in
|
||||
primary MS-DOS partitions with partition type
|
||||
.BR FD .
|
||||
In-kernel autodetect is not recommended for new installations. Using
|
||||
.I mdadm
|
||||
to detect and assemble arrays \(em possibly in an
|
||||
.I initrd
|
||||
\(em is substantially more flexible and should be preferred.
|
||||
|
||||
.P
|
||||
If a device is given before any options, or if the first option is
|
||||
.BR \-\-add ,
|
||||
|
|
7
mdadm.c
7
mdadm.c
|
@ -198,6 +198,8 @@ int main(int argc, char *argv[])
|
|||
case 'F': newmode = MONITOR;break;
|
||||
case 'G': newmode = GROW; shortopt = short_bitmap_auto_options; break;
|
||||
case 'I': newmode = INCREMENTAL; break;
|
||||
case AutoDetect:
|
||||
newmode = AUTODETECT; break;
|
||||
|
||||
case '#':
|
||||
case 'D':
|
||||
|
@ -277,6 +279,7 @@ int main(int argc, char *argv[])
|
|||
case 'F':
|
||||
case 'G':
|
||||
case 'I':
|
||||
case AutoDetect:
|
||||
continue;
|
||||
}
|
||||
if (opt == 1) {
|
||||
|
@ -1344,6 +1347,10 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
rv = Incremental(devlist->devname, verbose-quiet, runstop,
|
||||
ss, homehost, autof);
|
||||
break;
|
||||
case AUTODETECT:
|
||||
autodetect();
|
||||
break;
|
||||
}
|
||||
exit(rv);
|
||||
}
|
||||
|
|
3
mdadm.h
3
mdadm.h
|
@ -151,6 +151,7 @@ enum mode {
|
|||
MONITOR,
|
||||
GROW,
|
||||
INCREMENTAL,
|
||||
AUTODETECT,
|
||||
};
|
||||
|
||||
extern char short_options[];
|
||||
|
@ -175,6 +176,7 @@ enum special_options {
|
|||
HomeHost,
|
||||
AutoHomeHost,
|
||||
Symlinks,
|
||||
AutoDetect,
|
||||
};
|
||||
|
||||
/* structures read from config file */
|
||||
|
@ -415,6 +417,7 @@ extern int Manage_resize(char *devname, int fd, long long size, int raid_disks);
|
|||
extern int Manage_reconfig(char *devname, int fd, int layout);
|
||||
extern int Manage_subdevs(char *devname, int fd,
|
||||
mddev_dev_t devlist, int verbose);
|
||||
extern int autodetect(void);
|
||||
extern int Grow_Add_device(char *devname, int fd, char *newdev);
|
||||
extern int Grow_addbitmap(char *devname, int fd, char *file, int chunk, int delay, int write_behind, int force);
|
||||
extern int Grow_reshape(char *devname, int fd, int quiet, char *backup_file,
|
||||
|
|
2
test
2
test
|
@ -21,6 +21,8 @@ fi
|
|||
|
||||
# assume md0, md1, md2 exist in /dev
|
||||
md0=/dev/md0 md1=/dev/md1 md2=/dev/md2
|
||||
mdp0=/dev/md_d0
|
||||
mdp1=/dev/md_d1
|
||||
|
||||
# We test mdadm on loop-back block devices.
|
||||
# dir for storing files should be settable by command line maybe
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
|
||||
#
|
||||
# Test in-kernel autodetect.
|
||||
# Create a partitionable array on each of two devices,
|
||||
# put a partition on each, create an array, and see if we can
|
||||
# use autodetect to restart the array.
|
||||
|
||||
mdadm -CR $mdp0 -l0 -f -n1 $dev0
|
||||
mdadm -CR $mdp1 -l0 -f -n1 $dev1
|
||||
sfdisk $mdp0 >&2 << END
|
||||
,,FD
|
||||
END
|
||||
sfdisk $mdp1 >&2 << END
|
||||
,,FD
|
||||
END
|
||||
mdadm -CR $md0 -l1 -n2 ${mdp0}p1 ${mdp1}p1
|
||||
check resync
|
||||
check raid1
|
||||
check wait
|
||||
mdadm -S $md0
|
||||
mdadm --auto-detect
|
||||
check raid1
|
||||
|
||||
mdadm -Ss
|
||||
exit 0
|
Loading…
Reference in New Issue