mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
toolcontext: check dm version lazily for udev_fallback setting
Setting the cmd->default_settings.udev_fallback also requires DM driver version check. However, this caused useless mapper/control access with ioctl if not needed actually. For example if we're not using activation code, we don't need to know the udev_fallback as there's no node and symlink processing. For example, this premature mapper/control access caused problems when using lvm2app even when no activation happens - there are situations in which we don't need to use mapper/control, but still need some of the lvm2app functionality. This is also the case for lvm2-activation systemd generator which just needs to look at the lvm2 configuration, but it shouldn't touch mapper/control.
This commit is contained in:
parent
3d0cb0611e
commit
4407133113
@ -1,5 +1,6 @@
|
||||
Version 2.02.99 -
|
||||
===================================
|
||||
Fix premature DM version checking which caused useless mapper/control access.
|
||||
Add "active" LV reporting field to show activation state.
|
||||
Add "monitor" segment reporting field to show dmevent monitoring status.
|
||||
Document lvextend --use-policies option in man.
|
||||
|
@ -1309,6 +1309,57 @@ int dev_manager_mknodes(const struct logical_volume *lv)
|
||||
return r;
|
||||
}
|
||||
|
||||
#ifdef UDEV_SYNC_SUPPORT
|
||||
/*
|
||||
* Until the DM_UEVENT_GENERATED_FLAG was introduced in kernel patch
|
||||
* 856a6f1dbd8940e72755af145ebcd806408ecedd
|
||||
* some operations could not be performed by udev, requiring our fallback code.
|
||||
*/
|
||||
static int _dm_driver_has_stable_udev_support(void)
|
||||
{
|
||||
char vsn[80];
|
||||
unsigned maj, min, patchlevel;
|
||||
|
||||
return driver_version(vsn, sizeof(vsn)) &&
|
||||
(sscanf(vsn, "%u.%u.%u", &maj, &min, &patchlevel) == 3) &&
|
||||
(maj == 4 ? min >= 18 : maj > 4);
|
||||
}
|
||||
|
||||
static int _check_udev_fallback(struct cmd_context *cmd)
|
||||
{
|
||||
struct config_info *settings = &cmd->current_settings;
|
||||
|
||||
if (settings->udev_fallback != -1)
|
||||
goto out;
|
||||
|
||||
/*
|
||||
* Use udev fallback automatically in case udev
|
||||
* is disabled via DM_DISABLE_UDEV environment
|
||||
* variable or udev rules are switched off.
|
||||
*/
|
||||
settings->udev_fallback = !settings->udev_rules ? 1 :
|
||||
find_config_tree_bool(cmd, activation_verify_udev_operations_CFG);
|
||||
|
||||
/* Do not rely fully on udev if the udev support is known to be incomplete. */
|
||||
if (!settings->udev_fallback && !_dm_driver_has_stable_udev_support()) {
|
||||
log_very_verbose("Kernel driver has incomplete udev support so "
|
||||
"LVM will check and perform some operations itself.");
|
||||
settings->udev_fallback = 1;
|
||||
}
|
||||
out:
|
||||
return settings->udev_fallback;
|
||||
}
|
||||
|
||||
#else /* UDEV_SYNC_SUPPORT */
|
||||
|
||||
static int _check_udev_fallback(struct cmd_context *cmd)
|
||||
{
|
||||
/* We must use old node/symlink creation code if not compiled with udev support at all! */
|
||||
return cmd->current_settings.udev_fallback = 1;
|
||||
}
|
||||
|
||||
#endif /* UDEV_SYNC_SUPPORT */
|
||||
|
||||
static uint16_t _get_udev_flags(struct dev_manager *dm, struct logical_volume *lv,
|
||||
const char *layer)
|
||||
{
|
||||
@ -1318,7 +1369,7 @@ static uint16_t _get_udev_flags(struct dev_manager *dm, struct logical_volume *l
|
||||
* Instruct also libdevmapper to disable udev
|
||||
* fallback in accordance to LVM2 settings.
|
||||
*/
|
||||
if (!dm->cmd->current_settings.udev_fallback)
|
||||
if (!_check_udev_fallback(dm->cmd))
|
||||
udev_flags |= DM_UDEV_DISABLE_LIBRARY_FALLBACK;
|
||||
|
||||
/*
|
||||
@ -2399,7 +2450,7 @@ static int _create_lv_symlinks(struct dev_manager *dm, struct dm_tree_node *root
|
||||
int r = 1;
|
||||
|
||||
/* Nothing to do if udev fallback is disabled. */
|
||||
if (!dm->cmd->current_settings.udev_fallback) {
|
||||
if (!_check_udev_fallback(dm->cmd)) {
|
||||
fs_set_create();
|
||||
return 1;
|
||||
}
|
||||
@ -2447,7 +2498,7 @@ static int _remove_lv_symlinks(struct dev_manager *dm, struct dm_tree_node *root
|
||||
int r = 1;
|
||||
|
||||
/* Nothing to do if udev fallback is disabled. */
|
||||
if (!dm->cmd->current_settings.udev_fallback)
|
||||
if (!_check_udev_fallback(dm->cmd))
|
||||
return 1;
|
||||
|
||||
while ((child = dm_tree_next_child(&handle, root, 0))) {
|
||||
|
@ -262,23 +262,6 @@ static int _check_disable_udev(const char *msg) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef UDEV_SYNC_SUPPORT
|
||||
/*
|
||||
* Until the DM_UEVENT_GENERATED_FLAG was introduced in kernel patch
|
||||
* 856a6f1dbd8940e72755af145ebcd806408ecedd
|
||||
* some operations could not be performed by udev, requiring our fallback code.
|
||||
*/
|
||||
static int _dm_driver_has_stable_udev_support(void)
|
||||
{
|
||||
char vsn[80];
|
||||
unsigned maj, min, patchlevel;
|
||||
|
||||
return driver_version(vsn, sizeof(vsn)) &&
|
||||
(sscanf(vsn, "%u.%u.%u", &maj, &min, &patchlevel) == 3) &&
|
||||
(maj == 4 ? min >= 18 : maj > 4);
|
||||
}
|
||||
#endif
|
||||
|
||||
static int _process_config(struct cmd_context *cmd)
|
||||
{
|
||||
mode_t old_umask;
|
||||
@ -372,31 +355,18 @@ static int _process_config(struct cmd_context *cmd)
|
||||
cmd->default_settings.udev_sync = udev_disabled ? 0 :
|
||||
find_config_tree_bool(cmd, activation_udev_sync_CFG);
|
||||
|
||||
/*
|
||||
* Set udev_fallback lazily on first use since it requires
|
||||
* checking DM driver version which is an extra ioctl!
|
||||
* This also prevents unnecessary use of mapper/control.
|
||||
* If udev is disabled globally, set fallback mode immediately.
|
||||
*/
|
||||
cmd->default_settings.udev_fallback = udev_disabled ? 1 : -1;
|
||||
|
||||
init_retry_deactivation(find_config_tree_bool(cmd, activation_retry_deactivation_CFG));
|
||||
|
||||
init_activation_checks(find_config_tree_bool(cmd, activation_checks_CFG));
|
||||
|
||||
#ifdef UDEV_SYNC_SUPPORT
|
||||
/*
|
||||
* Use udev fallback automatically in case udev
|
||||
* is disabled via DM_DISABLE_UDEV environment
|
||||
* variable or udev rules are switched off.
|
||||
*/
|
||||
cmd->default_settings.udev_fallback = !cmd->default_settings.udev_rules || udev_disabled ? 1 :
|
||||
find_config_tree_bool(cmd, activation_verify_udev_operations_CFG);
|
||||
|
||||
/* Do not rely fully on udev if the udev support is known to be incomplete. */
|
||||
if (!cmd->default_settings.udev_fallback && !_dm_driver_has_stable_udev_support()) {
|
||||
log_very_verbose("Kernel driver has incomplete udev support so "
|
||||
"LVM will check and perform some operations itself.");
|
||||
cmd->default_settings.udev_fallback = 1;
|
||||
}
|
||||
|
||||
#else
|
||||
/* We must use old node/symlink creation code if not compiled with udev support at all! */
|
||||
cmd->default_settings.udev_fallback = 1;
|
||||
#endif
|
||||
|
||||
cmd->use_linear_target = find_config_tree_bool(cmd, activation_use_linear_target_CFG);
|
||||
|
||||
cmd->stripe_filler = find_config_tree_str(cmd, activation_missing_stripe_filler_CFG);
|
||||
|
Loading…
Reference in New Issue
Block a user