1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

udev: add support for "NOSCAN" flag

Recognize DM_SUBSYSTEM_UDEV_FLAG0 which for LVM is the "LVM_NOSCAN"
flag that causes the scanning to be skipped (mainly blkid) and
also directs all the foreign rules to be skipped as well.

Important thing here is that the "watch" udev rules is still set
as well as the /dev/disk/by-id content created (which does not
require any scanning to be done). Also, the flag is dropped on
any subsequent event and scanning done...
This commit is contained in:
Peter Rajnoha 2013-10-08 13:33:28 +02:00
parent ce7489ed22
commit 2f5ddfbade
4 changed files with 20 additions and 1 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.104 Version 2.02.104
=================================== ===================================
Recognize new flag to skip udev scanning in udev rules and act appropriately.
Add support for flagging an LV to skip udev scanning during activation. Add support for flagging an LV to skip udev scanning during activation.
Improve message when unable to change discards setting on active thin pool. Improve message when unable to change discards setting on active thin pool.
Run full scan before vgrename operation to avoid any cache name collision. Run full scan before vgrename operation to avoid any cache name collision.

View File

@ -20,6 +20,21 @@ ENV{DM_UUID}!="LVM-?*", GOTO="lvm_end"
# Use DM name and split it up into its VG/LV/layer constituents. # Use DM name and split it up into its VG/LV/layer constituents.
IMPORT{program}="(DM_EXEC)/dmsetup splitname --nameprefixes --noheadings --rows $env{DM_NAME}" IMPORT{program}="(DM_EXEC)/dmsetup splitname --nameprefixes --noheadings --rows $env{DM_NAME}"
# DM_SUBSYSTEM_UDEV_FLAG0 is the 'NOSCAN' flag for LVM subsystem.
# This flag is used to temporarily disable selected rules to prevent any
# processing or scanning done on the LVM volume before LVM has any chance
# to zero any stale metadata found within the LV data area. Such stale
# metadata could cause false claim of the LV device, keeping it open etc.
#
# If the NOSCAN flag is present, backup selected existing flags used to
# disable rules, then set them firmly so those selected rules are surely skipped.
# Restore these flags once the NOSCAN flag is dropped (which is normally any
# uevent that follows for this LV, even an artificially generated one).
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"
ENV{DM_SUBSYSTEM_UDEV_FLAG0}!="1", IMPORT{db}="DM_NOSCAN", IMPORT{db}="DM_DISABLE_OTHER_RULES_FLAG_OLD"
ENV{DM_SUBSYSTEM_UDEV_FLAG0}!="1", ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="$env{DM_DISABLE_OTHER_RULES_FLAG_OLD}", \
ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG_OLD}="", ENV{DM_NOSCAN}=""
ENV{DM_UDEV_DISABLE_SUBSYSTEM_RULES_FLAG}=="1", GOTO="lvm_end" ENV{DM_UDEV_DISABLE_SUBSYSTEM_RULES_FLAG}=="1", GOTO="lvm_end"
OPTIONS+="event_timeout=180" OPTIONS+="event_timeout=180"

View File

@ -18,6 +18,7 @@ SYMLINK+="disk/by-id/dm-name-$env{DM_NAME}"
ENV{DM_UUID}=="?*", SYMLINK+="disk/by-id/dm-uuid-$env{DM_UUID}" ENV{DM_UUID}=="?*", SYMLINK+="disk/by-id/dm-uuid-$env{DM_UUID}"
ENV{DM_SUSPENDED}=="1", GOTO="dm_end" ENV{DM_SUSPENDED}=="1", GOTO="dm_end"
ENV{DM_NOSCAN}=="1", GOTO="dm_watch"
(BLKID_RULE) (BLKID_RULE)
ENV{DM_UDEV_LOW_PRIORITY_FLAG}=="1", OPTIONS="link_priority=-100" ENV{DM_UDEV_LOW_PRIORITY_FLAG}=="1", OPTIONS="link_priority=-100"
@ -32,7 +33,7 @@ ENV{ID_FS_USAGE}=="filesystem|other", ENV{ID_FS_LABEL_ENC}=="?*", SYMLINK+="disk
# (like creating a filesystem, changing filesystem label etc.). # (like creating a filesystem, changing filesystem label etc.).
# #
# But let's use this until we have something better... # But let's use this until we have something better...
LABEL="dm_watch"
OPTIONS+="watch" OPTIONS+="watch"
LABEL="dm_end" LABEL="dm_end"

View File

@ -17,6 +17,8 @@
SUBSYSTEM!="block", GOTO="lvm_end" SUBSYSTEM!="block", GOTO="lvm_end"
(LVM_EXEC_RULE) (LVM_EXEC_RULE)
ENV{DM_NOSCAN}=="1", GOTO="lvm_end"
# If the PV label got lost, inform lvmetad immediately. # If the PV label got lost, inform lvmetad immediately.
# Detect the lost PV label by comparing previous ID_FS_TYPE value with current one. # Detect the lost PV label by comparing previous ID_FS_TYPE value with current one.
ENV{.ID_FS_TYPE_NEW}="$env{ID_FS_TYPE}" ENV{.ID_FS_TYPE_NEW}="$env{ID_FS_TYPE}"