mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
Add support for new IMPORT{db} udev rule.
This rule appeared in udev v152 and it helps us to support spurious events where we didn't have any flags set (events originated in udevadm trigger or the watch rule). These flags are important to direct the rule application. Now, with the help of this rule, we can regenerate old udev db content. To implement this correctly, we need to flag all proper DM udev events with DM_UDEV_PRIMARY_SOURCE_FLAG. That happens automatically for all ioctls generating events originated in libdevmapper.
This commit is contained in:
parent
8b7fc0da11
commit
942d6ef29f
@ -1,5 +1,7 @@
|
|||||||
Version 1.02.47 -
|
Version 1.02.47 -
|
||||||
=================================
|
=================================
|
||||||
|
Add support for new IMPORT{db} udev rule.
|
||||||
|
Add DM_UDEV_PRIMARY_SOURCE_FLAG udev flag to recognize proper DM events.
|
||||||
Also include udev libs in libdevmapper.pc when udev_sync is enabled.
|
Also include udev libs in libdevmapper.pc when udev_sync is enabled.
|
||||||
Cache bitset locations to speed up _calc_states.
|
Cache bitset locations to speed up _calc_states.
|
||||||
Add a regex optimisation pass for shared character prefixes.
|
Add a regex optimisation pass for shared character prefixes.
|
||||||
|
@ -1736,16 +1736,28 @@ static struct dm_ioctl *_do_dm_ioctl(struct dm_task *dmt, unsigned command,
|
|||||||
dmt->type == DM_DEVICE_REMOVE ||
|
dmt->type == DM_DEVICE_REMOVE ||
|
||||||
dmt->type == DM_DEVICE_RENAME;
|
dmt->type == DM_DEVICE_RENAME;
|
||||||
|
|
||||||
|
if (ioctl_with_uevent && dm_cookie_supported()) {
|
||||||
/*
|
/*
|
||||||
* Prevent udev vs. libdevmapper race when processing nodes and
|
* Always mark events coming from libdevmapper as
|
||||||
* symlinks. This can happen when the udev rules are installed and
|
* "primary sourced". This is needed to distinguish
|
||||||
* udev synchronisation code is enabled in libdevmapper but the
|
* any spurious events so we can act appropriately.
|
||||||
* software using libdevmapper does not make use of it (by not calling
|
* This needs to be applied even when udev_sync is
|
||||||
* dm_task_set_cookie before). We need to instruct the udev rules not
|
* not used because udev flags could be used alone.
|
||||||
* to be applied at all in this situation so we can gracefully fallback
|
|
||||||
* to libdevmapper's node and symlink creation code.
|
|
||||||
*/
|
*/
|
||||||
if (dm_udev_get_sync_support() && !dmt->cookie_set && ioctl_with_uevent) {
|
dmi->event_nr |= DM_UDEV_PRIMARY_SOURCE_FLAG <<
|
||||||
|
DM_UDEV_FLAGS_SHIFT;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Prevent udev vs. libdevmapper race when processing nodes
|
||||||
|
* and symlinks. This can happen when the udev rules are
|
||||||
|
* installed and udev synchronisation code is enabled in
|
||||||
|
* libdevmapper but the software using libdevmapper does not
|
||||||
|
* make use of it (by not calling dm_task_set_cookie before).
|
||||||
|
* We need to instruct the udev rules not to be applied at
|
||||||
|
* all in this situation so we can gracefully fallback to
|
||||||
|
* libdevmapper's node and symlink creation code.
|
||||||
|
*/
|
||||||
|
if (!dmt->cookie_set && dm_udev_get_sync_support()) {
|
||||||
log_debug("Cookie value is not set while trying to call "
|
log_debug("Cookie value is not set while trying to call "
|
||||||
"DM_DEVICE_RESUME, DM_DEVICE_REMOVE or DM_DEVICE_RENAME "
|
"DM_DEVICE_RESUME, DM_DEVICE_REMOVE or DM_DEVICE_RENAME "
|
||||||
"ioctl. Please, consider using libdevmapper's udev "
|
"ioctl. Please, consider using libdevmapper's udev "
|
||||||
@ -1754,14 +1766,15 @@ static struct dm_ioctl *_do_dm_ioctl(struct dm_task *dmt, unsigned command,
|
|||||||
log_debug("Switching off device-mapper and all subsystem related "
|
log_debug("Switching off device-mapper and all subsystem related "
|
||||||
"udev rules. Falling back to libdevmapper node creation.");
|
"udev rules. Falling back to libdevmapper node creation.");
|
||||||
/*
|
/*
|
||||||
* Disable general dm and subsystem rules but keep dm disk rules
|
* Disable general dm and subsystem rules but keep
|
||||||
* if not flagged out explicitly before. We need /dev/disk content
|
* dm disk rules if not flagged out explicitly before.
|
||||||
* for the software that expects it.
|
* We need /dev/disk content for the software that expects it.
|
||||||
*/
|
*/
|
||||||
dmi->event_nr |= (DM_UDEV_DISABLE_DM_RULES_FLAG |
|
dmi->event_nr |= (DM_UDEV_DISABLE_DM_RULES_FLAG |
|
||||||
DM_UDEV_DISABLE_SUBSYSTEM_RULES_FLAG) <<
|
DM_UDEV_DISABLE_SUBSYSTEM_RULES_FLAG) <<
|
||||||
DM_UDEV_FLAGS_SHIFT;
|
DM_UDEV_FLAGS_SHIFT;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
log_debug("dm %s %s %s%s%s %s%.0d%s%.0d%s"
|
log_debug("dm %s %s %s%s%s %s%.0d%s%.0d%s"
|
||||||
"%s%c%c%s%s %.0" PRIu64 " %s [%u]",
|
"%s%c%c%s%s %.0" PRIu64 " %s [%u]",
|
||||||
|
@ -1094,6 +1094,16 @@ void dm_report_field_set_value(struct dm_report_field *field, const void *value,
|
|||||||
* udev does something improperly.
|
* udev does something improperly.
|
||||||
*/
|
*/
|
||||||
#define DM_UDEV_DISABLE_LIBRARY_FALLBACK 0x0020
|
#define DM_UDEV_DISABLE_LIBRARY_FALLBACK 0x0020
|
||||||
|
/*
|
||||||
|
* DM_UDEV_PRIMARY_SOURCE_FLAG is automatically appended by
|
||||||
|
* libdevmapper for all ioctls generating udev uevents. Once used in
|
||||||
|
* udev rules, we know if this is a real "primary sourced" event or not.
|
||||||
|
* We need to distinguish real events originated in libdevmapper from
|
||||||
|
* any spurious events to gather all missing information (e.g. events
|
||||||
|
* generated as a result of "udevadm trigger" command or as a result
|
||||||
|
* of the "watch" udev rule).
|
||||||
|
*/
|
||||||
|
#define DM_UDEV_PRIMARY_SOURCE_FLAG 0x0040
|
||||||
|
|
||||||
int dm_cookie_supported(void);
|
int dm_cookie_supported(void);
|
||||||
|
|
||||||
|
@ -842,7 +842,8 @@ static int _udevflags(int args, char **argv, void *data __attribute((unused)))
|
|||||||
"DISABLE_OTHER_RULES",
|
"DISABLE_OTHER_RULES",
|
||||||
"LOW_PRIORITY",
|
"LOW_PRIORITY",
|
||||||
"DISABLE_LIBRARY_FALLBACK",
|
"DISABLE_LIBRARY_FALLBACK",
|
||||||
0, 0};
|
"PRIMARY_SOURCE",
|
||||||
|
0};
|
||||||
|
|
||||||
if (!(cookie = _get_cookie_value(argv[1])))
|
if (!(cookie = _get_cookie_value(argv[1])))
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -44,6 +44,28 @@ ENV{DM_COOKIE}=="?*", IMPORT{program}="$env{DM_SBIN_PATH}/dmsetup udevflags $env
|
|||||||
|
|
||||||
ACTION!="add|change", GOTO="dm_end"
|
ACTION!="add|change", GOTO="dm_end"
|
||||||
|
|
||||||
|
# There is no cookie set nor any flags encoded in events not originating
|
||||||
|
# in libdevmapper so we need to detect this and try to behave correctly.
|
||||||
|
# For such spurious events, regenerate all flags from current udev database content
|
||||||
|
# (this information would normally be inaccessible for spurious ADD and CHANGE events).
|
||||||
|
ENV{DM_UDEV_PRIMARY_SOURCE_FLAG}=="1", GOTO="dm_flags_done"
|
||||||
|
IMPORT{db}="DM_UDEV_DISABLE_DM_RULES_FLAG"
|
||||||
|
IMPORT{db}="DM_UDEV_DISABLE_SUBSYSTEM_RULES_FLAG"
|
||||||
|
IMPORT{db}="DM_UDEV_DISABLE_DISK_RULES_FLAG"
|
||||||
|
IMPORT{db}="DM_UDEV_DISABLE_OTHER_RULES_FLAG"
|
||||||
|
IMPORT{db}="DM_UDEV_LOW_PRIORITY_FLAG"
|
||||||
|
IMPORT{db}="DM_UDEV_DISABLE_LIBRARY_FALLBACK_FLAG"
|
||||||
|
IMPORT{db}="DM_UDEV_FLAG7"
|
||||||
|
IMPORT{db}="DM_SUBSYSTEM_UDEV_FLAG0"
|
||||||
|
IMPORT{db}="DM_SUBSYSTEM_UDEV_FLAG1"
|
||||||
|
IMPORT{db}="DM_SUBSYSTEM_UDEV_FLAG2"
|
||||||
|
IMPORT{db}="DM_SUBSYSTEM_UDEV_FLAG3"
|
||||||
|
IMPORT{db}="DM_SUBSYSTEM_UDEV_FLAG4"
|
||||||
|
IMPORT{db}="DM_SUBSYSTEM_UDEV_FLAG5"
|
||||||
|
IMPORT{db}="DM_SUBSYSTEM_UDEV_FLAG6"
|
||||||
|
IMPORT{db}="DM_SUBSYSTEM_UDEV_FLAG7"
|
||||||
|
LABEL="dm_flags_done"
|
||||||
|
|
||||||
# Normally, we operate on "change" events only. But when
|
# Normally, we operate on "change" events only. But when
|
||||||
# coldplugging, there's an "add" event present. We have to
|
# coldplugging, there's an "add" event present. We have to
|
||||||
# recognize this and do our actions in this particular
|
# recognize this and do our actions in this particular
|
||||||
|
Loading…
Reference in New Issue
Block a user