master - cleanup: drop unused vars
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=089bdc0be479dc...
Commit: 089bdc0be479dce8a886a50606b4bbb108614fb2
Parent: 71271cf9053bd4fb6d6dbf1c4240fcb105165084
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Nov 20 17:49:32 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Nov 20 17:49:32 2014 +0100
cleanup: drop unused vars
---
libdm/libdm-config.c | 2 +-
tools/toollib.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/libdm/libdm-config.c b/libdm/libdm-config.c
index 93e2887..91aa970 100644
--- a/libdm/libdm-config.c
+++ b/libdm/libdm-config.c
@@ -522,7 +522,7 @@ static struct dm_config_node *_section(struct parser *p, struct dm_config_node *
{
/* IDENTIFIER SECTION_B_CHAR VALUE* SECTION_E_CHAR */
- struct dm_config_node *root, *n, *l = NULL;
+ struct dm_config_node *root, *n;
struct dm_config_value *value;
char *str;
diff --git a/tools/toollib.c b/tools/toollib.c
index 2015ca1..00512a3 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -1126,7 +1126,7 @@ struct dm_config_tree *get_cachepolicy_params(struct cmd_context *cmd)
const char *str;
struct arg_value_group_list *group;
struct dm_config_tree *result = NULL, *prev = NULL, *current = NULL;
- struct dm_config_node *cn, *last = NULL;
+ struct dm_config_node *cn;
int ok = 0;
dm_list_iterate_items(group, &cmd->arg_value_groups) {
9 years, 5 months
master - test: Also test repeated --cachesettings in lvchange-cache.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=71271cf9053bd4...
Commit: 71271cf9053bd4fb6d6dbf1c4240fcb105165084
Parent: c75ae0846e4c1a74fbd44d85837e2b6dc50e9783
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Thu Nov 20 12:35:51 2014 +0100
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Thu Nov 20 16:51:07 2014 +0100
test: Also test repeated --cachesettings in lvchange-cache.
---
test/shell/lvchange-cache.sh | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/test/shell/lvchange-cache.sh b/test/shell/lvchange-cache.sh
index 4845bba..87a217a 100644
--- a/test/shell/lvchange-cache.sh
+++ b/test/shell/lvchange-cache.sh
@@ -47,4 +47,14 @@ 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'
+lvchange --cachesettings migration_threshold=233 --cachesettings sequential_threshold=13 --cachesettings random_threshold=1 $vg/corigin
+dmsetup status | grep $vg-corigin | grep 'migration_threshold 233 '
+dmsetup status | grep $vg-corigin | grep 'sequential_threshold 13 '
+dmsetup status | grep $vg-corigin | grep 'random_threshold 1 '
+
+lvchange --cachesettings random_threshold=default --cachesettings 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
9 years, 5 months
master - cache: Implement 'default' as a policy settings value to clear the record.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c75ae0846e4c1a...
Commit: c75ae0846e4c1a74fbd44d85837e2b6dc50e9783
Parent: 4b9b8e12825d5611d3b8d73aa8e381a4caffff5a
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Thu Nov 20 12:05:40 2014 +0100
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Thu Nov 20 16:51:07 2014 +0100
cache: Implement 'default' as a policy settings value to clear the record.
---
lib/metadata/cache_manip.c | 40 +++++++++++++++++++++++++++++++++++++---
test/shell/lvchange-cache.sh | 14 ++++++++++++++
2 files changed, 51 insertions(+), 3 deletions(-)
diff --git a/lib/metadata/cache_manip.c b/lib/metadata/cache_manip.c
index f7b1b99..6a13ec1 100644
--- a/lib/metadata/cache_manip.c
+++ b/lib/metadata/cache_manip.c
@@ -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;
+
+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;
+ }
- return 1;
+ r = 1;
+
+out:
+ if (old)
+ dm_config_destroy(old);
+ if (new)
+ dm_config_destroy(new);
+ if (tmp)
+ dm_config_destroy(tmp);
+ return r;
}
/*
diff --git a/test/shell/lvchange-cache.sh b/test/shell/lvchange-cache.sh
index 997b770..4845bba 100644
--- a/test/shell/lvchange-cache.sh
+++ b/test/shell/lvchange-cache.sh
@@ -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
9 years, 5 months
master - toollib: Split --cachesettings from --cachepolicy.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=4b9b8e12825d56...
Commit: 4b9b8e12825d5611d3b8d73aa8e381a4caffff5a
Parent: 310beb73a8a2d3a6ed7a28a3346306be82bbc533
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Thu Nov 20 11:30:19 2014 +0100
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Thu Nov 20 16:51:07 2014 +0100
toollib: Split --cachesettings from --cachepolicy.
---
test/shell/lvchange-cache.sh | 7 +++--
tools/args.h | 3 +-
tools/commands.h | 4 +-
tools/lvchange.c | 3 +-
tools/toollib.c | 53 +++++++++++++++++++++--------------------
5 files changed, 37 insertions(+), 33 deletions(-)
diff --git a/test/shell/lvchange-cache.sh b/test/shell/lvchange-cache.sh
index e790cbb..997b770 100644
--- a/test/shell/lvchange-cache.sh
+++ b/test/shell/lvchange-cache.sh
@@ -18,9 +18,10 @@ lvcreate --type cache-pool -an -v -L 2 -n cpool $vg
lvcreate -H -L 4 -n corigin --cachepool $vg/cpool
lvcreate -n noncache -l 1 $vg
-not lvchange --cachepolicy policy=mq $vg/noncache
+not lvchange --cachepolicy mq $vg/noncache
+not lvchange --cachesettings foo=bar $vg/noncache
-lvchange --cachepolicy policy=mq --cachepolicy migration_threshold=333 $vg/corigin
+lvchange --cachepolicy mq --cachesettings migration_threshold=333 $vg/corigin
dmsetup status | grep $vg-corigin | grep 'migration_threshold 333'
lvchange --refresh $vg/corigin
dmsetup status | grep $vg-corigin | grep 'migration_threshold 333'
@@ -28,7 +29,7 @@ lvchange -an $vg
lvchange -ay $vg
dmsetup status | grep $vg-corigin | grep 'migration_threshold 333'
-lvchange --cachepolicy 'migration_threshold = 233 sequential_threshold = 13' $vg/corigin
+lvchange --cachesettings 'migration_threshold = 233 sequential_threshold = 13' $vg/corigin
dmsetup status | grep $vg-corigin | grep 'migration_threshold 233'
dmsetup status | grep $vg-corigin | grep 'sequential_threshold 13'
diff --git a/tools/args.h b/tools/args.h
index 63fee14..1abe0eb 100644
--- a/tools/args.h
+++ b/tools/args.h
@@ -104,7 +104,8 @@ arg(trustcache_ARG, '\0', "trustcache", NULL, 0)
arg(type_ARG, '\0', "type", segtype_arg, 0)
arg(unbuffered_ARG, '\0', "unbuffered", NULL, 0)
arg(uncache_ARG, '\0', "uncache", NULL, 0)
-arg(cachepolicy_ARG, '\0', "cachepolicy", string_arg, ARG_GROUPABLE)
+arg(cachepolicy_ARG, '\0', "cachepolicy", string_arg, 0)
+arg(cachesettings_ARG, '\0', "cachesettings", string_arg, ARG_GROUPABLE)
arg(units_ARG, '\0', "units", string_arg, 0)
arg(unquoted_ARG, '\0', "unquoted", NULL, 0)
arg(use_policies_ARG, '\0', "use-policies", NULL, 0)
diff --git a/tools/commands.h b/tools/commands.h
index e3bac1f..4765923 100644
--- a/tools/commands.h
+++ b/tools/commands.h
@@ -106,7 +106,7 @@ xx(lvchange,
"\t[--addtag Tag]\n"
"\t[--alloc AllocationPolicy]\n"
"\t[-C|--contiguous y|n]\n"
- "\t[--cachepolicy policy=type] [--cachepolicy parameter=value]\n"
+ "\t[--cachepolicy policyname] [--cachesettings parameter=value]\n"
"\t[--commandprofile ProfileName]\n"
"\t[-d|--debug]\n"
"\t[--deltag Tag]\n"
@@ -144,7 +144,7 @@ xx(lvchange,
activationmode_ARG, addtag_ARG, alloc_ARG, autobackup_ARG, activate_ARG,
available_ARG,
- cachepolicy_ARG, contiguous_ARG, deltag_ARG, discards_ARG, detachprofile_ARG, force_ARG,
+ cachepolicy_ARG, cachesettings_ARG, contiguous_ARG, deltag_ARG, discards_ARG, detachprofile_ARG, force_ARG,
ignorelockingfailure_ARG, ignoremonitoring_ARG, ignoreactivationskip_ARG,
ignoreskippedcluster_ARG, major_ARG, metadataprofile_ARG, minor_ARG,
monitor_ARG, minrecoveryrate_ARG, maxrecoveryrate_ARG, noudevsync_ARG,
diff --git a/tools/lvchange.c b/tools/lvchange.c
index 144295b..d9003b4 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -1014,7 +1014,7 @@ static int _lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
docmds++;
}
- if (arg_count(cmd, cachepolicy_ARG)) {
+ if (arg_count(cmd, cachepolicy_ARG) || arg_count(cmd, cachesettings_ARG)) {
if (!archive(lv->vg))
return_ECMD_FAILED;
doit += lvchange_cachepolicy(cmd, lv);
@@ -1081,6 +1081,7 @@ int lvchange(struct cmd_context *cmd, int argc, char **argv)
arg_count(cmd, resync_ARG) ||
arg_count(cmd, syncaction_ARG) ||
arg_count(cmd, cachepolicy_ARG) ||
+ arg_count(cmd, cachesettings_ARG) ||
arg_count(cmd, writebehind_ARG) ||
arg_count(cmd, writemostly_ARG) ||
arg_count(cmd, zero_ARG);
diff --git a/tools/toollib.c b/tools/toollib.c
index 935f06e..2015ca1 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -1127,56 +1127,57 @@ struct dm_config_tree *get_cachepolicy_params(struct cmd_context *cmd)
struct arg_value_group_list *group;
struct dm_config_tree *result = NULL, *prev = NULL, *current = NULL;
struct dm_config_node *cn, *last = NULL;
+ int ok = 0;
dm_list_iterate_items(group, &cmd->arg_value_groups) {
- if (!grouped_arg_is_set(group->arg_values, cachepolicy_ARG))
+ if (!grouped_arg_is_set(group->arg_values, cachesettings_ARG))
continue;
current = dm_config_create();
if (!current)
- goto_bad;
+ goto_out;
if (prev)
current->cascade = prev;
prev = current;
if (!(str = grouped_arg_str_value(group->arg_values,
- cachepolicy_ARG,
+ cachesettings_ARG,
NULL)))
- goto_bad;
+ goto_out;
if (!dm_config_parse(current, str, str + strlen(str)))
- goto_bad;
+ goto_out;
}
result = dm_config_flatten(current);
- if (!(cn = dm_config_create_node(result, "policy_settings"))) {
- dm_config_destroy(result);
- result = NULL;
- }
+
+ if (!(cn = dm_config_create_node(result, "policy_settings")))
+ goto_out;
+
cn->child = result->root;
result->root = cn;
- cn = cn->child;
- while (cn) {
- if (!strcmp(cn->key, "policy")) {
- if (last)
- last->sib = cn->sib;
- else
- result->root->child = cn->sib;
- cn->parent = NULL;
- cn->sib = NULL;
- result->root->sib = cn;
- }
- last = cn;
- cn = cn->sib;
+ if (arg_count(cmd, cachepolicy_ARG)) {
+ if (!(cn = dm_config_create_node(result, "policy")))
+ goto_out;
+
+ result->root->sib = cn;
+ if (!(cn->v = dm_config_create_value(result)))
+ goto_out;
+
+ cn->v->v.str = arg_str_value(cmd, cachepolicy_ARG, NULL);
}
- if (!_validate_cachepool_params(current)) {
+ if (!_validate_cachepool_params(result))
+ goto_out;
+
+ ok = 1;
+
+out:
+ if (!ok) {
dm_config_destroy(result);
result = NULL;
}
-
-bad:
while (prev) {
current = prev->cascade;
dm_config_destroy(prev);
9 years, 5 months
master - test: Add a test for lvchange --cachepolicy.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=310beb73a8a2d3...
Commit: 310beb73a8a2d3a6ed7a28a3346306be82bbc533
Parent: c164f59631ca08f56c5f1e2e6cf677f3a85145fb
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Wed Nov 19 18:49:15 2014 +0100
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Thu Nov 20 16:51:07 2014 +0100
test: Add a test for lvchange --cachepolicy.
---
test/shell/lvchange-cache.sh | 35 +++++++++++++++++++++++++++++++++++
1 files changed, 35 insertions(+), 0 deletions(-)
diff --git a/test/shell/lvchange-cache.sh b/test/shell/lvchange-cache.sh
new file mode 100644
index 0000000..e790cbb
--- /dev/null
+++ b/test/shell/lvchange-cache.sh
@@ -0,0 +1,35 @@
+#!/bin/sh
+# Copyright (C) 2014 Red Hat, Inc. All rights reserved.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions
+# of the GNU General Public License v.2.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+. lib/inittest
+
+aux have_cache 1 3 0 || skip
+aux prepare_vg 3
+
+lvcreate --type cache-pool -an -v -L 2 -n cpool $vg
+lvcreate -H -L 4 -n corigin --cachepool $vg/cpool
+lvcreate -n noncache -l 1 $vg
+
+not lvchange --cachepolicy policy=mq $vg/noncache
+
+lvchange --cachepolicy policy=mq --cachepolicy migration_threshold=333 $vg/corigin
+dmsetup status | grep $vg-corigin | grep 'migration_threshold 333'
+lvchange --refresh $vg/corigin
+dmsetup status | grep $vg-corigin | grep 'migration_threshold 333'
+lvchange -an $vg
+lvchange -ay $vg
+dmsetup status | grep $vg-corigin | grep 'migration_threshold 333'
+
+lvchange --cachepolicy 'migration_threshold = 233 sequential_threshold = 13' $vg/corigin
+dmsetup status | grep $vg-corigin | grep 'migration_threshold 233'
+dmsetup status | grep $vg-corigin | grep 'sequential_threshold 13'
+
+vgremove -f $vg
9 years, 5 months
master - lvchange: Accept --cachepolicy.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c164f59631ca08...
Commit: c164f59631ca08f56c5f1e2e6cf677f3a85145fb
Parent: f67e1fadb0fcdc5887663f9b0c9c46fc5835d418
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Wed Nov 19 18:39:58 2014 +0100
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Thu Nov 20 16:51:07 2014 +0100
lvchange: Accept --cachepolicy.
---
tools/commands.h | 3 ++-
tools/lvchange.c | 32 ++++++++++++++++++++++++++++++++
2 files changed, 34 insertions(+), 1 deletions(-)
diff --git a/tools/commands.h b/tools/commands.h
index d4473a4..e3bac1f 100644
--- a/tools/commands.h
+++ b/tools/commands.h
@@ -106,6 +106,7 @@ xx(lvchange,
"\t[--addtag Tag]\n"
"\t[--alloc AllocationPolicy]\n"
"\t[-C|--contiguous y|n]\n"
+ "\t[--cachepolicy policy=type] [--cachepolicy parameter=value]\n"
"\t[--commandprofile ProfileName]\n"
"\t[-d|--debug]\n"
"\t[--deltag Tag]\n"
@@ -143,7 +144,7 @@ xx(lvchange,
activationmode_ARG, addtag_ARG, alloc_ARG, autobackup_ARG, activate_ARG,
available_ARG,
- contiguous_ARG, deltag_ARG, discards_ARG, detachprofile_ARG, force_ARG,
+ cachepolicy_ARG, contiguous_ARG, deltag_ARG, discards_ARG, detachprofile_ARG, force_ARG,
ignorelockingfailure_ARG, ignoremonitoring_ARG, ignoreactivationskip_ARG,
ignoreskippedcluster_ARG, major_ARG, metadataprofile_ARG, minor_ARG,
monitor_ARG, minrecoveryrate_ARG, maxrecoveryrate_ARG, noudevsync_ARG,
diff --git a/tools/lvchange.c b/tools/lvchange.c
index e0bb4b1..144295b 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -605,6 +605,30 @@ static int lvchange_persistent(struct cmd_context *cmd,
return 1;
}
+static int lvchange_cachepolicy(struct cmd_context *cmd, struct logical_volume *lv)
+{
+ struct dm_config_tree *policy = NULL;
+ int r = 0;
+
+ if (!lv_is_cache(lv) && !lv_is_cache_pool(lv)) {
+ log_error("LV %s is not a cache LV.", lv->name);
+ log_error("Only cache or cache pool devices can have --cachepolicy set.");
+ goto_out;
+ }
+
+ if (!(policy = get_cachepolicy_params(cmd)))
+ goto_out;
+ if (!lv_cache_setpolicy(lv, policy))
+ goto_out;
+ if (!lv_update_and_reload(lv))
+ goto_out;
+ r = 1;
+out:
+ if (policy)
+ dm_config_destroy(policy);
+ return r;
+}
+
static int lvchange_tag(struct cmd_context *cmd, struct logical_volume *lv, int arg)
{
if (!change_tag(cmd, NULL, lv, NULL, arg))
@@ -990,6 +1014,13 @@ static int _lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
docmds++;
}
+ if (arg_count(cmd, cachepolicy_ARG)) {
+ if (!archive(lv->vg))
+ return_ECMD_FAILED;
+ doit += lvchange_cachepolicy(cmd, lv);
+ docmds++;
+ }
+
if (doit)
log_print_unless_silent("Logical volume \"%s\" changed.", lv->name);
@@ -1049,6 +1080,7 @@ int lvchange(struct cmd_context *cmd, int argc, char **argv)
arg_count(cmd, maxrecoveryrate_ARG) ||
arg_count(cmd, resync_ARG) ||
arg_count(cmd, syncaction_ARG) ||
+ arg_count(cmd, cachepolicy_ARG) ||
arg_count(cmd, writebehind_ARG) ||
arg_count(cmd, writemostly_ARG) ||
arg_count(cmd, zero_ARG);
9 years, 5 months
master - toollib: Add --cachepolicy and implement get_cachepolicy_params.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f67e1fadb0fcdc...
Commit: f67e1fadb0fcdc5887663f9b0c9c46fc5835d418
Parent: d22ffd8c289f570b3406f684212b6e7821179710
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Wed Nov 19 18:39:29 2014 +0100
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Thu Nov 20 16:51:06 2014 +0100
toollib: Add --cachepolicy and implement get_cachepolicy_params.
---
tools/args.h | 1 +
tools/toollib.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
tools/toollib.h | 2 +
3 files changed, 72 insertions(+), 0 deletions(-)
diff --git a/tools/args.h b/tools/args.h
index 000af01..63fee14 100644
--- a/tools/args.h
+++ b/tools/args.h
@@ -104,6 +104,7 @@ arg(trustcache_ARG, '\0', "trustcache", NULL, 0)
arg(type_ARG, '\0', "type", segtype_arg, 0)
arg(unbuffered_ARG, '\0', "unbuffered", NULL, 0)
arg(uncache_ARG, '\0', "uncache", NULL, 0)
+arg(cachepolicy_ARG, '\0', "cachepolicy", string_arg, ARG_GROUPABLE)
arg(units_ARG, '\0', "units", string_arg, 0)
arg(unquoted_ARG, '\0', "unquoted", NULL, 0)
arg(use_policies_ARG, '\0', "use-policies", NULL, 0)
diff --git a/tools/toollib.c b/tools/toollib.c
index d33de79..935f06e 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -1116,6 +1116,75 @@ int get_stripe_params(struct cmd_context *cmd, uint32_t *stripes, uint32_t *stri
return _validate_stripe_params(cmd, stripes, stripe_size);
}
+static int _validate_cachepool_params(struct dm_config_tree *tree)
+{
+ return 1;
+}
+
+struct dm_config_tree *get_cachepolicy_params(struct cmd_context *cmd)
+{
+ const char *str;
+ struct arg_value_group_list *group;
+ struct dm_config_tree *result = NULL, *prev = NULL, *current = NULL;
+ struct dm_config_node *cn, *last = NULL;
+
+ dm_list_iterate_items(group, &cmd->arg_value_groups) {
+ if (!grouped_arg_is_set(group->arg_values, cachepolicy_ARG))
+ continue;
+
+ current = dm_config_create();
+ if (!current)
+ goto_bad;
+ if (prev)
+ current->cascade = prev;
+ prev = current;
+
+ if (!(str = grouped_arg_str_value(group->arg_values,
+ cachepolicy_ARG,
+ NULL)))
+ goto_bad;
+
+ if (!dm_config_parse(current, str, str + strlen(str)))
+ goto_bad;
+ }
+
+ result = dm_config_flatten(current);
+ if (!(cn = dm_config_create_node(result, "policy_settings"))) {
+ dm_config_destroy(result);
+ result = NULL;
+ }
+ cn->child = result->root;
+ result->root = cn;
+ cn = cn->child;
+
+ while (cn) {
+ if (!strcmp(cn->key, "policy")) {
+ if (last)
+ last->sib = cn->sib;
+ else
+ result->root->child = cn->sib;
+ cn->parent = NULL;
+ cn->sib = NULL;
+ result->root->sib = cn;
+ }
+ last = cn;
+ cn = cn->sib;
+ }
+
+ if (!_validate_cachepool_params(current)) {
+ dm_config_destroy(result);
+ result = NULL;
+ }
+
+bad:
+ while (prev) {
+ current = prev->cascade;
+ dm_config_destroy(prev);
+ prev = current;
+ }
+ return result;
+}
+
/* FIXME move to lib */
static int _pv_change_tag(struct physical_volume *pv, const char *tag, int addtag)
{
diff --git a/tools/toollib.h b/tools/toollib.h
index 9040387..715f65e 100644
--- a/tools/toollib.h
+++ b/tools/toollib.h
@@ -123,6 +123,8 @@ int get_pool_params(struct cmd_context *cmd,
int get_stripe_params(struct cmd_context *cmd, uint32_t *stripes,
uint32_t *stripe_size);
+struct dm_config_tree *get_cachepolicy_params(struct cmd_context *cmd);
+
int change_tag(struct cmd_context *cmd, struct volume_group *vg,
struct logical_volume *lv, struct physical_volume *pv, int arg);
9 years, 5 months
master - cache: Add lv_cache_setpolicy to cache_manip.c.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d22ffd8c289f57...
Commit: d22ffd8c289f570b3406f684212b6e7821179710
Parent: 0050480c0eced1da98ffc76d5010cef605c776eb
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Wed Nov 19 18:38:30 2014 +0100
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Thu Nov 20 16:51:06 2014 +0100
cache: Add lv_cache_setpolicy to cache_manip.c.
---
lib/metadata/cache_manip.c | 18 ++++++++++++++++++
lib/metadata/metadata-exported.h | 1 +
2 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/lib/metadata/cache_manip.c b/lib/metadata/cache_manip.c
index fb5346d..f7b1b99 100644
--- a/lib/metadata/cache_manip.c
+++ b/lib/metadata/cache_manip.c
@@ -395,6 +395,24 @@ int lv_is_cache_origin(const struct logical_volume *lv)
return seg && lv_is_cache(seg->lv) && !lv_is_pending_delete(seg->lv) && (seg_lv(seg, 0) == lv);
}
+int lv_cache_setpolicy(struct logical_volume *lv, struct dm_config_tree *policy)
+{
+ struct lv_segment *seg = first_seg(lv);
+ const char *name;
+
+ if (lv_is_cache(lv))
+ seg = first_seg(seg->pool_lv);
+
+ if (!(seg->policy_settings = dm_config_clone_node_with_mem(lv->vg->vgmem, policy->root, 0)))
+ return_0;
+
+ if ((name = dm_config_find_str(policy->root, "policy", NULL)) &&
+ !(seg->policy_name = dm_pool_strdup(lv->vg->vgmem, name)))
+ return_0;
+
+ return 1;
+}
+
/*
* Wipe cache pool metadata area before use.
*
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index c472f41..d960e1f 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -1109,6 +1109,7 @@ int validate_lv_cache_create_origin(const struct logical_volume *origin_lv);
struct logical_volume *lv_cache_create(struct logical_volume *pool,
struct logical_volume *origin);
int lv_cache_remove(struct logical_volume *cache_lv);
+int lv_cache_setpolicy(struct logical_volume *cache_lv, struct dm_config_tree *pol);
int wipe_cache_pool(struct logical_volume *cache_pool_lv);
/* -- metadata/cache_manip.c */
9 years, 5 months
master - libdm-config: Warn about duplicate keys.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=0050480c0eced1...
Commit: 0050480c0eced1da98ffc76d5010cef605c776eb
Parent: de2c5ab2ac0100c1d2f0648b9fec5304371a1ae5
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Thu Nov 20 16:18:22 2014 +0100
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Thu Nov 20 16:51:06 2014 +0100
libdm-config: Warn about duplicate keys.
---
libdm/libdm-config.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/libdm/libdm-config.c b/libdm/libdm-config.c
index e99ae26..93e2887 100644
--- a/libdm/libdm-config.c
+++ b/libdm/libdm-config.c
@@ -523,6 +523,7 @@ static struct dm_config_node *_section(struct parser *p, struct dm_config_node *
/* IDENTIFIER SECTION_B_CHAR VALUE* SECTION_E_CHAR */
struct dm_config_node *root, *n, *l = NULL;
+ struct dm_config_value *value;
char *str;
if (p->t == TOK_STRING_ESCAPED) {
@@ -560,8 +561,12 @@ static struct dm_config_node *_section(struct parser *p, struct dm_config_node *
match(TOK_SECTION_E);
} else {
match(TOK_EQ);
- if (!(root->v = _value(p)))
+ if (!(value = _value(p)))
return_NULL;
+ if (root->v)
+ log_warn("WARNING: Ignoring duplicate"
+ " config value: %s", str);
+ root->v = value;
}
return root;
9 years, 5 months
master - libdm-config: Implement dm_config_remove_node.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=de2c5ab2ac0100...
Commit: de2c5ab2ac0100c1d2f0648b9fec5304371a1ae5
Parent: 8bc996676345bdaa69e0bdaaebb490a9da5a7d4b
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Thu Nov 20 12:05:09 2014 +0100
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Thu Nov 20 16:51:06 2014 +0100
libdm-config: Implement dm_config_remove_node.
---
libdm/libdevmapper.h | 1 +
libdm/libdm-config.c | 17 +++++++++++++++++
2 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/libdm/libdevmapper.h b/libdm/libdevmapper.h
index 3400c28..895ad48 100644
--- a/libdm/libdevmapper.h
+++ b/libdm/libdevmapper.h
@@ -1879,6 +1879,7 @@ int dm_config_write_one_node_out(const struct dm_config_node *cn, const struct d
struct dm_config_node *dm_config_find_node(const struct dm_config_node *cn, const char *path);
int dm_config_has_node(const struct dm_config_node *cn, const char *path);
+int dm_config_remove_node(struct dm_config_node *parent, struct dm_config_node *remove);
const char *dm_config_find_str(const struct dm_config_node *cn, const char *path, const char *fail);
const char *dm_config_find_str_allow_empty(const struct dm_config_node *cn, const char *path, const char *fail);
int dm_config_find_int(const struct dm_config_node *cn, const char *path, int fail);
diff --git a/libdm/libdm-config.c b/libdm/libdm-config.c
index 1bc88e1..e99ae26 100644
--- a/libdm/libdm-config.c
+++ b/libdm/libdm-config.c
@@ -1380,3 +1380,20 @@ struct dm_config_tree *dm_config_flatten(struct dm_config_tree *cft)
return res;
}
+
+int dm_config_remove_node(struct dm_config_node *parent, struct dm_config_node *remove)
+{
+ struct dm_config_node *cn = parent->child, *last = NULL;
+ while (cn) {
+ if (cn == remove) {
+ if (last)
+ last->sib = cn->sib;
+ else
+ parent->child = cn->sib;
+ return 1;
+ }
+ last = cn;
+ cn = cn->sib;
+ }
+ return 0;
+}
9 years, 5 months