Samuel Mendoza-Jonas | d939857 | 2017-06-05 13:22:05 +1000 | [diff] [blame] | 1 | # Copyright (C) 2009 Red Hat, Inc. All rights reserved. |
| 2 | # |
| 3 | # This file is part of LVM2. |
| 4 | |
| 5 | # Udev rules for LVM. |
| 6 | # |
| 7 | # These rules create symlinks for LVM logical volumes in |
| 8 | # /dev/VG directory (VG is an actual VG name). Some udev |
| 9 | # environment variables are set (they can be used in later |
| 10 | # rules as well): |
| 11 | # DM_LV_NAME - logical volume name |
| 12 | # DM_VG_NAME - volume group name |
| 13 | # DM_LV_LAYER - logical volume layer (blank if not set) |
| 14 | |
| 15 | # "add" event is processed on coldplug only! |
| 16 | ACTION!="add|change", GOTO="lvm_end" |
| 17 | ENV{DM_UDEV_RULES_VSN}!="?*", GOTO="lvm_end" |
| 18 | ENV{DM_UUID}!="LVM-?*", GOTO="lvm_end" |
| 19 | |
| 20 | # Use DM name and split it up into its VG/LV/layer constituents. |
| 21 | IMPORT{program}="/usr/sbin/dmsetup splitname --nameprefixes --noheadings --rows $env{DM_NAME}" |
| 22 | |
| 23 | # DM_SUBSYSTEM_UDEV_FLAG0 is the 'NOSCAN' flag for LVM subsystem. |
| 24 | # This flag is used to temporarily disable selected rules to prevent any |
| 25 | # processing or scanning done on the LVM volume before LVM has any chance |
| 26 | # to zero any stale metadata found within the LV data area. Such stale |
| 27 | # metadata could cause false claim of the LV device, keeping it open etc. |
| 28 | # |
| 29 | # If the NOSCAN flag is present, backup selected existing flags used to |
| 30 | # disable rules, then set them firmly so those selected rules are surely skipped. |
| 31 | # Restore these flags once the NOSCAN flag is dropped (which is normally any |
| 32 | # uevent that follows for this LV, even an artificially generated one). |
| 33 | ENV{DM_SUBSYSTEM_UDEV_FLAG0}=="1", ENV{DM_NOSCAN}="1", ENV{DM_DISABLE_OTHER_RULES_FLAG_OLD}="$env{DM_UDEV_DISABLE_OTHER_RULES_FLAG}", ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="1" |
| 34 | ENV{DM_SUBSYSTEM_UDEV_FLAG0}!="1", IMPORT{db}="DM_NOSCAN", IMPORT{db}="DM_DISABLE_OTHER_RULES_FLAG_OLD" |
| 35 | ENV{DM_SUBSYSTEM_UDEV_FLAG0}!="1", ENV{DM_NOSCAN}=="1", ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="$env{DM_DISABLE_OTHER_RULES_FLAG_OLD}", \ |
| 36 | ENV{DM_DISABLE_OTHER_RULES_FLAG_OLD}="", ENV{DM_NOSCAN}="" |
| 37 | |
| 38 | ENV{DM_UDEV_DISABLE_SUBSYSTEM_RULES_FLAG}=="1", GOTO="lvm_end" |
| 39 | |
| 40 | OPTIONS+="event_timeout=180" |
| 41 | |
| 42 | # Do not create symlinks for inappropriate subdevices. |
| 43 | ENV{DM_LV_NAME}=="pvmove?*|?*_vorigin", GOTO="lvm_disable" |
| 44 | ENV{DM_LV_LAYER}=="?*", GOTO="lvm_disable" |
| 45 | |
| 46 | # Create symlinks for top-level devices only. |
| 47 | ENV{DM_VG_NAME}=="?*", ENV{DM_LV_NAME}=="?*", SYMLINK+="$env{DM_VG_NAME}/$env{DM_LV_NAME}", GOTO="lvm_end" |
| 48 | |
| 49 | LABEL="lvm_disable" |
| 50 | ENV{DM_UDEV_DISABLE_DISK_RULES_FLAG}="1" |
| 51 | ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="1" |
| 52 | OPTIONS:="nowatch" |
| 53 | |
| 54 | LABEL="lvm_end" |