From: Dan Williams <djbw@xxxxxx> sysfs deprecated makes forwarding udev events from a scsi device to its block device difficult. Provide a workalike for the udev rule: ACTION=="change", SUBSYSTEM=="scsi", ENV{DEVTYPE}=="scsi_device", \ TEST=="block", ATTR{block/*/uevent}="change" Signed-off-by: Dan Williams <dan.j.williams@xxxxxxxxx> Signed-off-by: Song Liu <songliubraving@xxxxxx> --- Makefile | 17 +++++++++++++++-- forward-scsi-uevents | 14 ++++++++++++++ ...enclosure-slot.rules => udev-enclosure-slot.rules.in | 2 -- udev-workaround-sysfs-deprecated.in | 2 ++ 4 files changed, 31 insertions(+), 4 deletions(-) create mode 100755 forward-scsi-uevents rename udev-enclosure-slot.rules => udev-enclosure-slot.rules.in (87%) create mode 100644 udev-workaround-sysfs-deprecated.in diff --git a/Makefile b/Makefile index 4eb2dad..2963884 100644 --- a/Makefile +++ b/Makefile @@ -292,7 +292,17 @@ install-man: mdadm.8 md.4 mdadm.conf.5 mdmon.8 $(INSTALL) -D -m 644 md.4 $(DESTDIR)$(MAN4DIR)/md.4 $(INSTALL) -D -m 644 mdadm.conf.5 $(DESTDIR)$(MAN5DIR)/mdadm.conf.5 -install-udev: udev-md-raid-arrays.rules udev-md-raid-assembly.rules +udev-enclosure-slot.rules: udev-enclosure-slot.rules.in udev-workaround-sysfs-deprecated.in Makefile + @echo "$@: generate" + @/bin/echo -e "# do not edit this file, it will be overwritten on update\n" > $@ + @if [ ! -d /sys/class/block ]; then \ + echo "$@: applying sysfs-deprecated workaround"; \ + cat udev-workaround-sysfs-deprecated.in >> $@; \ + fi + @cat udev-enclosure-slot.rules.in >> $@ + +install-udev: udev-md-raid-arrays.rules udev-md-raid-assembly.rules udev-enclosure-slot.rules \ + forward-scsi-uevents $(INSTALL) -D -m 655 ses_slot_id $(DESTDIR)$(LIBDIR)/ses_slot_id $(INSTALL) -D -m 644 udev-enclosure-slot.rules $(DESTDIR)$(UDEVDIR)/rules.d/62-md-enclosure-slot.rules @for file in 63-md-raid-arrays.rules 64-md-raid-assembly.rules ; \ @@ -301,6 +311,9 @@ install-udev: udev-md-raid-arrays.rules udev-md-raid-assembly.rules $(INSTALL) -D -m 644 .install.tmp.1 $(DESTDIR)$(UDEVDIR)/rules.d/$$file ; \ rm -f .install.tmp.1; \ done + @if [ ! -d /sys/class/block ]; then \ + $(INSTALL) -D -m 655 forward-scsi-uevents $(DESTDIR)$(UDEVDIR)/forward-scsi-uevents; \ + fi install-systemd: systemd/mdmon@.service @for file in mdmon@.service mdmonitor.service mdadm-last-resort@.timer \ @@ -331,7 +344,7 @@ clean : mdassemble mdassemble.static mdassemble.auto mdassemble.uclibc \ mdassemble.klibc swap_super \ init.cpio.gz mdadm.uclibc.static test_stripe raid6check raid6check.o mdmon \ - mdadm.8 + mdadm.8 udev-enclosure-slot.rules dist : clean ./makedist diff --git a/forward-scsi-uevents b/forward-scsi-uevents new file mode 100755 index 0000000..d43687f --- /dev/null +++ b/forward-scsi-uevents @@ -0,0 +1,14 @@ +#!/bin/sh + +# on sysfs-deprecated hosts the default udev rules are unable to forward +# udev events to the block device, this is a hack to enable this +# forwarding by searching for the matching device path + +for i in /sys/block/sd* +do + DEV=$(readlink -f $i/device) + if [ $DEV = /sys$1 ]; then + echo "change" > $i/uevent + break + fi +done diff --git a/udev-enclosure-slot.rules b/udev-enclosure-slot.rules.in similarity index 87% rename from udev-enclosure-slot.rules rename to udev-enclosure-slot.rules.in index 75c6376..50e3c45 100644 --- a/udev-enclosure-slot.rules +++ b/udev-enclosure-slot.rules.in @@ -1,5 +1,3 @@ -# do not edit this file, it will be overwritten on update - SUBSYSTEM!="block", GOTO="ses_slot_end" ACTION!="add|change", GOTO="ses_slot_end" diff --git a/udev-workaround-sysfs-deprecated.in b/udev-workaround-sysfs-deprecated.in new file mode 100644 index 0000000..65a21b3 --- /dev/null +++ b/udev-workaround-sysfs-deprecated.in @@ -0,0 +1,2 @@ +ACTION=="change", SUBSYSTEM=="scsi", ENV{DEVTYPE}=="scsi_device", TEST=="scsi_disk", RUN="forward-scsi-uevents %p" + -- 2.4.6 -- To unsubscribe from this list: send the line "unsubscribe linux-raid" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html