90mdraid: fix/adjust 65-md* rules and related scripts

Reworked the flow of the rules file a bit, removed redundant tests, also
should be easier to follow. It's much shorter now as well, a bit more
similar to 90lvm script - both revolve around same concepts after all.

There's no reason to treat conf-assembled arrays differently from
incremental ones. Once we hit timeout in init's udev loop, we can use
common script (mdraid_start.sh) to try force inactive arrays
into degraded mode.

md-finished.sh was kind-of out of place - it didn't really wait for any
particular device(s) to show up, just watched if onetime mdadm scripts
are still in place. Furthermore, after moving mdraid_start to --timeout
initqueue, it didn't really have too much to watch at all, besides
mdadm_auto (and that served no purpose, as we do wait for concrete
devices).

Either way, with stock 64-md fixes, current version of 65-md*.rules does
the following:

- limits assembly to certain uuids, if specified
- watch for no ddf/imsm
- if mdadm.conf => setup onetime -As script, without forced --run option
- if !mdadm.conf => incrementally assemble
- for both cases, setup timeout script, run-forcing arrays as a last resort

Signed-off-by: Michal Soltys <soltys@ziu.info>
master
Michal Soltys 2011-09-06 00:17:28 +02:00 committed by Harald Hoyer
parent cf5891424e
commit a025cc17f0
5 changed files with 39 additions and 70 deletions

View File

@ -2,68 +2,45 @@
# automatically cause mdadm to be run. # automatically cause mdadm to be run.
# See udev(8) for syntax # See udev(8) for syntax


ACTION!="add|change", GOTO="md_inc_end" ACTION!="add|change", GOTO="md_end"
SUBSYSTEM!="block", GOTO="md_inc_end" SUBSYSTEM!="block", GOTO="md_end"
ENV{ID_FS_TYPE}!="*_raid_member", GOTO="md_inc_end" ENV{rd_NO_MD}=="?*", GOTO="md_end"
KERNEL=="md*", GOTO="md_end"


ENV{ID_FS_TYPE}=="isw_raid_member", ENV{rd_NO_MDIMSM}=="?*", GOTO="md_inc_end" ENV{ID_FS_TYPE}!="*_raid_member", GOTO="md_end"
ENV{ID_FS_TYPE}=="ddf_raid_member", ENV{rd_NO_MDDDF}=="?*", GOTO="md_inc_end" ENV{ID_FS_TYPE}=="isw_raid_member", ENV{rd_NO_MDIMSM}=="?*", GOTO="md_end"
ENV{ID_FS_TYPE}=="ddf_raid_member", ENV{rd_NO_MDDDF}=="?*", GOTO="md_end"


ENV{rd_NO_MD}=="?*", GOTO="md_inc_end" # already done ?
PROGRAM="/bin/sh -c 'for i in $sys/$devpath/holders/md[0-9]*; do [ -e $$i ] && exit 0; done; exit 1;' ", \
GOTO="md_end"


PROGRAM=="/bin/sh -c 'for i in $sys/$devpath/holders/md[0-9]*; do [ -e $$i ] && exit 0; done; exit 1;' ", \ # for native arrays - array's uuid has to be specified
GOTO="md_inc_end" # for containers - container's uuid has to be specified
# TODO : how to get embedded array's uuid having container's component ?
#
# UUID CHECK


ENV{DEVTYPE}!="partition", \ ENV{DEVTYPE}!="partition", \
RUN+="/sbin/partx -d --nr 1-1024 $env{DEVNAME}" RUN+="/sbin/partx -d --nr 1-1024 $env{DEVNAME}"


KERNEL!="md*", IMPORT{program}="/sbin/mdadm --examine --export $tempnode"

# UUID CHECK

LABEL="do_md_inc"

#
# if rd_MDADMCONF do not assemble incrementally
# defer auto assembly until the udev queue is settled
#
ENV{rd_MDADMCONF}!="?*", GOTO="md_auto_end"

RUN+="/sbin/initqueue --finished --unique --name md_finished /sbin/md_finished.sh"
RUN+="/sbin/initqueue --settled --onetime --unique /sbin/mdadm_auto"

GOTO="md_inc_end"

