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.
|
- --help now goes to stdout so you can direct it to a pager.
|
||||||
- Various manpage updates.
|
- Various manpage updates.
|
||||||
- Make "--grow --add" for linear arrays really work.
|
- Make "--grow --add" for linear arrays really work.
|
||||||
|
- --auto-detect to trigger in-kernel autodetect.
|
||||||
|
|
||||||
Changes Prior to 2.6.1 release
|
Changes Prior to 2.6.1 release
|
||||||
- --monitor was producing some meaningless warnings due to a bug.
|
- --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;
|
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
|
#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 */
|
{"zero-superblock", 0, 0, 'K'}, /* deliberately no a short_option */
|
||||||
{"query", 0, 0, 'Q'},
|
{"query", 0, 0, 'Q'},
|
||||||
{"examine-bitmap", 0, 0, 'X'},
|
{"examine-bitmap", 0, 0, 'X'},
|
||||||
|
{"auto-detect", 0, 0, AutoDetect},
|
||||||
|
|
||||||
/* synonyms */
|
/* synonyms */
|
||||||
{"monitor", 0, 0, 'F'},
|
{"monitor", 0, 0, 'F'},
|
||||||
|
@ -255,6 +256,7 @@ char OptionHelp[] =
|
||||||
" --incremental -I : add a single device to an array as appropriate\n"
|
" --incremental -I : add a single device to an array as appropriate\n"
|
||||||
" --query -Q : Display general information about how a\n"
|
" --query -Q : Display general information about how a\n"
|
||||||
" device relates to the md driver\n"
|
" device relates to the md driver\n"
|
||||||
|
" --auto-detect : Start arrays auto-detected by the kernel\n"
|
||||||
;
|
;
|
||||||
/*
|
/*
|
||||||
"\n"
|
"\n"
|
||||||
|
@ -624,6 +626,7 @@ mapping_t modes[] = {
|
||||||
{ "monitor", MONITOR},
|
{ "monitor", MONITOR},
|
||||||
{ "grow", GROW},
|
{ "grow", GROW},
|
||||||
{ "incremental", INCREMENTAL},
|
{ "incremental", INCREMENTAL},
|
||||||
|
{ "auto-detect", AUTODETECT},
|
||||||
};
|
};
|
||||||
|
|
||||||
mapping_t faultylayout[] = {
|
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
|
'''This mode allows operations on independent devices such as examine MD
|
||||||
'''superblocks, erasing old superblocks and stopping active arrays.
|
'''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
|
||||||
|
|
||||||
.SH Options for selecting a mode are:
|
.SH Options for selecting a mode are:
|
||||||
|
@ -181,9 +185,24 @@ mode.
|
||||||
Change the size or shape of an active array.
|
Change the size or shape of an active array.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.BE \-I ", " \-\-incremental
|
.BR \-I ", " \-\-incremental
|
||||||
Add a single device into an appropriate array, and possibly start the array.
|
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
|
.P
|
||||||
If a device is given before any options, or if the first option is
|
If a device is given before any options, or if the first option is
|
||||||
.BR \-\-add ,
|
.BR \-\-add ,
|
||||||
|
|
7
mdadm.c
7
mdadm.c
|
@ -198,6 +198,8 @@ int main(int argc, char *argv[])
|
||||||
case 'F': newmode = MONITOR;break;
|
case 'F': newmode = MONITOR;break;
|
||||||
case 'G': newmode = GROW; shortopt = short_bitmap_auto_options; break;
|
case 'G': newmode = GROW; shortopt = short_bitmap_auto_options; break;
|
||||||
case 'I': newmode = INCREMENTAL; break;
|
case 'I': newmode = INCREMENTAL; break;
|
||||||
|
case AutoDetect:
|
||||||
|
newmode = AUTODETECT; break;
|
||||||
|
|
||||||
case '#':
|
case '#':
|
||||||
case 'D':
|
case 'D':
|
||||||
|
@ -277,6 +279,7 @@ int main(int argc, char *argv[])
|
||||||
case 'F':
|
case 'F':
|
||||||
case 'G':
|
case 'G':
|
||||||
case 'I':
|
case 'I':
|
||||||
|
case AutoDetect:
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (opt == 1) {
|
if (opt == 1) {
|
||||||
|
@ -1344,6 +1347,10 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
rv = Incremental(devlist->devname, verbose-quiet, runstop,
|
rv = Incremental(devlist->devname, verbose-quiet, runstop,
|
||||||
ss, homehost, autof);
|
ss, homehost, autof);
|
||||||
|
break;
|
||||||
|
case AUTODETECT:
|
||||||
|
autodetect();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
exit(rv);
|
exit(rv);
|
||||||
}
|
}
|
||||||
|
|
3
mdadm.h
3
mdadm.h
|
@ -151,6 +151,7 @@ enum mode {
|
||||||
MONITOR,
|
MONITOR,
|
||||||
GROW,
|
GROW,
|
||||||
INCREMENTAL,
|
INCREMENTAL,
|
||||||
|
AUTODETECT,
|
||||||
};
|
};
|
||||||
|
|
||||||
extern char short_options[];
|
extern char short_options[];
|
||||||
|
@ -175,6 +176,7 @@ enum special_options {
|
||||||
HomeHost,
|
HomeHost,
|
||||||
AutoHomeHost,
|
AutoHomeHost,
|
||||||
Symlinks,
|
Symlinks,
|
||||||
|
AutoDetect,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* structures read from config file */
|
/* 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_reconfig(char *devname, int fd, int layout);
|
||||||
extern int Manage_subdevs(char *devname, int fd,
|
extern int Manage_subdevs(char *devname, int fd,
|
||||||
mddev_dev_t devlist, int verbose);
|
mddev_dev_t devlist, int verbose);
|
||||||
|
extern int autodetect(void);
|
||||||
extern int Grow_Add_device(char *devname, int fd, char *newdev);
|
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_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,
|
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
|
# assume md0, md1, md2 exist in /dev
|
||||||
md0=/dev/md0 md1=/dev/md1 md2=/dev/md2
|
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.
|
# We test mdadm on loop-back block devices.
|
||||||
# dir for storing files should be settable by command line maybe
|
# 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