Replace "info.open_count" test with "dm_device_has_holders" in lvremove code path
PATCH 5/7 Replace "info.open_count" test with "dm_device_has_holders" in lvremove code path
lib/activate/activate.c | 2 +- lib/commands/toolcontext.c | 8 +++++--- lib/metadata/lv_manip.c | 2 +- libdm/libdm-deptree.c | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-)
lib/activate/activate.c +1 -1
@@ -1437,7 +1437,7 @@ int lv_deactivate(struct cmd_context *cmd, const char *lvid_s) }if (lv_is_visible (lv)) { -if (info.open_count) { +if (dm_device_has_holders (info.major, info.minor)) {log_error ("LV %s/%s in use: not deactivating" , lv->vg->name, lv->name); goto out;
lib/commands/toolcontext.c +5 -3
@@ -243,9 +243,6 @@ static int _process_config(struct cmd_context *cmd)log_error ("Device directory given in config file too long" );return 0 ; } -#ifdef DEVMAPPER_SUPPORT -dm_set_dev_dir (cmd->dev_dir); -#endif /* proc dir */ if (dm_snprintf(cmd->proc_dir, sizeof(cmd->proc_dir), "%s",
@@ -265,6 +262,11 @@ static int _process_config(struct cmd_context *cmd)_get_sysfs_dir (cmd);set_sysfs_dir_path (cmd->sysfs_dir); +#ifdef DEVMAPPER_SUPPORT +dm_set_dev_dir (cmd->dev_dir); +dm_set_sysfs_dir (cmd->sysfs_dir); +#endif +/* activation? */ cmd->default_settings.activation = find_config_tree_int(cmd, "global/activation",
lib/metadata/lv_manip.c +1 -1
@@ -3099,7 +3099,7 @@ int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,/* FIXME Ensure not referred to by another existing LVs */ if (lv_info (cmd, lv,0 , &info,1 ,0 )) { -if (info.open_count) { +if (info.exists &&dm_device_has_holders (info.major, info.minor)) {log_error ("Can't remove open logical volume \"%s\"" , lv->name);return 0 ;
libdm/libdm-deptree.c +1 -1
@@ -1185,7 +1185,7 @@ static int _dm_tree_deactivate_children(struct dm_tree_node *dnode,continue ;/* Also checking open_count in parent nodes of presuspend_node */ -if (info.open_count || +if (dm_device_has_holders (info.major, info.minor) || (child->presuspend_node && !_node_has_closed_parents (child->presuspend_node, uuid_prefix, uuid_prefix_len))) {