LVM2 lib/activate/dev_manager.c libdm/libdevma ...
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: prajnoha at sourceware.org 2009-10-26 14:29:35
Modified files:
lib/activate : dev_manager.c
libdm : libdevmapper.h libdm-common.c libdm-common.h
libdm-deptree.c
libdm/ioctl : libdm-iface.c
tools : dmsetup.c
udev : 10-dm.rules.in 11-dm-lvm.rules 13-dm-disk.rules
Makefile.in
Log message:
Several changes to udev support code:
- we have these levels when the udev rules are processed:
10-dm.rules --> [11-dm-<subsystem>.rules] --> [12-dm-permissions.rules] --> 13-dm-disk.rules --> [...all the other foreign rules...] --> 95-dm-notify.rules
- each level can be disabled now by DM_UDEV_DISABLE_{DM, SUBSYSTEM, DISK, OTHER}_RULES_FLAG
- add DM_UDEV_DISABLE_DM_RULES_FLAG to disable 10-dm.rules
- add DM_UDEV_DISABLE_OTHER_RULES_FLAG to disable all the other (non-dm) rules. We cutoff these rules by using the 'last_rule', so this one should really be used with great care and in well-founded situations. We use this for lvm's hidden and layer devices now.
- add a parameter for add_dev_node, rm_dev_node and rename_dev_node so it's possible to switch on/off udev checks
- use DM_UDEV_DISABLE_DM_RULES_FLAG and DM_UDEV_DISABLE_SUBSYSTEM_RULES_FLAG if there's no cookie set and we have resume, remove and rename ioctl. This could happen when someone uses the libdevmapper that is compiled with udev_sync but the software does not make use of it. This way we can switch off the rules and fallback to libdevmapper node creation so there's no udev/libdevmapper race.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/dev_manager.c.diff?cvsroot=lvm2&r1=1.161&r2=1.162
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdevmapper.h.diff?cvsroot=lvm2&r1=1.99&r2=1.100
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-common.c.diff?cvsroot=lvm2&r1=1.87&r2=1.88
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-common.h.diff?cvsroot=lvm2&r1=1.5&r2=1.6
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.60&r2=1.61
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/ioctl/libdm-iface.c.diff?cvsroot=lvm2&r1=1.63&r2=1.64
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/dmsetup.c.diff?cvsroot=lvm2&r1=1.125&r2=1.126
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/udev/10-dm.rules.in.diff?cvsroot=lvm2&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/udev/11-dm-lvm.rules.diff?cvsroot=lvm2&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/udev/13-dm-disk.rules.diff?cvsroot=lvm2&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/udev/Makefile.in.diff?cvsroot=lvm2&r1=1.3&r2=1.4
lib/activate/dev_manager.c +2 -1
@@ -1026,7 +1026,8 @@if (layer || !lv_is_visible (lv)) udev_flags |=DM_UDEV_DISABLE_SUBSYSTEM_RULES_FLAG | -DM_UDEV_DISABLE_DISK_RULES_FLAG ; +DM_UDEV_DISABLE_DISK_RULES_FLAG | +DM_UDEV_DISABLE_OTHER_RULES_FLAG ;if (lv_is_cow (lv)) udev_flags |=DM_UDEV_LOW_PRIORITY_FLAG ;
libdm/libdevmapper.h +19 -3
@@ -1035,17 +1035,33 @@#define DM_COOKIE_MAGIC 0x0D4D#define DM_UDEV_FLAGS_MASK 0xFFFF0000#define DM_UDEV_FLAGS_SHIFT 16 + +/* +* DM_UDEV_DISABLE_DM_RULES_FLAG is set in case we need to disable +* basic device-mapper udev rules that create symlinks in /dev/<DM_DIR> +* directory. However, we can't reliably prevent creating default +* nodes by udev (commonly /dev/dm-X, where X is a number). +*/ +#define DM_UDEV_DISABLE_DM_RULES_FLAG 0x0001/* * DM_UDEV_DISABLE_SUBSYTEM_RULES_FLAG is set in case we need to disable * subsystem udev rules, but still we need the general DM udev rules to * be applied (to create the nodes and symlinks under /dev and /dev/disk). */ -#define DM_UDEV_DISABLE_SUBSYSTEM_RULES_FLAG 0x0001 +#define DM_UDEV_DISABLE_SUBSYSTEM_RULES_FLAG 0x0002/* * DM_UDEV_DISABLE_DISK_RULES_FLAG is set in case we need to disable * general DM rules that set symlinks in /dev/disk directory. */ -#define DM_UDEV_DISABLE_DISK_RULES_FLAG 0x0002 +#define DM_UDEV_DISABLE_DISK_RULES_FLAG 0x0004 +/* +* DM_UDEV_DISABLE_OTHER_RULES_FLAG is set in case we need to disable +* all the other rules that are not general device-mapper nor subsystem +* related (the rules belong to other software or packages). Use this +* flag with care since it will cutoff the rule processing after the +* last device-mapper/subsytem rule is applied. +*/ +#define DM_UDEV_DISABLE_OTHER_RULES_FLAG 0x0008/* * DM_UDEV_LOW_PRIORITY_FLAG is set in case we need to instruct the * udev rules to give low priority to the device that is currently
@@ -1054,7 +1070,7 @@* Common situation is a name based on FS UUID while using origin and * snapshot devices. */ -#define DM_UDEV_LOW_PRIORITY_FLAG 0x0004 +#define DM_UDEV_LOW_PRIORITY_FLAG 0x0010int dm_cookie_supported (void );
libdm/libdm-common.c +31 -24
170 lines not on this page · raw message
libdm/libdm-common.h +4 -3
@@ -23,9 +23,10 @@ const char *type, const char *params);int add_dev_node (const char *dev_name,uint32_t minor,uint32_t major, -uid_t uid,gid_t gid,mode_t mode); -int rm_dev_node (const char *dev_name); -int rename_dev_node (const char *old_name,const char *new_name); +uid_t uid,gid_t gid,mode_t mode,int check_udev); +int rm_dev_node (const char *dev_name,int check_udev); +int rename_dev_node (const char *old_name,const char *new_name, +int check_udev);int get_dev_node_read_ahead (const char *dev_name,uint32_t *read_ahead);int set_dev_node_read_ahead (const char *dev_name,uint32_t read_ahead,uint32_t read_ahead_flags);
libdm/libdm-deptree.c +1 -1
@@ -873,7 +873,7 @@ r =dm_task_run (dmt);/* FIXME Until kernel returns actual name so dm-ioctl.c can handle it */ -rm_dev_node (name); +rm_dev_node (name, dmt->cookie_set);/* FIXME Remove node from tree or mark invalid? */
libdm/ioctl/libdm-iface.c +50 -13
126 lines not on this page · raw message
tools/dmsetup.c +4 -2
@@ -779,10 +779,12 @@uint32_t cookie;uint16_t flags;int i; -static const char *dm_flag_names[] = {"DISABLE_SUBSYSTEM_RULES" , +static const char *dm_flag_names[] = {"DISABLE_DM_RULES" , +"DISABLE_SUBSYSTEM_RULES" ,"DISABLE_DISK_RULES" , +"DISABLE_OTHER_RULES" ,"LOW_PRIORITY" , -0 ,0 ,0 ,0 ,0 }; +0 ,0 ,0 };if (!(cookie =_get_cookie_value (argv[1 ])))return 0 ;
udev/10-dm.rules.in +16 -7
@@ -21,8 +21,16 @@ TEST!="$env{DM_SBIN_PATH}/dmsetup", GOTO="dm_end" # Decode udev control flags and set environment variables appropriately. +# These flags are encoded in DM_COOKIE variable that was introduced in +# kernel version 2.6.31. Therefore, we can use this feature with +# kernels >= 2.6.31 only. ENV{DM_COOKIE}=="?*", IMPORT{program}="$env{DM_SBIN_PATH}/dmsetup udevflags $env{DM_COOKIE}" +# Normally, we would test for DM_UDEV_DISABLE_DM_RULES_FLAG here and skip +# the rules if set. However, we need to set DM_* environment variables +# for now to properly filter out inappropriate events. This dependency +# might be removed in the future. + ACTION!="add|change", GOTO="dm_end" # Normally, we operate on "change" events only. But when
@@ -58,18 +66,19 @@ # possible future changes. ENV{DM_UDEV_RULES_VSN}="1" -ENV{DM_NAME}=="?*", SYMLINK+="(DM_DIR)/$env{DM_NAME}" +ENV{DM_UDEV_DISABLE_DM_RULES_FLAG}!="1", ENV{DM_NAME}=="?*", SYMLINK+="(DM_DIR)/$env{DM_NAME}" # We have to ignore further rule application for inappropriate events # and devices. But still send the notification if cookie exists. -ENV{DM_UUID}=="mpath-?*", ENV{DM_ACTION}=="PATH_FAILED", GOTO="dm_last_rule" -ENV{DM_UUID}=="CRYPT-TEMP-?*", GOTO="dm_last_rule" -ENV{DM_UUID}!="?*", ENV{DM_NAME}=="temporary-cryptsetup-?*", GOTO="dm_last_rule" +ENV{DM_UUID}=="mpath-?*", ENV{DM_ACTION}=="PATH_FAILED", GOTO="dm_disable" +ENV{DM_UUID}=="CRYPT-TEMP-?*", GOTO="dm_disable" +ENV{DM_UUID}!="?*", ENV{DM_NAME}=="temporary-cryptsetup-?*", GOTO="dm_disable" GOTO="dm_end" -LABEL="dm_last_rule" -ENV{DM_COOKIE}=="?*", RUN+="$env{DM_SBIN_PATH}/dmsetup udevcomplete $env{DM_COOKIE}" -OPTIONS+="last_rule" +LABEL="dm_disable" +ENV{DM_UDEV_DISABLE_SUBSYSTEM_RULES_FLAG}="1" +ENV{DM_UDEV_DISABLE_DISK_RULES_FLAG}="1" +ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="1" LABEL="dm_end"
udev/11-dm-lvm.rules +1 -1
@@ -17,7 +17,7 @@ # Use DM name and split it up into its VG/LV/layer constituents. IMPORT{program}="$env{DM_SBIN_PATH}/dmsetup splitname --nameprefixes --noheadings --rows $env{DM_NAME}" -# Do not create symlinks for hidden subdevices. +# Do not create symlinks for inappropriate subdevices. ENV{DM_LV_NAME}=="?*_mimage_[0-9]*|pvmove?*|?*_vorigin", GOTO="lvm_end" # Create symlinks for top-level devices only.
udev/13-dm-disk.rules +12 -3
@@ -7,17 +7,26 @@ # "add" event is processed on coldplug only! ACTION!="add|change", GOTO="dm_end" -ENV{DM_UDEV_RULES_VSN}!="?*", GOTO="dm_end" -ENV{DM_UDEV_DISABLE_DISK_RULES_FLAG}=="1", GOTO="dm_end" +ENV{DM_UDEV_RULES_VSN}!="?*", GOTO="dm_other" +ENV{DM_UDEV_DISABLE_DISK_RULES_FLAG}=="1", GOTO="dm_other" SYMLINK+="disk/by-id/dm-name-$env{DM_NAME}" 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_other" IMPORT{program}="$env{DM_SBIN_PATH}/blkid -o udev -p $tempnode" ENV{DM_UDEV_LOW_PRIORITY_FLAG}=="1", OPTIONS="link_priority=-100" ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{ID_FS_UUID_ENC}=="?*", SYMLINK+="disk/by-uuid/$env{ID_FS_UUID_ENC}" ENV{ID_FS_USAGE}=="filesystem|other", ENV{ID_FS_LABEL_ENC}=="?*", SYMLINK+="disk/by-label/$env{ID_FS_LABEL_ENC}" +# Cutoff all subsequent rules if instructed by a flag. +# This flag should be used in well-founded situations only to prevent +# any problems that could arise when processing this event further by +# foreign rules (various temporary and hidden devices mostly). +LABEL="dm_other" +ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}!="1", GOTO="dm_end" +ENV{DM_COOKIE}=="?*", RUN+="$env{DM_SBIN_PATH}/dmsetup udevcomplete $env{DM_COOKIE}" +OPTIONS+="last_rule" + LABEL="dm_end"
udev/Makefile.in +2 -2
@@ -16,8 +16,8 @@ top_builddir = @top_builddir@ VPATH = @srcdir@ -DM_RULES=10-dm.rules 12-dm-disk.rules 95-dm-notify.rules -LVM_RULES=11-lvm.rules +DM_RULES=10-dm.rules 13-dm-disk.rules 95-dm-notify.rules +LVM_RULES=11-dm-lvm.rules DM_DIR=$(shell grep "\#define DM_DIR" $(top_srcdir)/libdm/misc/dm-ioctl.h | awk '{print $$3}') CLEAN_TARGETS=10-dm.rules