summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetr Rockai <prockai@redhat.com>2014-11-27 20:21:41 +0100
committerPetr Rockai <prockai@redhat.com>2014-11-27 20:22:03 +0100
commit5b2726fc6142c734e06fa8b49ad856b2e47da9fc (patch)
tree37a7044ff6967926ac5eb31af4b1af60fd63ecc5
parent2c3db52356eebd7ad7e950a01f465359c040b379 (diff)
downloadlvm2-5b2726fc6142c734e06fa8b49ad856b2e47da9fc.tar.gz
lvcreate: Implement --cachepolicy/--cachesettings.
-rw-r--r--test/shell/lvcreate-cache.sh14
-rw-r--r--tools/commands.h3
-rw-r--r--tools/lvcreate.c19
3 files changed, 34 insertions, 2 deletions
diff --git a/test/shell/lvcreate-cache.sh b/test/shell/lvcreate-cache.sh
index eeba827d0..f709d8bdf 100644
--- a/test/shell/lvcreate-cache.sh
+++ b/test/shell/lvcreate-cache.sh
@@ -226,6 +226,20 @@ fail lvcreate -H -L10 --chunksize 16M $vg/cpool4
lvremove -f $vg
+lvcreate --type cache-pool -L10 $vg/cpool
+lvcreate --type cache -l 1 --cachepool $vg/cpool -n corigin $vg --cachepolicy mq --cachesettings migration_threshold=233
+dmsetup status | grep $vg
+dmsetup status | grep $vg-corigin | grep 'migration_threshold 233'
+
+lvremove -f $vg
+
+lvcreate --type cache-pool -L10 --cachepolicy mq --cachesettings migration_threshold=233 $vg/cpool
+lvcreate --type cache -l 1 --cachepool $vg/cpool -n corigin $vg
+dmsetup status | grep $vg
+dmsetup status | grep $vg-corigin | grep 'migration_threshold 233'
+
+lvremove -f $vg
+
##############################
# Test things that should fail
diff --git a/tools/commands.h b/tools/commands.h
index 852b675b0..8dc335c96 100644
--- a/tools/commands.h
+++ b/tools/commands.h
@@ -308,6 +308,7 @@ xx(lvcreate,
"\t[-A|--autobackup {y|n}]\n"
"\t[--addtag Tag]\n"
"\t[--alloc AllocationPolicy]\n"
+ "\t[--cachepolicy Policy] [--cachesettings Key=Value]\n"
"\t[-c|--chunksize]\n"
"\t[-C|--contiguous {y|n}]\n"
"\t[--commandprofile ProfileName]\n"
@@ -337,7 +338,7 @@ xx(lvcreate,
"\t[PhysicalVolumePath...]\n\n",
addtag_ARG, alloc_ARG, autobackup_ARG, activate_ARG, available_ARG,
- cache_ARG, cachemode_ARG, cachepool_ARG,
+ cache_ARG, cachemode_ARG, cachepool_ARG, cachepolicy_ARG, cachesettings_ARG,
chunksize_ARG, contiguous_ARG, corelog_ARG, discards_ARG,
extents_ARG, ignoreactivationskip_ARG, ignoremonitoring_ARG, major_ARG,
metadataprofile_ARG, minor_ARG, mirrorlog_ARG, mirrors_ARG, monitor_ARG,
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index b0186d338..7236ffca5 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -698,7 +698,9 @@ static int _lvcreate_params(struct cmd_context *cmd,
#define CACHE_POOL_ARGS \
cachemode_ARG,\
- cachepool_ARG
+ cachepool_ARG,\
+ cachepolicy_ARG,\
+ cachesettings_ARG
#define MIRROR_ARGS \
corelog_ARG,\
@@ -1010,6 +1012,13 @@ static int _lvcreate_params(struct cmd_context *cmd,
return 0;
}
+ if ((arg_count(cmd, cachepolicy_ARG) || arg_count(cmd, cachesettings_ARG)) &&
+ !(lp->cache_policy = get_cachepolicy_params(cmd)))
+ {
+ log_error("Failed to parse cache policy and/or settings.");
+ return 0;
+ }
+
dm_list_iterate_items(current_group, &cmd->arg_value_groups) {
if (!grouped_arg_is_set(current_group->arg_values, addtag_ARG))
continue;
@@ -1404,6 +1413,13 @@ static int _validate_internal_thin_processing(const struct lvcreate_params *lp)
return r;
}
+static void _destroy_lvcreate_params(struct lvcreate_params *lp)
+{
+ if (lp->cache_policy)
+ dm_config_destroy(lp->cache_policy);
+ lp->cache_policy = NULL;
+}
+
int lvcreate(struct cmd_context *cmd, int argc, char **argv)
{
int r = ECMD_FAILED;
@@ -1482,6 +1498,7 @@ int lvcreate(struct cmd_context *cmd, int argc, char **argv)
r = ECMD_PROCESSED;
out:
+ _destroy_lvcreate_params(&lp);
unlock_and_release_vg(cmd, vg, lp.vg_name);
return r;
}