56-dm-mpath.rules 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. ACTION!="add|change", GOTO="mpath_end"
  2. ENV{DM_UDEV_RULES}!="?*", GOTO="mpath_end"
  3. ENV{DM_UUID}!="mpath-?*", GOTO="mpath_end"
  4. IMPORT{db}="DM_DISABLE_OTHER_RULES_FLAG_OLD"
  5. IMPORT{db}="MPATH_DEVICE_READY"
  6. # If this uevent didn't come from dm, don't try to update the
  7. # device state
  8. ENV{DM_COOKIE}!="?*", ENV{DM_ACTION}!="PATH_*", IMPORT{db}="DM_UDEV_DISABLE_OTHER_RULES_FLAG", IMPORT{db}="DM_NOSCAN", GOTO="scan_import"
  9. ENV{.MPATH_DEVICE_READY_OLD}="$env{MPATH_DEVICE_READY}"
  10. # multipath sets DM_SUBSYSTEM_UDEV_FLAG2 when it reloads a
  11. # table with no active devices. If this happens, mark the
  12. # device not ready
  13. ENV{DM_SUBSYSTEM_UDEV_FLAG2}=="1", ENV{MPATH_DEVICE_READY}="0",\
  14. GOTO="mpath_action"
  15. # If the last path has failed mark the device not ready
  16. # Note that DM_NR_VALID_PATHS is only set for PATH_FAILED|PATH_REINSTATED
  17. # events.
  18. # This may not be reliable, as events aren't necessarily received in order.
  19. ENV{DM_NR_VALID_PATHS}=="0", ENV{MPATH_DEVICE_READY}="0", GOTO="mpath_action"
  20. ENV{MPATH_SBIN_PATH}="/sbin"
  21. TEST!="$env{MPATH_SBIN_PATH}/multipath", ENV{MPATH_SBIN_PATH}="/usr/sbin"
  22. # Don't run multipath -U during "coldplug" after switching root,
  23. # because paths are just being added to the udev db.
  24. ACTION=="add", ENV{.MPATH_DEVICE_READY_OLD}=="1", GOTO="paths_ok"
  25. # Check the map state directly with multipath -U.
  26. # This doesn't attempt I/O on the device.
  27. PROGRAM=="$env{MPATH_SBIN_PATH}/multipath -U %k", GOTO="paths_ok"
  28. ENV{MPATH_DEVICE_READY}="0", GOTO="mpath_action"
  29. LABEL="paths_ok"
  30. # Don't mark a device ready on a PATH_FAILED event. even if
  31. # DM_NR_VALID_PATHS is greater than 0. Just keep the existing
  32. # value
  33. ENV{DM_ACTION}=="PATH_FAILED", GOTO="mpath_action"
  34. # This event is either a PATH_REINSTATED or a table reload where
  35. # there are active paths. Mark the device ready
  36. ENV{MPATH_DEVICE_READY}="1"
  37. LABEL="mpath_action"
  38. # DM_SUBSYSTEM_UDEV_FLAG0 is the "RELOAD" flag for multipath subsystem.
  39. # Drop the DM_ACTIVATION flag here as mpath reloads tables if any of its
  40. # paths are lost/recovered. For any stack above the mpath device, this is not
  41. # something that should be reacted upon since it would be useless extra work.
  42. # It's exactly mpath's job to provide *seamless* device access to any of the
  43. # paths that are available underneath.
  44. ENV{DM_SUBSYSTEM_UDEV_FLAG0}=="1", \
  45. ENV{DM_ACTIVATION}="0", ENV{MPATH_UNCHANGED}="1"
  46. # For path failed or reinstated events, unset DM_ACTIVATION.
  47. # This is similar to the DM_SUBSYSTEM_UDEV_FLAG0 case above.
  48. ENV{DM_ACTION}=="PATH_FAILED|PATH_REINSTATED", \
  49. ENV{DM_ACTIVATION}="0", ENV{MPATH_UNCHANGED}="1"
  50. # Do not initiate scanning if no path is available,
  51. # otherwise there would be a hang or IO error on access.
  52. # We'd like to avoid this, especially within udev processing.
  53. ENV{MPATH_DEVICE_READY}=="0", ENV{DM_NOSCAN}="1"
  54. # Also skip all foreign rules if no path is available.
  55. # Remember the original value of DM_DISABLE_OTHER_RULES_FLAG
  56. # and restore it back once we have at least one path available.
  57. ENV{MPATH_DEVICE_READY}=="0", ENV{.MPATH_DEVICE_READY_OLD}=="1",\
  58. ENV{DM_DISABLE_OTHER_RULES_FLAG_OLD}=="",\
  59. ENV{DM_DISABLE_OTHER_RULES_FLAG_OLD}="$env{DM_UDEV_DISABLE_OTHER_RULES_FLAG}"
  60. ENV{MPATH_DEVICE_READY}=="0", ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="1"
  61. ENV{MPATH_DEVICE_READY}!="0", ENV{.MPATH_DEVICE_READY_OLD}=="0",\
  62. ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="$env{DM_DISABLE_OTHER_RULES_FLAG_OLD}",\
  63. ENV{DM_DISABLE_OTHER_RULES_FLAG_OLD}="",\
  64. ENV{DM_ACTIVATION}="1"
  65. # The code to check multipath state ends here. We need to set
  66. # properties and symlinks regardless whether the map is usable or
  67. # not. If symlinks get lost, systemd may auto-unmount file systems.
  68. LABEL="scan_import"
  69. ENV{DM_NOSCAN}!="1", GOTO="import_end"
  70. IMPORT{db}="ID_FS_TYPE"
  71. IMPORT{db}="ID_FS_USAGE"
  72. IMPORT{db}="ID_FS_UUID"
  73. IMPORT{db}="ID_FS_UUID_ENC"
  74. IMPORT{db}="ID_FS_LABEL"
  75. IMPORT{db}="ID_FS_LABEL_ENC"
  76. IMPORT{db}="ID_FS_VERSION"
  77. LABEL="import_end"
  78. # Multipath maps should take precedence over their members.
  79. ENV{DM_UDEV_LOW_PRIORITY_FLAG}!="1", OPTIONS+="link_priority=50"
  80. # Set some additional symlinks that typically exist for mpath
  81. # path members, too, and should be overridden.
  82. # kpartx_id is very robust, it works for suspended maps and maps
  83. # with 0 dependencies. It sets DM_TYPE, DM_PART, DM_WWN
  84. TEST=="/lib/udev/kpartx_id", \
  85. IMPORT{program}=="kpartx_id %M %m $env{DM_UUID}"
  86. ENV{DM_TYPE}=="?*", ENV{DM_SERIAL}=="?*", \
  87. SYMLINK+="disk/by-id/$env{DM_TYPE}-$env{DM_SERIAL}"
  88. ENV{DM_WWN}=="?*", SYMLINK+="disk/by-id/wwn-$env{DM_WWN}"
  89. LABEL="mpath_end"