initramfs issues with mdraid/bcache-tools/lvm2 on debian wheezy-backports 3.16

Tero Marttila
2014-10-11T15:49:28Z

Hi,

I had some difficulty getting an md-raid1 / bcache / lvm stack to boot up
succesfully on the recent debian wheezy-backports 3.16-0.bpo.2-amd64 kernel
with the rootfs on bcache (and a separate /boot).

I ended up having to patch two parts of the initramfs to get it working.
The bcache-tools patch is probably not the correct solution, but I'm not sure
what the exact issue is which causes bcache-register to fail for a newly added
md device..

1)

In bcache-tools, the /dev/md0 udev rule to invoke

/lib/udev/bcache-register /dev/md0

has some timing constraint; namely, during initramfs bootup the

echo "$1" > /sys/fs/bcache/register_quiet

part seems to give (based on udev_log="debug" output):

write error: Invalid arument

without any additional info in dmesg.

However, running the identical command:

/lib/udev/bcache-register /dev/md0

by hand a short while later from within the initramfs prompts works..

I modified bcache-register to include include a sleep, and now the
/dev/bcache0 device registers during boot.

2)

This exposes a related bug within the mdadm initramfs scripts, as per

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=644876#85

So the mdadm part of local-top has to wait for udev to settle and the /dev/bcache0
devices to show up before attempting to activate the lvm VGs.

Not a bcache issues, but part of the workaround...

-- Tero Marttila

--- bcache-tools-1.0.7/bcache-register 2014-05-10 16:38:21.000000000 +0300
+++ /lib/udev/bcache-register 2014-10-11 18:27:42.641482307 +0300
@@ -1,4 +1,7 @@
#!/bin/sh
/sbin/modprobe -qba bcache
+
+echo "$0 sleeping for $1 to settle, while we have:" /dev/bcache* >&2; sleep 5
+
test -f /sys/fs/bcache/register_quiet && echo "$1" > /sys/fs/bcache/register_quiet

--- mdadm-3.2.5/debian/initramfs/script.local-top 2012-08-25 22:29:05.000000000 +0300
+++ /usr/share/initramfs-tools/scripts/local-top/mdadm 2014-10-11 18:15:23.804520521 +0300
@@ -97,11 +97,8 @@
done
fi

-if [ -x "$(command -v udevsettle)" ]; then
- verbose && log_begin_msg "Waiting for udev to process events"
- udevsettle 10
- verbose && log_end_msg
-fi
+# XXX: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=644876
+wait_for_udev 10

maybe_break post-mdadm