* [RFC 0/6] Update 90mdraid
@ 2011-09-05 22:17 Michal Soltys
[not found] ` <1315261048-19544-1-git-send-email-soltys-R61QfzASbfY@public.gmane.org>
0 siblings, 1 reply; 10+ messages in thread
From: Michal Soltys @ 2011-09-05 22:17 UTC (permalink / raw)
To: initramfs-u79uwXL29TY76Z2rM5mHXA
This is a set of patches simplifying mdraid module, with a few fixes along the way.
1) 90mdraid: adjust stock mdadm udev rules
2) 90(md|dm)raid: recognize ddf container
3) 90mdraid: containers are not runnable
4) 90mdraid: fix/adjust mdraid-cleanup
5) 90mdraid: fix/adjust force-run script
6) 90mdraid: fix/adjust 65-md* rules and related scripts
First 4 patches are pretty simple and could likely go in. In particular, 1st
one has a fix for stock mdadm rules, which originally cause unconditional
incremental assembly of all native+imsm components.
#4 - I'm still not sure, why exactly raid cleanup was called twice.
#5 and #6 are main part with more changes resulting with, subjecitvely,
cleaner and shorter code. All the details and rationale are in respective
commit messages.
It looks solid, but it's still work in progress and requires some
testing. Comment if you have any objections or questions.
For convenience, it can be also pulled from:
git://git.hasevolq.net/dracut.git mdraid-fix-v1
Michal Soltys (6):
90mdraid: adjust stock mdadm udev rules
90(md|dm)raid: recognize ddf container
90mdraid: containers are not runnable
90mdraid: fix/adjust mdraid-cleanup
90mdraid: fix/adjust force-run script
90mdraid: fix/adjust 65-md* rules and related scripts
dracut.kernel.7.xml | 6 ++
modules.d/90dmraid/61-dmraid-imsm.rules | 1 +
modules.d/90dmraid/parse-dm.sh | 4 +
modules.d/90mdraid/65-md-incremental-imsm.rules | 92 ++++++----------------
modules.d/90mdraid/md-noddf.sh | 5 +
modules.d/90mdraid/md-noimsm.sh | 2 +-
modules.d/90mdraid/md_finished.sh | 9 --
modules.d/90mdraid/mdadm_auto.sh | 2 +-
modules.d/90mdraid/mdcontainer_start.sh | 12 ---
modules.d/90mdraid/mdraid-cleanup.sh | 30 ++++---
modules.d/90mdraid/mdraid_start.sh | 52 ++++++++-----
modules.d/90mdraid/module-setup.sh | 15 +++-
modules.d/90mdraid/parse-md.sh | 15 +++-
13 files changed, 114 insertions(+), 131 deletions(-)
create mode 100755 modules.d/90mdraid/md-noddf.sh
delete mode 100755 modules.d/90mdraid/md_finished.sh
delete mode 100755 modules.d/90mdraid/mdcontainer_start.sh
--
1.7.5.3
^ permalink raw reply [flat|nested] 10+ messages in thread
* [RFC 1/6] 90mdraid: adjust stock mdadm udev rules
[not found] ` <1315261048-19544-1-git-send-email-soltys-R61QfzASbfY@public.gmane.org>
@ 2011-09-05 22:17 ` Michal Soltys
2011-09-05 22:17 ` [RFC 2/6] 90(md|dm)raid: recognize ddf container Michal Soltys
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Michal Soltys @ 2011-09-05 22:17 UTC (permalink / raw)
To: initramfs-u79uwXL29TY76Z2rM5mHXA
Currently shipped mdadm rules incrementally assemble all imsm and native
raids, and do so unconditionally. This causes few issues:
- fine-grained controls in 65-md* are shadowed - for example,
mdadm.conf's presence tests or uuid checks
- 90dmraid might also conflict with 90mdraid, if user prefers the former
to handle containers
- possibly other subtle issues
This patch adjusts the behaviour.
Signed-off-by: Michal Soltys <soltys-R61QfzASbfY@public.gmane.org>
---
modules.d/90mdraid/module-setup.sh | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/modules.d/90mdraid/module-setup.sh b/modules.d/90mdraid/module-setup.sh
index de7785d..91a0769 100755
--- a/modules.d/90mdraid/module-setup.sh
+++ b/modules.d/90mdraid/module-setup.sh
@@ -50,6 +50,11 @@ install() {
if [ ! -x /lib/udev/vol_id ]; then
inst_rules 64-md-raid.rules
+ # remove incremental assembly from stock rules, so they don't shadow
+ # 65-md-inc*.rules and its fine-grained controls, or cause other problems
+ # when we explicitly don't want certain components to be incrementally
+ # assembled
+ sed -i -e '/^ENV{ID_FS_TYPE}==.*ACTION=="add".*RUN+="\/sbin\/mdadm --incremental $env{DEVNAME}"$/d' "${initdir}/lib/udev/rules.d/64-md-raid.rules"
fi
inst_rules "$moddir/65-md-incremental-imsm.rules"
--
1.7.5.3
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [RFC 2/6] 90(md|dm)raid: recognize ddf container
[not found] ` <1315261048-19544-1-git-send-email-soltys-R61QfzASbfY@public.gmane.org>
2011-09-05 22:17 ` [RFC 1/6] 90mdraid: adjust stock mdadm udev rules Michal Soltys
@ 2011-09-05 22:17 ` Michal Soltys
2011-09-05 22:17 ` [RFC 3/6] 90mdraid: containers are not runnable Michal Soltys
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Michal Soltys @ 2011-09-05 22:17 UTC (permalink / raw)
To: initramfs-u79uwXL29TY76Z2rM5mHXA
This patch adds ddf support, consistently with imsm/isw options.
Signed-off-by: Michal Soltys <soltys-R61QfzASbfY@public.gmane.org>
---
dracut.kernel.7.xml | 6 ++++++
modules.d/90dmraid/61-dmraid-imsm.rules | 1 +
modules.d/90dmraid/parse-dm.sh | 4 ++++
modules.d/90mdraid/65-md-incremental-imsm.rules | 3 ++-
modules.d/90mdraid/md-noddf.sh | 5 +++++
modules.d/90mdraid/md-noimsm.sh | 2 +-
modules.d/90mdraid/module-setup.sh | 6 +++++-
modules.d/90mdraid/parse-md.sh | 6 ++++++
8 files changed, 30 insertions(+), 3 deletions(-)
create mode 100755 modules.d/90mdraid/md-noddf.sh
diff --git a/dracut.kernel.7.xml b/dracut.kernel.7.xml
index b6e59e6..8d50d94 100644
--- a/dracut.kernel.7.xml
+++ b/dracut.kernel.7.xml
@@ -343,6 +343,12 @@ This parameter can be specified multiple times.</para>
</listitem>
</varlistentry>
<varlistentry>
+ <term><envar>rd.md.ddf</envar>=0</term>
+ <listitem>
+ <para>disable MD RAID for SNIA ddf raids, use DM RAID instead</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
<term>
<envar>rd.md.conf</envar>=0
</term>
diff --git a/modules.d/90dmraid/61-dmraid-imsm.rules b/modules.d/90dmraid/61-dmraid-imsm.rules
index d87fce7..73ba58e 100644
--- a/modules.d/90dmraid/61-dmraid-imsm.rules
+++ b/modules.d/90dmraid/61-dmraid-imsm.rules
@@ -10,6 +10,7 @@ ENV{ID_FS_TYPE}=="linux_raid_member", GOTO="dm_end"
ENV{ID_FS_TYPE}!="*_raid_member", , GOTO="dm_end"
ENV{ID_FS_TYPE}=="isw_raid_member", ENV{rd_NO_MDIMSM}!="?*", GOTO="dm_end"
+ENV{ID_FS_TYPE}=="ddf_raid_member", ENV{rd_NO_MDDDF}!="?*", GOTO="dm_end"
ENV{rd_NO_DM}=="?*", GOTO="dm_end"
diff --git a/modules.d/90dmraid/parse-dm.sh b/modules.d/90dmraid/parse-dm.sh
index 059c396..fe38d35 100755
--- a/modules.d/90dmraid/parse-dm.sh
+++ b/modules.d/90dmraid/parse-dm.sh
@@ -12,3 +12,7 @@ if ! command -v mdadm >/dev/null || ! getargbool 1 rd.md.imsm -n rd_NO_MDIMSM |
udevproperty rd_NO_MDIMSM=1
fi
+if ! command -v mdadm >/dev/null || ! getargbool 1 rd.md.ddf -n rd_NO_MDDDF || getarg noddfmd; then
+ info "rd.md.ddf=0: no MD RAID for SNIA ddf raids"
+ udevproperty rd_NO_MDDDF=1
+fi
diff --git a/modules.d/90mdraid/65-md-incremental-imsm.rules b/modules.d/90mdraid/65-md-incremental-imsm.rules
index 7c1d503..d02afee 100644
--- a/modules.d/90mdraid/65-md-incremental-imsm.rules
+++ b/modules.d/90mdraid/65-md-incremental-imsm.rules
@@ -4,9 +4,10 @@
ACTION!="add|change", GOTO="md_inc_end"
SUBSYSTEM!="block", GOTO="md_inc_end"
-ENV{ID_FS_TYPE}!="linux_raid_member|isw_raid_member", GOTO="md_inc_end"
+ENV{ID_FS_TYPE}!="*_raid_member", GOTO="md_inc_end"
ENV{ID_FS_TYPE}=="isw_raid_member", ENV{rd_NO_MDIMSM}=="?*", GOTO="md_inc_end"
+ENV{ID_FS_TYPE}=="ddf_raid_member", ENV{rd_NO_MDDDF}=="?*", GOTO="md_inc_end"
ENV{rd_NO_MD}=="?*", GOTO="md_inc_end"
diff --git a/modules.d/90mdraid/md-noddf.sh b/modules.d/90mdraid/md-noddf.sh
new file mode 100755
index 0000000..bc46dd7
--- /dev/null
+++ b/modules.d/90mdraid/md-noddf.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
+# ex: ts=8 sw=4 sts=4 et filetype=sh
+info "rd.md.ddf=0: no MD RAID for SNIA ddf raids"
+udevproperty rd_NO_MDDDF=1
diff --git a/modules.d/90mdraid/md-noimsm.sh b/modules.d/90mdraid/md-noimsm.sh
index bc9cf7f..8272f86 100755
--- a/modules.d/90mdraid/md-noimsm.sh
+++ b/modules.d/90mdraid/md-noimsm.sh
@@ -2,4 +2,4 @@
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
info "rd.md.imsm=0: no MD RAID for imsm/isw raids"
-udevproperty rd_NO_MDIMSM=1
\ No newline at end of file
+udevproperty rd_NO_MDIMSM=1
diff --git a/modules.d/90mdraid/module-setup.sh b/modules.d/90mdraid/module-setup.sh
index 91a0769..ae432ba 100755
--- a/modules.d/90mdraid/module-setup.sh
+++ b/modules.d/90mdraid/module-setup.sh
@@ -20,7 +20,7 @@ check() {
check_block_and_slaves is_mdraid "$_rootdev" || return 1
else
# root is not on a block device, use the shotgun approach
- blkid | egrep -q '(linux|isw)_raid' || return 1
+ blkid | grep -q '"[^"]*_raid_member"' || return 1
fi
}
@@ -59,9 +59,13 @@ install() {
inst_rules "$moddir/65-md-incremental-imsm.rules"
+ # guard against pre-3.0 mdadm versions, that can't handle containers
if ! mdadm -Q -e imsm /dev/null &> /dev/null; then
inst_hook pre-trigger 30 "$moddir/md-noimsm.sh"
fi
+ if ! mdadm -Q -e ddf /dev/null &> /dev/null; then
+ inst_hook pre-trigger 30 "$moddir/md-noddf.sh"
+ fi
if [[ $hostonly ]] || [[ $mdadmconf = "yes" ]]; then
if [ -f /etc/mdadm.conf ]; then
diff --git a/modules.d/90mdraid/parse-md.sh b/modules.d/90mdraid/parse-md.sh
index 6d1b615..adcc402 100755
--- a/modules.d/90mdraid/parse-md.sh
+++ b/modules.d/90mdraid/parse-md.sh
@@ -42,3 +42,9 @@ if ! getargbool 1 rd.md.imsm -n rd_NO_MDIMSM || getarg noiswmd || getarg nodmrai
info "no MD RAID for imsm/isw raids"
udevproperty rd_NO_MDIMSM=1
fi
+
+# same thing with ddf containers
+if ! getargbool 1 rd.md.ddf -n rd_NO_MDDDF || getarg noddfmd || getarg nodmraid; then
+ info "no MD RAID for SNIA ddf raids"
+ udevproperty rd_NO_MDDDF=1
+fi
--
1.7.5.3
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [RFC 3/6] 90mdraid: containers are not runnable
[not found] ` <1315261048-19544-1-git-send-email-soltys-R61QfzASbfY@public.gmane.org>
2011-09-05 22:17 ` [RFC 1/6] 90mdraid: adjust stock mdadm udev rules Michal Soltys
2011-09-05 22:17 ` [RFC 2/6] 90(md|dm)raid: recognize ddf container Michal Soltys
@ 2011-09-05 22:17 ` Michal Soltys
2011-09-05 22:17 ` [RFC 4/6] 90mdraid: fix/adjust mdraid-cleanup Michal Soltys
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Michal Soltys @ 2011-09-05 22:17 UTC (permalink / raw)
To: initramfs-u79uwXL29TY76Z2rM5mHXA
Remove whole "start a container logic".
Containers once assembled, always remain in 'inactive' state.
Any attempt to run a container with mdadm -IR is a no-op, and any
attempt with just mdadm -R ends with an error.
Signed-off-by: Michal Soltys <soltys-R61QfzASbfY@public.gmane.org>
---
modules.d/90mdraid/65-md-incremental-imsm.rules | 20 --------------------
modules.d/90mdraid/md_finished.sh | 2 +-
modules.d/90mdraid/mdcontainer_start.sh | 12 ------------
modules.d/90mdraid/module-setup.sh | 1 -
4 files changed, 1 insertions(+), 34 deletions(-)
delete mode 100755 modules.d/90mdraid/mdcontainer_start.sh
diff --git a/modules.d/90mdraid/65-md-incremental-imsm.rules b/modules.d/90mdraid/65-md-incremental-imsm.rules
index d02afee..bb030cf 100644
--- a/modules.d/90mdraid/65-md-incremental-imsm.rules
+++ b/modules.d/90mdraid/65-md-incremental-imsm.rules
@@ -67,23 +67,3 @@ RUN+="/sbin/initqueue --finished --unique --name md_finished /sbin/md_finished.s
RUN+="/sbin/initqueue --timeout --onetime --unique /sbin/mdraid_start"
LABEL="end_raidstart"
-
-#
-# Handle container raid arrays
-#
-ACTION=="add|change", \
- KERNEL=="md[0-9]*|md/*", \
- ENV{DEVTYPE}!="partition", \
- ENV{MD_LEVEL}=="container", \
- ENV{rd_MDADMCONF}!="?*", \
- ENV{rd_NO_MD}!="?*", \
- GOTO="do_container"
-
-GOTO="end_container"
-
-LABEL="do_container"
-
-RUN+="/sbin/initqueue --finished --unique --name md_finished /sbin/md_finished.sh"
-RUN+="/sbin/initqueue --timeout --onetime --unique --name mdcontainer_start-%k /sbin/mdcontainer_start $env{DEVNAME}"
-
-LABEL="end_container"
diff --git a/modules.d/90mdraid/md_finished.sh b/modules.d/90mdraid/md_finished.sh
index cde0966..ce355be 100755
--- a/modules.d/90mdraid/md_finished.sh
+++ b/modules.d/90mdraid/md_finished.sh
@@ -1,7 +1,7 @@
#!/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/mdcontainer_start* $hookdir/initqueue/settled/mdraid_start* $hookdir/initqueue/settled/mdadm_auto*; do
+for f in $hookdir/initqueue/settled/mdraid_start* $hookdir/initqueue/settled/mdadm_auto*; do
[ -e $f ] && exit 1
done
diff --git a/modules.d/90mdraid/mdcontainer_start.sh b/modules.d/90mdraid/mdcontainer_start.sh
deleted file mode 100755
index e7dd3ef..0000000
--- a/modules.d/90mdraid/mdcontainer_start.sh
+++ /dev/null
@@ -1,12 +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
-type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
-
-md=$1
-udevadm control --stop-exec-queue
-# and activate any containers
-mdadm -IR $md 2>&1 | vinfo
-ln -s $(command -v mdraid-cleanup) $hookdir/pre-pivot/30-mdraid-cleanup.sh 2>/dev/null
-ln -s $(command -v mdraid-cleanup) $hookdir/pre-pivot/31-mdraid-cleanup.sh 2>/dev/null
-udevadm control --start-exec-queue
diff --git a/modules.d/90mdraid/module-setup.sh b/modules.d/90mdraid/module-setup.sh
index ae432ba..ccb4a0d 100755
--- a/modules.d/90mdraid/module-setup.sh
+++ b/modules.d/90mdraid/module-setup.sh
@@ -81,7 +81,6 @@ install() {
inst_hook pre-udev 30 "$moddir/mdmon-pre-udev.sh"
inst "$moddir/mdraid_start.sh" /sbin/mdraid_start
- inst "$moddir/mdcontainer_start.sh" /sbin/mdcontainer_start
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"
--
1.7.5.3
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [RFC 4/6] 90mdraid: fix/adjust mdraid-cleanup
[not found] ` <1315261048-19544-1-git-send-email-soltys-R61QfzASbfY@public.gmane.org>
` (2 preceding siblings ...)
2011-09-05 22:17 ` [RFC 3/6] 90mdraid: containers are not runnable Michal Soltys
@ 2011-09-05 22:17 ` Michal Soltys
2011-09-05 22:17 ` [RFC 5/6] 90mdraid: fix/adjust force-run script Michal Soltys
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Michal Soltys @ 2011-09-05 22:17 UTC (permalink / raw)
To: initramfs-u79uwXL29TY76Z2rM5mHXA
Stop both arrays (first pass) and containers (second pass).
Loop only over /dev/md[0-9]*
Call cleanup script only once, make sure it's after crypt cleanup.
Signed-off-by: Michal Soltys <soltys-R61QfzASbfY@public.gmane.org>
---
modules.d/90mdraid/mdraid-cleanup.sh | 30 +++++++++++++++++-------------
modules.d/90mdraid/mdraid_start.sh | 1 -
2 files changed, 17 insertions(+), 14 deletions(-)
diff --git a/modules.d/90mdraid/mdraid-cleanup.sh b/modules.d/90mdraid/mdraid-cleanup.sh
index add02e0..8fc54e2 100755
--- a/modules.d/90mdraid/mdraid-cleanup.sh
+++ b/modules.d/90mdraid/mdraid-cleanup.sh
@@ -2,18 +2,22 @@
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
-# stop everything which is not busy
-for i in /dev/md* /dev/md/*; do
- [ -b $i ] || continue
+type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
- mddetail=$(udevadm info --query=property --name=$i)
- case "$mddetail" in
- *MD_LEVEL=container*)
- ;;
- *DEVTYPE=partition*)
- ;;
- *)
- mdadm --stop $i >/dev/null 2>&1
- ;;
- esac
+containers=""
+for md in /dev/md[0-9]*; do
+ [ -b "$md" ] || continue
+ udevinfo="$(udevadm info --query=env --name=$md)"
+ strstr "$udevinfo" "DEVTYPE=partition" && continue
+ if strstr "$udevinfo" "MD_LEVEL=container"; then
+ containers="$containers $md"
+ continue
+ fi
+ mdadm -S "$md" >/dev/null 2>&1
done
+
+for md in $containers; do
+ mdadm -S "$md" >/dev/null 2>&1
+done
+
+unset containers udevinfo
diff --git a/modules.d/90mdraid/mdraid_start.sh b/modules.d/90mdraid/mdraid_start.sh
index 4aa7f82..4c0255e 100755
--- a/modules.d/90mdraid/mdraid_start.sh
+++ b/modules.d/90mdraid/mdraid_start.sh
@@ -21,6 +21,5 @@ for md in /dev/md[0-9]* /dev/md/*; do
done
unset udevinfo
-ln -s $(command -v mdraid-cleanup) $hookdir/pre-pivot/30-mdraid-cleanup.sh 2>/dev/null
ln -s $(command -v mdraid-cleanup) $hookdir/pre-pivot/31-mdraid-cleanup.sh 2>/dev/null
udevadm control --start-exec-queue
--
1.7.5.3
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [RFC 5/6] 90mdraid: fix/adjust force-run script
[not found] ` <1315261048-19544-1-git-send-email-soltys-R61QfzASbfY@public.gmane.org>
` (3 preceding siblings ...)
2011-09-05 22:17 ` [RFC 4/6] 90mdraid: fix/adjust mdraid-cleanup Michal Soltys
@ 2011-09-05 22:17 ` Michal Soltys
2011-09-05 22:17 ` [RFC 6/6] 90mdraid: fix/adjust 65-md* rules and related scripts Michal Soltys
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Michal Soltys @ 2011-09-05 22:17 UTC (permalink / raw)
To: initramfs-u79uwXL29TY76Z2rM5mHXA
1) mdadm -As --auto=yes --run 2>&1 | vinfo (removed)
Currently such auto assembly will not complete or force-run partially
assembled arrays. It might assemble "concurrent" separate array and
force-run it, if possible (though the chances of suddenly showing
missing components in this scenario - a script run after udev timeout -
are pretty thin). See [1] for details. Also see #3 below.
2) mdadm -Is --run 2>&1 (removed)
This will only force-run native arrays - arrays in containers will not
be affected. See [1] for details. Also see #3 below.
3) mdadm -R run loop (implicitly handles #1 & #2)
This loop does everywthing that #1 & #2 are expected to do. Thus, the
above invocations are simply redundant and this is the most safe and
flexible option.
Also, it shouldn't be necessary to go under md/ directory, as those are
just symlinks to /dev/md[0-9]*.
Certain checks were changed to strict ones (array state, degraded state)
instead of relying on env tricks.
'cat' was added explicitly to installed programs (it has been used
implicitly in shutdown script either way)
4) mdmon bug
See [1] for details as well. In short - force-run arrays in containers
will not have mdmon started, so we do that manually.
5) stop/run queue magic
Also removed. mdadm -R will only cause change events to the array
itself, and they should not be an issue.
[1] http://article.gmane.org/gmane.linux.raid/35133
Signed-off-by: Michal Soltys <soltys-R61QfzASbfY@public.gmane.org>
---
modules.d/90mdraid/mdraid_start.sh | 51 ++++++++++++++++++++++--------------
modules.d/90mdraid/module-setup.sh | 2 +-
modules.d/90mdraid/parse-md.sh | 1 +
3 files changed, 33 insertions(+), 21 deletions(-)
diff --git a/modules.d/90mdraid/mdraid_start.sh b/modules.d/90mdraid/mdraid_start.sh
index 4c0255e..be5a3ce 100755
--- a/modules.d/90mdraid/mdraid_start.sh
+++ b/modules.d/90mdraid/mdraid_start.sh
@@ -3,23 +3,34 @@
# ex: ts=8 sw=4 sts=4 et filetype=sh
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
-# run mdadm if udev has settled
-info "Assembling MD RAID arrays"
-udevadm control --stop-exec-queue
-mdadm -As --auto=yes --run 2>&1 | vinfo
-mdadm -Is --run 2>&1 | vinfo
-
-# there could still be some leftover devices
-# which have had a container added
-for md in /dev/md[0-9]* /dev/md/*; do
- [ -b "$md" ] || continue
- udevinfo="$(udevadm info --query=env --name=$md)"
- strstr "$udevinfo" "MD_UUID=" && continue
- strstr "$udevinfo" "MD_LEVEL=container" && continue
- strstr "$udevinfo" "DEVTYPE=partition" && continue
- mdadm --run "$md" 2>&1 | vinfo
-done
-unset udevinfo
-
-ln -s $(command -v mdraid-cleanup) $hookdir/pre-pivot/31-mdraid-cleanup.sh 2>/dev/null
-udevadm control --start-exec-queue
+_md_force_run() {
+ local _udevinfo
+ local _path_s
+ local _path_d
+ # try to force-run anything not running yet
+ for md in /dev/md[0-9]*; do
+ [ -b "$md" ] || continue
+ _udevinfo="$(udevadm info --query=env --name="$md")"
+ strstr "$_udevinfo" "MD_LEVEL=container" && continue
+ strstr "$_udevinfo" "DEVTYPE=partition" && continue
+
+ _path_s="$(udevadm info -q path -n "$md")/md/array_state"
+ [ ! -r "$_path_s" ] && continue
+
+ # inactive ?
+ [ "$(cat "$_path_s")" != "inactive" ] && continue
+
+ mdadm -R "$md" 2>&1 | vinfo
+
+ # still inactive ?
+ [ "$(cat "$_path_s")" = "inactive" ] && continue
+
+ _path_d="${_path_s%/*}/degraded"
+ [ ! -r "$_path_d" ] && continue
+
+ # workaround for mdmon bug
+ [ "$(cat "$_path_d")" -gt "0" ] && mdmon --takeover "$md"
+ done
+}
+
+_md_force_run
diff --git a/modules.d/90mdraid/module-setup.sh b/modules.d/90mdraid/module-setup.sh
index ccb4a0d..5c526a0 100755
--- a/modules.d/90mdraid/module-setup.sh
+++ b/modules.d/90mdraid/module-setup.sh
@@ -37,7 +37,7 @@ installkernel() {
}
install() {
- dracut_install mdadm partx
+ dracut_install mdadm partx cat
# XXX: mdmon really needs to run as non-root?
diff --git a/modules.d/90mdraid/parse-md.sh b/modules.d/90mdraid/parse-md.sh
index adcc402..33d93dc 100755
--- a/modules.d/90mdraid/parse-md.sh
+++ b/modules.d/90mdraid/parse-md.sh
@@ -34,6 +34,7 @@ fi
if ! getargbool 1 rd.md.conf -n rd_NO_MDADMCONF; then
rm -f /etc/mdadm/mdadm.conf /etc/mdadm.conf
+ ln -s $(command -v mdraid-cleanup) $hookdir/pre-pivot/31-mdraid-cleanup.sh 2>/dev/null
fi
# noiswmd nodmraid for anaconda / rc.sysinit compatibility
--
1.7.5.3
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [RFC 6/6] 90mdraid: fix/adjust 65-md* rules and related scripts
[not found] ` <1315261048-19544-1-git-send-email-soltys-R61QfzASbfY@public.gmane.org>
` (4 preceding siblings ...)
2011-09-05 22:17 ` [RFC 5/6] 90mdraid: fix/adjust force-run script Michal Soltys
@ 2011-09-05 22:17 ` Michal Soltys
2011-09-09 20:02 ` question - minimal mdadm version Michal Soltys
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Michal Soltys @ 2011-09-05 22:17 UTC (permalink / raw)
To: initramfs-u79uwXL29TY76Z2rM5mHXA
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-R61QfzASbfY@public.gmane.org>
---
modules.d/90mdraid/65-md-incremental-imsm.rules | 79 ++++++++---------------
modules.d/90mdraid/md_finished.sh | 9 ---
modules.d/90mdraid/mdadm_auto.sh | 2 +-
modules.d/90mdraid/module-setup.sh | 1 -
modules.d/90mdraid/parse-md.sh | 8 ++-
5 files changed, 34 insertions(+), 65 deletions(-)
delete mode 100755 modules.d/90mdraid/md_finished.sh
diff --git a/modules.d/90mdraid/65-md-incremental-imsm.rules b/modules.d/90mdraid/65-md-incremental-imsm.rules
index bb030cf..209b17b 100644
--- a/modules.d/90mdraid/65-md-incremental-imsm.rules
+++ b/modules.d/90mdraid/65-md-incremental-imsm.rules
@@ -2,68 +2,45 @@
# automatically cause mdadm to be run.
# See udev(8) for syntax
-ACTION!="add|change", GOTO="md_inc_end"
-SUBSYSTEM!="block", GOTO="md_inc_end"
-ENV{ID_FS_TYPE}!="*_raid_member", GOTO="md_inc_end"
-
-ENV{ID_FS_TYPE}=="isw_raid_member", ENV{rd_NO_MDIMSM}=="?*", GOTO="md_inc_end"
-ENV{ID_FS_TYPE}=="ddf_raid_member", ENV{rd_NO_MDDDF}=="?*", GOTO="md_inc_end"
-
-ENV{rd_NO_MD}=="?*", GOTO="md_inc_end"
-
-PROGRAM=="/bin/sh -c 'for i in $sys/$devpath/holders/md[0-9]*; do [ -e $$i ] && exit 0; done; exit 1;' ", \
- GOTO="md_inc_end"
+ACTION!="add|change", GOTO="md_end"
+SUBSYSTEM!="block", GOTO="md_end"
+ENV{rd_NO_MD}=="?*", GOTO="md_end"
+KERNEL=="md*", GOTO="md_end"
+
+ENV{ID_FS_TYPE}!="*_raid_member", GOTO="md_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"
+
+# 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"
+
+# for native arrays - array's uuid has to be specified
+# 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", \
RUN+="/sbin/partx -d --nr 1-1024 $env{DEVNAME}"
-KERNEL!="md*", IMPORT{program}="/sbin/mdadm --examine --export $tempnode"
-
-# UUID CHECK
-
-LABEL="do_md_inc"
+RUN+="/sbin/initqueue --timeout --onetime --unique /sbin/mdraid_start"
+# if rd_MDADMCONF is set, do not assemble incrementally;
+# defer conf-based assembly until the udev queue is settled
#
-# if rd_MDADMCONF do not assemble incrementally
-# defer auto assembly until the udev queue is settled
-#
-ENV{rd_MDADMCONF}!="?*", GOTO="md_auto_end"
+ENV{rd_MDADMCONF}!="?*", GOTO="md_incremental"
-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"
+GOTO="md_end"
#
-# Incrementally build the md array
+# Incrementally build the md array; this will automatically assemble
+# any eventual containers as well (imsm, ddf)
#
-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"
+LABEL="md_incremental"
-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/mdadm -I $env{DEVNAME}"
-LABEL="end_raidstart"
+LABEL="md_end"
diff --git a/modules.d/90mdraid/md_finished.sh b/modules.d/90mdraid/md_finished.sh
deleted file mode 100755
index ce355be..0000000
--- a/modules.d/90mdraid/md_finished.sh
+++ /dev/null
@@ -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
diff --git a/modules.d/90mdraid/mdadm_auto.sh b/modules.d/90mdraid/mdadm_auto.sh
index 915fb28..9b61bf5 100755
--- a/modules.d/90mdraid/mdadm_auto.sh
+++ b/modules.d/90mdraid/mdadm_auto.sh
@@ -4,4 +4,4 @@
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
info "Autoassembling MD Raid"
-mdadm -As --auto=yes --run 2>&1 | vinfo
+mdadm -As --auto=yes 2>&1 | vinfo
diff --git a/modules.d/90mdraid/module-setup.sh b/modules.d/90mdraid/module-setup.sh
index 5c526a0..12e6739 100755
--- a/modules.d/90mdraid/module-setup.sh
+++ b/modules.d/90mdraid/module-setup.sh
@@ -82,7 +82,6 @@ install() {
inst "$moddir/mdraid_start.sh" /sbin/mdraid_start
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 "$moddir/mdraid-cleanup.sh" /sbin/mdraid-cleanup
inst_hook shutdown 30 "$moddir/md-shutdown.sh"
diff --git a/modules.d/90mdraid/parse-md.sh b/modules.d/90mdraid/parse-md.sh
index 33d93dc..b85a3a3 100755
--- a/modules.d/90mdraid/parse-md.sh
+++ b/modules.d/90mdraid/parse-md.sh
@@ -13,12 +13,14 @@ else
[ -e "$f" ] || continue
while read line; do
if [ "${line%%UUID CHECK}" != "$line" ]; then
+ printf 'IMPORT{program}="/sbin/mdadm --examine --export $tempnode"\n'
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;
- printf 'GOTO="md_inc_end"\n';
+ printf 'GOTO="md_end"\n'
+ printf 'LABEL="md_uuid_ok"\n'
else
- echo $line;
+ echo "$line"
fi
done < "${f}" > "${f}.new"
mv "${f}.new" "$f"
--
1.7.5.3
^ permalink raw reply related [flat|nested] 10+ messages in thread
* question - minimal mdadm version
[not found] ` <1315261048-19544-1-git-send-email-soltys-R61QfzASbfY@public.gmane.org>
` (5 preceding siblings ...)
2011-09-05 22:17 ` [RFC 6/6] 90mdraid: fix/adjust 65-md* rules and related scripts Michal Soltys
@ 2011-09-09 20:02 ` Michal Soltys
2011-09-10 23:33 ` [RFC 0/6] Update 90mdraid Michal Soltys
2011-09-22 13:45 ` Harald Hoyer
8 siblings, 0 replies; 10+ messages in thread
From: Michal Soltys @ 2011-09-09 20:02 UTC (permalink / raw)
To: initramfs-u79uwXL29TY76Z2rM5mHXA
I've been experimenting with a bit different approach, but trying to be
mdadm version-neutral kinda ties the hands.
Is there any minimal version that must be supported ? I was thinking
about 3.0, but that's probably far too new - and current code assumes
pre-udev/container version can be present.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC 0/6] Update 90mdraid
[not found] ` <1315261048-19544-1-git-send-email-soltys-R61QfzASbfY@public.gmane.org>
` (6 preceding siblings ...)
2011-09-09 20:02 ` question - minimal mdadm version Michal Soltys
@ 2011-09-10 23:33 ` Michal Soltys
2011-09-22 13:45 ` Harald Hoyer
8 siblings, 0 replies; 10+ messages in thread
From: Michal Soltys @ 2011-09-10 23:33 UTC (permalink / raw)
To: initramfs-u79uwXL29TY76Z2rM5mHXA
Either way, I'll be doing v2 with quite a bit different approach - a
clean split for mdadm 2.x (pre-udev/pre-container) and 3.x - as things
are a little bit different with both of those.
Also, 2.x path is better with -As and conf file telling what to do,
while 3.x with -I and conf telling what not to do (trivially allowing
the same behaviour as with old -As). Some details about conf file are
also different, so this approach should be cleaner than trying to throw
everything into one big bag.
From other changes I'm thinking about adding few potentially useful
options - assembly by name (storing one is supported by 1.x and ddf),
controlling force-run, allowing partitionable raid on <2.6.28 kernels,
and few other lesser details.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC 0/6] Update 90mdraid
[not found] ` <1315261048-19544-1-git-send-email-soltys-R61QfzASbfY@public.gmane.org>
` (7 preceding siblings ...)
2011-09-10 23:33 ` [RFC 0/6] Update 90mdraid Michal Soltys
@ 2011-09-22 13:45 ` Harald Hoyer
8 siblings, 0 replies; 10+ messages in thread
From: Harald Hoyer @ 2011-09-22 13:45 UTC (permalink / raw)
To: Michal Soltys; +Cc: initramfs-u79uwXL29TY76Z2rM5mHXA
On 06.09.2011 00:17, Michal Soltys wrote:
> This is a set of patches simplifying mdraid module, with a few fixes along the way.
>
> 1) 90mdraid: adjust stock mdadm udev rules
> 2) 90(md|dm)raid: recognize ddf container
> 3) 90mdraid: containers are not runnable
> 4) 90mdraid: fix/adjust mdraid-cleanup
> 5) 90mdraid: fix/adjust force-run script
> 6) 90mdraid: fix/adjust 65-md* rules and related scripts
>
> First 4 patches are pretty simple and could likely go in. In particular, 1st
> one has a fix for stock mdadm rules, which originally cause unconditional
> incremental assembly of all native+imsm components.
>
> #4 - I'm still not sure, why exactly raid cleanup was called twice.
>
> #5 and #6 are main part with more changes resulting with, subjecitvely,
> cleaner and shorter code. All the details and rationale are in respective
> commit messages.
>
> It looks solid, but it's still work in progress and requires some
> testing. Comment if you have any objections or questions.
>
> For convenience, it can be also pulled from:
> git://git.hasevolq.net/dracut.git mdraid-fix-v1
>
>
> Michal Soltys (6):
> 90mdraid: adjust stock mdadm udev rules
> 90(md|dm)raid: recognize ddf container
> 90mdraid: containers are not runnable
> 90mdraid: fix/adjust mdraid-cleanup
> 90mdraid: fix/adjust force-run script
> 90mdraid: fix/adjust 65-md* rules and related scripts
>
> dracut.kernel.7.xml | 6 ++
> modules.d/90dmraid/61-dmraid-imsm.rules | 1 +
> modules.d/90dmraid/parse-dm.sh | 4 +
> modules.d/90mdraid/65-md-incremental-imsm.rules | 92 ++++++----------------
> modules.d/90mdraid/md-noddf.sh | 5 +
> modules.d/90mdraid/md-noimsm.sh | 2 +-
> modules.d/90mdraid/md_finished.sh | 9 --
> modules.d/90mdraid/mdadm_auto.sh | 2 +-
> modules.d/90mdraid/mdcontainer_start.sh | 12 ---
> modules.d/90mdraid/mdraid-cleanup.sh | 30 ++++---
> modules.d/90mdraid/mdraid_start.sh | 52 ++++++++-----
> modules.d/90mdraid/module-setup.sh | 15 +++-
> modules.d/90mdraid/parse-md.sh | 15 +++-
> 13 files changed, 114 insertions(+), 131 deletions(-)
> create mode 100755 modules.d/90mdraid/md-noddf.sh
> delete mode 100755 modules.d/90mdraid/md_finished.sh
> delete mode 100755 modules.d/90mdraid/mdcontainer_start.sh
>
pushed to temporary git: http://git.surfsite.org/dracut.git
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2011-09-22 13:45 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-05 22:17 [RFC 0/6] Update 90mdraid Michal Soltys
[not found] ` <1315261048-19544-1-git-send-email-soltys-R61QfzASbfY@public.gmane.org>
2011-09-05 22:17 ` [RFC 1/6] 90mdraid: adjust stock mdadm udev rules Michal Soltys
2011-09-05 22:17 ` [RFC 2/6] 90(md|dm)raid: recognize ddf container Michal Soltys
2011-09-05 22:17 ` [RFC 3/6] 90mdraid: containers are not runnable Michal Soltys
2011-09-05 22:17 ` [RFC 4/6] 90mdraid: fix/adjust mdraid-cleanup Michal Soltys
2011-09-05 22:17 ` [RFC 5/6] 90mdraid: fix/adjust force-run script Michal Soltys
2011-09-05 22:17 ` [RFC 6/6] 90mdraid: fix/adjust 65-md* rules and related scripts Michal Soltys
2011-09-09 20:02 ` question - minimal mdadm version Michal Soltys
2011-09-10 23:33 ` [RFC 0/6] Update 90mdraid Michal Soltys
2011-09-22 13:45 ` Harald Hoyer
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.