0be22ae439fde42f8e77dcf80590309cd8acc811
[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 # Note that DM_NR_VALID_PATHS is only set for PATH_FAILED|PATH_REINSTATED
22 # events.
23 # This may not be reliable, as events aren't necessarily received in order.
24 ENV{DM_NR_VALID_PATHS}=="0", ENV{MPATH_DEVICE_READY}="0", GOTO="mpath_action"
25
26 ENV{MPATH_SBIN_PATH}="/sbin"
27 TEST!="$env{MPATH_SBIN_PATH}/multipath", ENV{MPATH_SBIN_PATH}="/usr/sbin"
28
29 # Check the map state directly with multipath -U.
30 # This doesn't attempt I/O on the device.
31 PROGRAM=="$env{MPATH_SBIN_PATH}/multipath -U %k", GOTO="paths_ok"
32 ENV{MPATH_DEVICE_READY}="0", GOTO="mpath_action"
33 LABEL="paths_ok"
34
35 # Don't mark a device ready on a PATH_FAILED event. even if
36 # DM_NR_VALID_PATHS is greater than 0. Just keep the existing
37 # value
38 ENV{DM_ACTION}=="PATH_FAILED", GOTO="mpath_action"
39
40 # This event is either a PATH_REINSTATED or a table reload where
41 # there are active paths. Mark the device ready
42 ENV{MPATH_DEVICE_READY}="1"
43
44 LABEL="mpath_action"
45 # DM_SUBSYSTEM_UDEV_FLAG0 is the "RELOAD" flag for multipath subsystem.
46 # Drop the DM_ACTIVATION flag here as mpath reloads tables if any of its
47 # paths are lost/recovered. For any stack above the mpath device, this is not
48 # something that should be reacted upon since it would be useless extra work.
49 # It's exactly mpath's job to provide *seamless* device access to any of the
50 # paths that are available underneath.
51 ENV{DM_SUBSYSTEM_UDEV_FLAG0}=="1", ENV{DM_ACTIVATION}="0"
52
53 # Do not initiate scanning if no path is available,
54 # otherwise there would be a hang or IO error on access.
55 # We'd like to avoid this, especially within udev processing.
56 ENV{MPATH_DEVICE_READY}=="0", ENV{DM_NOSCAN}="1"
57
58 # Also skip all foreign rules if no path is available.
59 # Remember the original value of DM_DISABLE_OTHER_RULES_FLAG
60 # and restore it back once we have at least one path available.
61 ENV{MPATH_DEVICE_READY}=="0", ENV{.MPATH_DEVICE_READY_OLD}=="1",\
62         ENV{DM_DISABLE_OTHER_RULES_FLAG_OLD}=="",\
63         ENV{DM_DISABLE_OTHER_RULES_FLAG_OLD}="$env{DM_UDEV_DISABLE_OTHER_RULES_FLAG}"
64 ENV{MPATH_DEVICE_READY}=="0", ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="1"
65 ENV{MPATH_DEVICE_READY}!="0", ENV{.MPATH_DEVICE_READY_OLD}=="0",\
66         ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="$env{DM_DISABLE_OTHER_RULES_FLAG_OLD}",\
67         ENV{DM_DISABLE_OTHER_RULES_FLAG_OLD}="",\
68         ENV{DM_ACTIVATION}="1"
69
70 LABEL="scan_import"
71 ENV{DM_NOSCAN}!="1", GOTO="mpath_end"
72 IMPORT{db}="ID_FS_TYPE"
73 IMPORT{db}="ID_FS_USAGE"
74 IMPORT{db}="ID_FS_UUID"
75 IMPORT{db}="ID_FS_UUID_ENC"
76 IMPORT{db}="ID_FS_LABEL"
77 IMPORT{db}="ID_FS_LABEL_ENC"
78 IMPORT{db}="ID_FS_VERSION"
79
80 LABEL="mpath_end"