1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-10-27 18:55:19 +03:00

cache: Implement 'default' as a policy settings value to clear the record.

This commit is contained in:
Petr Rockai 2014-11-20 12:05:40 +01:00
parent 4b9b8e1282
commit c75ae0846e
2 changed files with 51 additions and 3 deletions

View File

@ -399,18 +399,52 @@ int lv_cache_setpolicy(struct logical_volume *lv, struct dm_config_tree *policy)
{
struct lv_segment *seg = first_seg(lv);
const char *name;
struct dm_config_node *cn;
struct dm_config_tree *old = NULL, *new = NULL, *tmp = NULL;
int r = 0;
if (lv_is_cache(lv))
seg = first_seg(seg->pool_lv);
if (seg->policy_settings) {
if (!(old = dm_config_create()))
goto_out;
if (!(new = dm_config_create()))
goto_out;
new->root = policy->root;
old->root = seg->policy_settings;
new->cascade = old;
if (!(tmp = policy = dm_config_flatten(new)))
goto_out;
}
if (!(seg->policy_settings = dm_config_clone_node_with_mem(lv->vg->vgmem, policy->root, 0)))
return_0;
goto_out;
if ((name = dm_config_find_str(policy->root, "policy", NULL)) &&
!(seg->policy_name = dm_pool_strdup(lv->vg->vgmem, name)))
return_0;
goto_out;
return 1;
restart: /* remove any 'default" nodes */
cn = seg->policy_settings->child;
while (cn) {
if (cn->v->type == DM_CFG_STRING && !strcmp(cn->v->v.str, "default")) {
dm_config_remove_node(seg->policy_settings, cn);
goto restart;
}
cn = cn->sib;
}
r = 1;
out:
if (old)
dm_config_destroy(old);
if (new)
dm_config_destroy(new);
if (tmp)
dm_config_destroy(tmp);
return r;
}
/*

View File

@ -33,4 +33,18 @@ lvchange --cachesettings 'migration_threshold = 233 sequential_threshold = 13' $
dmsetup status | grep $vg-corigin | grep 'migration_threshold 233'
dmsetup status | grep $vg-corigin | grep 'sequential_threshold 13'
lvchange --cachesettings 'migration_threshold = 17' $vg/corigin
dmsetup status | grep $vg-corigin | grep 'migration_threshold 17'
dmsetup status | grep $vg-corigin | grep 'sequential_threshold 13'
lvchange --cachesettings 'migration_threshold = default' $vg/corigin
dmsetup status | grep $vg-corigin | grep 'migration_threshold 2048'
dmsetup status | grep $vg-corigin | grep 'sequential_threshold 13'
lvchange --cachesettings 'migration_threshold = 233 sequential_threshold = 13 random_threshold = 1' $vg/corigin
lvchange --cachesettings 'random_threshold = default migration_threshold = default' $vg/corigin
dmsetup status | grep $vg-corigin | grep 'migration_threshold 2048'
dmsetup status | grep $vg-corigin | grep 'sequential_threshold 13'
dmsetup status | grep $vg-corigin | grep 'random_threshold 4'
vgremove -f $vg