multipath-tools: check for C compiler option -Werror=discarded-qualifiers
[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 # Don't run multipath -U during "coldplug" after switching root,
30 # because paths are just being added to the udev db.
31 ACTION=="add", ENV{.MPATH_DEVICE_READY_OLD}=="1", GOTO="paths_ok"
32
33 # Check the map state directly with multipath -U.
34 # This doesn't attempt I/O on the device.
35 PROGRAM=="$env{MPATH_SBIN_PATH}/multipath -U %k", GOTO="paths_ok"
36 ENV{MPATH_DEVICE_READY}="0", GOTO="mpath_action"
37 LABEL="paths_ok"
38
39 # Don't mark a device ready on a PATH_FAILED event. even if
40 # DM_NR_VALID_PATHS is greater than 0. Just keep the existing
41 # value
42 ENV{DM_ACTION}=="PATH_FAILED", GOTO="mpath_action"
43
44 # This event is either a PATH_REINSTATED or a table reload where
45 # there are active paths. Mark the device ready
46 ENV{MPATH_DEVICE_READY}="1"
47
48 LABEL="mpath_action"
49 # DM_SUBSYSTEM_UDEV_FLAG0 is the "RELOAD" flag for multipath subsystem.
50 # Drop the DM_ACTIVATION flag here as mpath reloads tables if any of its
51 # paths are lost/recovered. For any stack above the mpath device, this is not
52 # something that should be reacted upon since it would be useless extra work.
53 # It's exactly mpath's job to provide *seamless* device access to any of the
54 # paths that are available underneath.
55 ENV{DM_SUBSYSTEM_UDEV_FLAG0}=="1", \
56         ENV{DM_ACTIVATION}="0", ENV{MPATH_UNCHANGED}="1"
57
58 # For path failed or reinstated events, unset DM_ACTIVATION.
59 # This is similar to the DM_SUBSYSTEM_UDEV_FLAG0 case above.
60 ENV{DM_ACTION}=="PATH_FAILED|PATH_REINSTATED", \
61         ENV{DM_ACTIVATION}="0", ENV{MPATH_UNCHANGED}="1"
62
63 # Do not initiate scanning if no path is available,
64 # otherwise there would be a hang or IO error on access.
65 # We'd like to avoid this, especially within udev processing.
66 ENV{MPATH_DEVICE_READY}=="0", ENV{DM_NOSCAN}="1"
67
68 # Also skip all foreign rules if no path is available.
69 # Remember the original value of DM_DISABLE_OTHER_RULES_FLAG
70 # and restore it back once we have at least one path available.
71 ENV{MPATH_DEVICE_READY}=="0", ENV{.MPATH_DEVICE_READY_OLD}=="1",\
72         ENV{DM_DISABLE_OTHER_RULES_FLAG_OLD}=="",\
73         ENV{DM_DISABLE_OTHER_RULES_FLAG_OLD}="$env{DM_UDEV_DISABLE_OTHER_RULES_FLAG}"
74 ENV{MPATH_DEVICE_READY}=="0", ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="1"
75 ENV{MPATH_DEVICE_READY}!="0", ENV{.MPATH_DEVICE_READY_OLD}=="0",\
76         ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="$env{DM_DISABLE_OTHER_RULES_FLAG_OLD}",\
77         ENV{DM_DISABLE_OTHER_RULES_FLAG_OLD}="",\
78         ENV{DM_ACTIVATION}="1"
79
80 # The code to check multipath state ends here. We need to set
81 # properties and symlinks regardless whether the map is usable or
82 # not. If symlinks get lost, systemd may auto-unmount file systems.
83
84 LABEL="scan_import"
85 ENV{DM_NOSCAN}!="1", GOTO="import_end"
86 IMPORT{db}="ID_FS_TYPE"
87 IMPORT{db}="ID_FS_USAGE"
88 IMPORT{db}="ID_FS_UUID"
89 IMPORT{db}="ID_FS_UUID_ENC"
90 IMPORT{db}="ID_FS_LABEL"
91 IMPORT{db}="ID_FS_LABEL_ENC"
92 IMPORT{db}="ID_FS_VERSION"
93
94 LABEL="import_end"
95
96 # Multipath maps should take precedence over their members.
97 ENV{DM_UDEV_LOW_PRIORITY_FLAG}!="1", OPTIONS+="link_priority=50"
98
99 # Set some additional symlinks that typically exist for mpath
100 # path members, too, and should be overridden.
101
102 # kpartx_id is very robust, it works for suspended maps and maps
103 # with 0 dependencies. It sets DM_TYPE, DM_PART, DM_WWN
104 TEST=="/usr/lib/udev/kpartx_id", \
105         IMPORT{program}=="kpartx_id %M %m $env{DM_UUID}"
106
107 ENV{DM_TYPE}=="?*", ENV{DM_SERIAL}=="?*", \
108         SYMLINK+="disk/by-id/$env{DM_TYPE}-$env{DM_SERIAL}"
109 ENV{DM_WWN}=="?*", SYMLINK+="disk/by-id/wwn-$env{DM_WWN}"
110
111 LABEL="mpath_end"