fix udev rules for failed multipath devices
[multipath-tools/.git] / multipath / 11-dm-mpath.rules
1 ACTION!="add|change", GOTO="mpath_end"
2 ENV{DM_UDEV_RULES_VSN}!="?*", GOTO="mpath_end"
3 ENV{DM_UUID}!="mpath-?*", GOTO="mpath_end"
4
5 IMPORT{db}="DM_DISABLE_OTHER_RULES_FLAG_OLD"
6 IMPORT{db}="MPATH_DEVICE_READY"
7
8 # If this uevent didn't come from dm, don't try to update the
9 # device state
10 ENV{DM_COOKIE}!="?*", ENV{DM_ACTION}!="PATH_*", IMPORT{db}="DM_UDEV_DISABLE_OTHER_RULES_FLAG", IMPORT{db}="DM_NOSCAN", GOTO="scan_import"
11
12 ENV{.MPATH_DEVICE_READY_OLD}="$env{MPATH_DEVICE_READY}"
13
14 # multipath sets DM_SUBSYSTEM_UDEV_FLAG2 when it reloads a
15 # table with no active devices. If this happens, mark the
16 # device not ready
17 ENV{DM_SUBSYSTEM_UDEV_FLAG2}=="1", ENV{MPATH_DEVICE_READY}="0",\
18         GOTO="mpath_action"
19
20 # If the last path has failed mark the device not ready
21 ENV{DM_ACTION}=="PATH_FAILED", ENV{DM_NR_VALID_PATHS}=="0",\
22         ENV{MPATH_DEVICE_READY}="0", GOTO="mpath_action"
23
24 # Don't mark a device ready on a PATH_FAILED event. even if
25 # DM_NR_VALID_PATHS is greater than 0. Just keep the existing
26 # value
27 ENV{DM_ACTION}=="PATH_FAILED", GOTO="mpath_action"
28
29 # This event is either a PATH_REINSTATED or a table reload where
30 # there are active paths. Mark the device ready
31 ENV{MPATH_DEVICE_READY}=""
32
33 LABEL="mpath_action"
34 # DM_SUBSYSTEM_UDEV_FLAG0 is the "RELOAD" flag for multipath subsystem.
35 # Drop the DM_ACTIVATION flag here as mpath reloads tables if any of its
36 # paths are lost/recovered. For any stack above the mpath device, this is not
37 # something that should be reacted upon since it would be useless extra work.
38 # It's exactly mpath's job to provide *seamless* device access to any of the
39 # paths that are available underneath.
40 ENV{DM_SUBSYSTEM_UDEV_FLAG0}=="1", ENV{DM_ACTIVATION}="0"
41
42 # Do not initiate scanning if no path is available,
43 # otherwise there would be a hang or IO error on access.
44 # We'd like to avoid this, especially within udev processing.
45 ENV{MPATH_DEVICE_READY}=="0", ENV{DM_NOSCAN}="1"
46
47 # Also skip all foreign rules if no path is available.
48 # Remember the original value of DM_DISABLE_OTHER_RULES_FLAG
49 # and restore it back once we have at least one path available.
50 ENV{MPATH_DEVICE_READY}=="0", ENV{.MPATH_DEVICE_READY_OLD}!="0",\
51         ENV{DM_DISABLE_OTHER_RULES_FLAG_OLD}=="",\
52         ENV{DM_DISABLE_OTHER_RULES_FLAG_OLD}="$env{DM_UDEV_DISABLE_OTHER_RULES_FLAG}",\
53         ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="1"
54 ENV{MPATH_DEVICE_READY}!="0", ENV{.MPATH_DEVICE_READY_OLD}=="0",\
55         ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="$env{DM_DISABLE_OTHER_RULES_FLAG_OLD}",\
56         ENV{DM_DISABLE_OTHER_RULES_FLAG_OLD}="",\
57         ENV{DM_ACTIVATION}="1"
58
59 LABEL="scan_import"
60 ENV{DM_NOSCAN}!="1", GOTO="mpath_end"
61 ENV{ID_FS_TYPE}!="?*", IMPORT{db}="ID_FS_TYPE"
62 ENV{ID_FS_USAGE}!="?*", IMPORT{db}="ID_FS_USAGE"
63 ENV{ID_FS_UUID}!="?*", IMPORT{db}="ID_FS_UUID"
64 ENV{ID_FS_ENC}!="?*", IMPORT{db}="ID_FS_UUID_ENC"
65 ENV{ID_FS_VERSION}!="?*", IMPORT{db}="ID_FS_VERSION"
66
67 LABEL="mpath_end"