mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
cache: Fix a segfault when passing --cachepolicy without --cachesettings.
This commit is contained in:
parent
5793ecd165
commit
7d615a3fe5
@ -1,5 +1,6 @@
|
||||
Version 2.02.117 -
|
||||
====================================
|
||||
Do not crash when --cachepolicy is given without --cachesettings.
|
||||
Add NEEDS_FOREIGN_VGS flag to vgimport so --foreign is always supplied.
|
||||
Add --foreign to the 6 display and reporting tools and vgcfgbackup.
|
||||
Install /etc/lvm/lvmlocal.conf template with local section for systemid.
|
||||
|
@ -418,7 +418,8 @@ int lv_cache_setpolicy(struct logical_volume *lv, struct dm_config_tree *policy)
|
||||
goto_out;
|
||||
}
|
||||
|
||||
if (!(seg->policy_settings = dm_config_clone_node_with_mem(lv->vg->vgmem, policy->root, 0)))
|
||||
if ((cn = dm_config_find_node(policy->root, "policy_settings")) &&
|
||||
!(seg->policy_settings = dm_config_clone_node_with_mem(lv->vg->vgmem, cn, 0)))
|
||||
goto_out;
|
||||
|
||||
if ((name = dm_config_find_str(policy->root, "policy", NULL)) &&
|
||||
@ -426,7 +427,7 @@ int lv_cache_setpolicy(struct logical_volume *lv, struct dm_config_tree *policy)
|
||||
goto_out;
|
||||
|
||||
restart: /* remove any 'default" nodes */
|
||||
cn = seg->policy_settings->child;
|
||||
cn = seg->policy_settings ? seg->policy_settings->child : NULL;
|
||||
while (cn) {
|
||||
if (cn->v->type == DM_CFG_STRING && !strcmp(cn->v->v.str, "default")) {
|
||||
dm_config_remove_node(seg->policy_settings, cn);
|
||||
|
@ -21,7 +21,12 @@ lvcreate -n noncache -l 1 $vg
|
||||
not lvchange --cachepolicy mq $vg/noncache
|
||||
not lvchange --cachesettings foo=bar $vg/noncache
|
||||
|
||||
lvchange --cachepolicy cleaner $vg/corigin
|
||||
dmsetup status | grep $vg-corigin | grep 'cleaner'
|
||||
|
||||
lvchange --cachepolicy mq --cachesettings migration_threshold=333 $vg/corigin
|
||||
dmsetup status | grep $vg-corigin | not grep 'cleaner'
|
||||
dmsetup status | grep $vg-corigin | grep 'mq'
|
||||
dmsetup status | grep $vg-corigin | grep 'migration_threshold 333'
|
||||
lvchange --refresh $vg/corigin
|
||||
dmsetup status | grep $vg-corigin | grep 'migration_threshold 333'
|
||||
|
@ -1232,17 +1232,20 @@ struct dm_config_tree *get_cachepolicy_params(struct cmd_context *cmd)
|
||||
if (!(result = dm_config_flatten(current)))
|
||||
goto_out;
|
||||
|
||||
if (!(cn = dm_config_create_node(result, "policy_settings")))
|
||||
goto_out;
|
||||
if (result->root) {
|
||||
if (!(cn = dm_config_create_node(result, "policy_settings")))
|
||||
goto_out;
|
||||
|
||||
cn->child = result->root;
|
||||
result->root = cn;
|
||||
cn->child = result->root;
|
||||
result->root = cn;
|
||||
}
|
||||
|
||||
if (arg_count(cmd, cachepolicy_ARG)) {
|
||||
if (!(cn = dm_config_create_node(result, "policy")))
|
||||
goto_out;
|
||||
|
||||
result->root->sib = cn;
|
||||
cn->sib = result->root;
|
||||
result->root = cn;
|
||||
if (!(cn->v = dm_config_create_value(result)))
|
||||
goto_out;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user