Register devices with just udev.

This means bcache devices will be registered earlier and in all
cases, not just when the rootfs fails to mount.

The initramfs hook is still there to ensure the bcache module
and udev rules are shipped if an initramfs is used.
This commit is contained in:
Gabriel 2013-04-11 16:44:03 +02:00 committed by Kent Overstreet
parent 3088f201ed
commit 944cb4ce32
5 changed files with 14 additions and 35 deletions

View File

@ -1,3 +1,8 @@
KERNEL=="sd*", ENV{DEVTYPE}=="disk", IMPORT{program}="/sbin/probe-bcache -o udev $tempnode"
# register bcache devices as they come up
# man 7 udev for syntax
SUBSYSTEM=="block", IMPORT{program}="/sbin/probe-bcache -o udev $tempnode"
ENV{ID_FS_UUID_ENC}=="?*", SYMLINK+="disk/by-uuid/$env{ID_FS_UUID_ENC}"
SUBSYSTEM=="block", ACTION=="add|change", ENV{ID_FS_TYPE}=="bcache", \
RUN+="bcache-register $tempnode"

View File

@ -8,7 +8,7 @@ install: make-bcache probe-bcache bcache-super-show
install -m0755 make-bcache bcache-super-show $(DESTDIR)${PREFIX}/sbin/
install -m0755 probe-bcache $(DESTDIR)/sbin/
install -m0644 61-bcache.rules $(DESTDIR)/lib/udev/rules.d/
-install -m0755 initramfs/script $(DESTDIR)/etc/initramfs-tools/scripts/init-premount/bcache
install -m0755 bcache-register $(DESTDIR)/lib/udev/
-install -m0755 initramfs/hook $(DESTDIR)/etc/initramfs-tools/hooks/bcache
install -m0644 -- *.8 $(DESTDIR)${PREFIX}/share/man/man8
# install -m0755 bcache-test $(DESTDIR)${PREFIX}/sbin/

4
bcache-register Executable file
View File

@ -0,0 +1,4 @@
#!/bin/sh
modprobe -qba bcache
test -f /sys/fs/bcache/register && echo "$1" > /sys/fs/bcache/register

View File

@ -16,5 +16,7 @@ esac
. /usr/share/initramfs-tools/hook-functions
copy_exec /bin/mknod
cp -pt "${DESTDIR}/lib/udev/rules.d" /lib/udev/rules.d/61-bcache.rules
copy_exec /lib/udev/bcache-register
copy_exec /sbin/probe-bcache
manual_add_modules bcache

View File

@ -1,32 +0,0 @@
#!/bin/sh
mountroot_fail()
{
for i in `ls /dev/sd*`; do
echo $i > /sys/fs/bcache/register_quiet
done
# for i in `ls /sys/dev/block/`; do
# DEV=/bcache_dev
#
# mknod $DEV b `echo $i|sed -e 's/:/ /'`
# echo $DEV > /sys/fs/bcache/register_quiet
# rm $DEV
# done
}
case $1 in
prereqs)
exit 0
;;
mountfail)
mountroot_fail
exit 0
;;
esac
. /scripts/functions
add_mountroot_fail_hook "30-bcache"
exit 0