multipath.rules: fixup race condition with systemd
[multipath-tools/.git] / multipath / multipath.rules
index ffc11a3..c76e6b8 100644 (file)
@@ -1,22 +1,14 @@
-#
-# multipath and multipath partitions nodes are created in /dev/mapper/
-# this file should be installed in /etc/udev/rules.d
-#
-# !! udev must not discard DM events !!
-# !! check the other installed rules !!
-#
+# Set DM_MULTIPATH_DEVICE_PATH if the device should be handled by multipath
+SUBSYSTEM!="block", GOTO="end_mpath"
 
-# lookup the devmap name
-#ACTION=="add", SUBSYSTEM=="block", KERNEL=="dm-*", \
-#      PROGRAM="/sbin/devmap_name %M %m"
-ACTION=="add", SUBSYSTEM=="block", KERNEL=="dm-*", \
-       PROGRAM="dmsetup -j %M -m %m --noopencount -n -c -o name info"
+ENV{MPATH_SBIN_PATH}="/sbin"
+TEST!="$env{MPATH_SBIN_PATH}/multipath", ENV{MPATH_SBIN_PATH}="/usr/sbin"
 
-# take care of devmap partitioning
-ACTION=="add", SUBSYSTEM=="block", KERNEL=="dm-*", \
-       RUN+="/sbin/kpartx -a /dev/mapper/%c"
-
-# insert new paths in multipath topology
-ACTION=="add", SUBSYSTEM=="block", KERNEL!="dm-*", \
-       RUN+="/sbin/multipath -v0 %M:%m"
+SUBSYSTEM=="block", ACTION=="add|change", KERNEL=="sd*|dasd*", \
+       ENV{DM_MULTIPATH_DEVICE_PATH}!="1", \
+       PROGRAM=="$env{MPATH_SBIN_PATH}/multipath -u %k", \
+       ENV{DM_MULTIPATH_DEVICE_PATH}="1" \
+       ENV{ID_FS_TYPE}="none" \
+       ENV{SYSTEMD_READY}="0"
 
+LABEL="end_mpath"