LABEL="md_auto_end"

#
# Incrementally build the md array
#
RUN+="/sbin/mdadm -I $env{DEVNAME}"

RUN+="/sbin/initqueue --finished --unique --name md_finished /sbin/md_finished.sh"

LABEL="md_inc_end"

#
# Handle non-container raid arrays
#
ACTION=="add|change", \
KERNEL=="md[0-9]*|md/*", \
ENV{MD_LEVEL}!="container", \
ENV{MD_CONTAINER}!="?*", \
ENV{rd_MDADMCONF}!="?*", \
ENV{rd_NO_MD}!="?*", \
GOTO="do_raidstart"

GOTO="end_raidstart"

LABEL="do_raidstart"

# check if array is not inactive anymore
TEST=="md/array_state", ATTR{md/array_state}!="|inactive", GOTO="end_raidstart"

RUN+="/sbin/initqueue --finished --unique --name md_finished /sbin/md_finished.sh"
RUN+="/sbin/initqueue --timeout --onetime --unique /sbin/mdraid_start" RUN+="/sbin/initqueue --timeout --onetime --unique /sbin/mdraid_start"


LABEL="end_raidstart" # if rd_MDADMCONF is set, do not assemble incrementally;
# defer conf-based assembly until the udev queue is settled
#
ENV{rd_MDADMCONF}!="?*", GOTO="md_incremental"

RUN+="/sbin/initqueue --settled --onetime --unique /sbin/mdadm_auto"

GOTO="md_end"

#
# Incrementally build the md array; this will automatically assemble
# any eventual containers as well (imsm, ddf)
#
LABEL="md_incremental"

RUN+="/sbin/mdadm -I $env{DEVNAME}"

LABEL="md_end"

View File

@ -1,9 +0,0 @@
#!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
for f in $hookdir/initqueue/settled/mdraid_start* $hookdir/initqueue/settled/mdadm_auto*; do
[ -e $f ] && exit 1
done

$UDEV_QUEUE_EMPTY >/dev/null 2>&1 || exit 1
exit 0

View File

@ -4,4 +4,4 @@
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh


info "Autoassembling MD Raid" info "Autoassembling MD Raid"
mdadm -As --auto=yes --run 2>&1 | vinfo mdadm -As --auto=yes 2>&1 | vinfo

View File

@ -82,7 +82,6 @@ install() {


inst "$moddir/mdraid_start.sh" /sbin/mdraid_start inst "$moddir/mdraid_start.sh" /sbin/mdraid_start
inst "$moddir/mdadm_auto.sh" /sbin/mdadm_auto inst "$moddir/mdadm_auto.sh" /sbin/mdadm_auto
inst "$moddir/md_finished.sh" /sbin/md_finished.sh
inst_hook pre-trigger 30 "$moddir/parse-md.sh" inst_hook pre-trigger 30 "$moddir/parse-md.sh"
inst "$moddir/mdraid-cleanup.sh" /sbin/mdraid-cleanup inst "$moddir/mdraid-cleanup.sh" /sbin/mdraid-cleanup
inst_hook shutdown 30 "$moddir/md-shutdown.sh" inst_hook shutdown 30 "$moddir/md-shutdown.sh"

View File

@ -13,12 +13,14 @@ else
[ -e "$f" ] || continue [ -e "$f" ] || continue
while read line; do while read line; do
if [ "${line%%UUID CHECK}" != "$line" ]; then if [ "${line%%UUID CHECK}" != "$line" ]; then
printf 'IMPORT{program}="/sbin/mdadm --examine --export $tempnode"\n'
for uuid in $MD_UUID; do for uuid in $MD_UUID; do
printf 'ENV{MD_UUID}=="%s", GOTO="do_md_inc"\n' $uuid printf 'ENV{MD_UUID}=="%s", GOTO="md_uuid_ok"\n' $uuid
done; done;
printf 'GOTO="md_inc_end"\n'; printf 'GOTO="md_end"\n'
printf 'LABEL="md_uuid_ok"\n'
else else
echo $line; echo "$line"
fi fi
done < "${f}" > "${f}.new" done < "${f}" > "${f}.new"
mv "${f}.new" "$f" mv "${f}.new" "$f"