60-multipath.rules 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. # Set DM_MULTIPATH_DEVICE_PATH if the device should be handled by multipath
  2. SUBSYSTEM!="block", GOTO="end_mpath"
  3. KERNEL!="sd*|dasd*|nvme*", GOTO="end_mpath"
  4. ACTION=="remove", TEST=="/dev/shm/multipath/find_multipaths/$major:$minor", \
  5. RUN+="/usr/bin/rm -f /dev/shm/multipath/find_multipaths/$major:$minor"
  6. ACTION!="add|change", GOTO="end_mpath"
  7. IMPORT{cmdline}="nompath"
  8. ENV{nompath}=="?*", GOTO="end_mpath"
  9. IMPORT{cmdline}="multipath"
  10. ENV{multipath}=="off", GOTO="end_mpath"
  11. ENV{DEVTYPE}!="partition", GOTO="test_dev"
  12. IMPORT{parent}="DM_MULTIPATH_DEVICE_PATH"
  13. ENV{DM_MULTIPATH_DEVICE_PATH}=="1", ENV{ID_FS_TYPE}="none", \
  14. ENV{SYSTEMD_READY}="0"
  15. GOTO="end_mpath"
  16. LABEL="test_dev"
  17. ENV{MPATH_SBIN_PATH}="/sbin"
  18. TEST!="$env{MPATH_SBIN_PATH}/multipath", ENV{MPATH_SBIN_PATH}="/usr/sbin"
  19. # FIND_MULTIPATHS_WAIT_UNTIL is the timeout (in seconds after the
  20. # epoch).
  21. IMPORT{db}="FIND_MULTIPATHS_WAIT_UNTIL"
  22. ENV{.SAVED_FM_WAIT_UNTIL}="$env{FIND_MULTIPATHS_WAIT_UNTIL}"
  23. # multipath -u needs to know if this device has ever been exported
  24. IMPORT{db}="DM_MULTIPATH_DEVICE_PATH"
  25. # multipath -u sets DM_MULTIPATH_DEVICE_PATH and,
  26. # if "find_multipaths smart", also FIND_MULTIPATHS_WAIT_UNTIL.
  27. IMPORT{program}="$env{MPATH_SBIN_PATH}/multipath -u %k"
  28. # case 1: this is definitely multipath
  29. ENV{DM_MULTIPATH_DEVICE_PATH}=="1", \
  30. ENV{ID_FS_TYPE}="mpath_member", ENV{SYSTEMD_READY}="0", \
  31. GOTO="stop_wait"
  32. # case 2: this is definitely not multipath, or timeout has expired
  33. ENV{DM_MULTIPATH_DEVICE_PATH}!="2", \
  34. GOTO="stop_wait"
  35. # Code below here is only run in "smart" mode.
  36. # multipath -u has indicated this is "maybe" multipath.
  37. # Note that DM_MULTIPATH_DEVICE_PATH has the value 2 at this point.
  38. # This value will never propagate to other rules files, because
  39. # it will be reset to 1 in the "pretend_multipath" section below.
  40. # This shouldn't happen, just in case.
  41. ENV{FIND_MULTIPATHS_WAIT_UNTIL}!="?*", GOTO="end_mpath"
  42. # Be careful not to start the timer twice.
  43. ACTION!="add", GOTO="pretend_mpath"
  44. ENV{.SAVED_FM_WAIT_UNTIL}=="?*", GOTO="pretend_mpath"
  45. # At this point, we are seeing this path for the first time, and it's "maybe" multipath.
  46. # The actual start command for the timer.
  47. #
  48. # The purpose of this command is only to make sure we will receive another
  49. # uevent eventually. *Any* uevent may cause waiting to finish if it either ends
  50. # in case 1-3 above, or if it arrives after FIND_MULTIPATHS_WAIT_UNTIL.
  51. #
  52. # Note that this will try to activate multipathd if it isn't running yet.
  53. # If that fails, the unit starts and expires nonetheless. If multipathd
  54. # startup needs to wait for other services, this wait time will add up with
  55. # the --on-active timeout.
  56. #
  57. # We must trigger an "add" event because LVM2 will only act on those.
  58. RUN+="/usr/bin/systemd-run --unit=cancel-multipath-wait-$kernel --description 'cancel waiting for multipath siblings of $kernel' --no-block --timer-property DefaultDependencies=no --timer-property Conflicts=shutdown.target --timer-property Before=shutdown.target --timer-property AccuracySec=500ms --property DefaultDependencies=no --property Conflicts=shutdown.target --property Before=shutdown.target --property Wants=multipathd.service --property After=multipathd.service --on-active=$env{FIND_MULTIPATHS_WAIT_UNTIL} /usr/bin/udevadm trigger --action=add $sys$devpath"
  59. LABEL="pretend_mpath"
  60. ENV{DM_MULTIPATH_DEVICE_PATH}="1"
  61. ENV{SYSTEMD_READY}="0"
  62. GOTO="end_mpath"
  63. LABEL="stop_wait"
  64. # If timeout hasn't expired but we're not in "maybe" state any more, stop timer
  65. # Do this only once, and only if the timer has been started before
  66. IMPORT{db}="FIND_MULTIPATHS_WAIT_CANCELLED"
  67. ENV{FIND_MULTIPATHS_WAIT_CANCELLED}!="?*", \
  68. ENV{FIND_MULTIPATHS_WAIT_UNTIL}=="?*", \
  69. ENV{FIND_MULTIPATHS_WAIT_UNTIL}!="0", \
  70. ENV{FIND_MULTIPATHS_WAIT_CANCELLED}="1", \
  71. RUN+="/usr/bin/systemctl stop cancel-multipath-wait-$kernel.timer"
  72. LABEL="end_mpath"