int thin;
int uncache;
const char *type_str; /* When this is set, mirrors_supplied may optionally also be set */
+ /* Holds what you asked for based on --type or other arguments, else "" */
- const struct segment_type *segtype;
+ const struct segment_type *segtype; /* Holds what segment type you will get */
int merge_snapshot; /* merge is also set */
int merge_mirror; /* merge is also set */
return 1;
}
-static int _check_conversion_type(struct cmd_context *cmd, const char *type_str)
-{
- if (!type_str || !*type_str)
- return 1;
-
- if (!strcmp(type_str, "mirror")) {
- if (!arg_is_set(cmd, mirrors_ARG)) {
- log_error("Conversions to --type mirror require -m/--mirrors");
- return 0;
- }
- return 1;
- }
-
- /* FIXME: Check thin-pool and thin more thoroughly! */
- if (!strcmp(type_str, "snapshot") || !strcmp(type_str, "linear") ||
- !strcmp(type_str, "striped") ||
- !strncmp(type_str, "raid", 4) ||
- !strcmp(type_str, "cache-pool") || !strcmp(type_str, "cache") ||
- !strcmp(type_str, "thin-pool") || !strcmp(type_str, "thin"))
- return 1;
-
- log_error("Conversion using --type %s is not supported.", type_str);
- return 0;
-}
-
/* -s/--snapshot and --type snapshot are synonyms */
static int _snapshot_type_requested(struct cmd_context *cmd, const char *type_str)
{
- return (arg_is_set(cmd, snapshot_ARG) || !strcmp(type_str, "snapshot"));
+ return (arg_is_set(cmd, snapshot_ARG) || !strcmp(type_str, SEG_TYPE_NAME_SNAPSHOT));
}
-static int _raid0_type_requested(struct cmd_context *cmd, const char *type_str)
+static int _raid0_type_requested(const char *type_str)
{
- return (!strcmp(type_str, "raid0") || !strcmp(type_str, "raid0_meta"));
+ return (!strcmp(type_str, SEG_TYPE_NAME_RAID0) || !strcmp(type_str, SEG_TYPE_NAME_RAID0_META));
}
/* mirror/raid* (1,10,4,5,6 and their variants) reshape */
static int _mirror_or_raid_type_requested(struct cmd_context *cmd, const char *type_str)
{
- return (arg_is_set(cmd, mirrors_ARG) || !strcmp(type_str, "mirror") ||
- (!strncmp(type_str, "raid", 4) && !_raid0_type_requested(cmd, type_str)));
+ return (arg_is_set(cmd, mirrors_ARG) || !strcmp(type_str, SEG_TYPE_NAME_MIRROR) ||
+ (!strncmp(type_str, SEG_TYPE_NAME_RAID, 4) && !_raid0_type_requested(type_str)));
}
-static int _striped_type_requested(struct cmd_context *cmd, const char *type_str)
+static int _linear_type_requested(const char *type_str)
{
- return (!strcmp(type_str, SEG_TYPE_NAME_STRIPED) || !strcmp(type_str, SEG_TYPE_NAME_LINEAR));
+ return (!strcmp(type_str, SEG_TYPE_NAME_LINEAR));
}
-static int _linear_type_requested(const char *type_str)
+static int _striped_type_requested(const char *type_str)
{
- return (!strcmp(type_str, SEG_TYPE_NAME_LINEAR));
+ return (!strcmp(type_str, SEG_TYPE_NAME_STRIPED) || _linear_type_requested(type_str));
+}
+
+static int _check_conversion_type(struct cmd_context *cmd, const char *type_str)
+{
+ if (!type_str || !*type_str)
+ return 1;
+
+ if (!strcmp(type_str, SEG_TYPE_NAME_MIRROR)) {
+ if (!arg_is_set(cmd, mirrors_ARG)) {
+ log_error("Conversions to --type mirror require -m/--mirrors");
+ return 0;
+ }
+ return 1;
+ }
+
+ /* FIXME: Check thin-pool and thin more thoroughly! */
+ if (!strcmp(type_str, SEG_TYPE_NAME_SNAPSHOT) || _striped_type_requested(type_str) ||
+ !strncmp(type_str, SEG_TYPE_NAME_RAID, 4) ||
+ !strcmp(type_str, SEG_TYPE_NAME_CACHE_POOL) || !strcmp(type_str, SEG_TYPE_NAME_CACHE) ||
+ !strcmp(type_str, SEG_TYPE_NAME_THIN_POOL) || !strcmp(type_str, SEG_TYPE_NAME_THIN))
+ return 1;
+
+ log_error("Conversion using --type %s is not supported.", type_str);
+ return 0;
}
static int _read_pool_params(struct cmd_context *cmd, int *pargc, char ***pargv,
if ((lp->pool_data_name = arg_str_value(cmd, cachepool_ARG, NULL))) {
if (lp->type_str[0] &&
- strcmp(lp->type_str, "cache") &&
- strcmp(lp->type_str, "cache-pool")) {
+ strcmp(lp->type_str, SEG_TYPE_NAME_CACHE) &&
+ strcmp(lp->type_str, SEG_TYPE_NAME_CACHE_POOL)) {
log_error("--cachepool argument is only valid with "
"the cache or cache-pool segment type.");
return 0;
}
cachepool = 1;
- lp->type_str = "cache-pool";
- } else if (!strcmp(lp->type_str, "cache-pool"))
+ lp->type_str = SEG_TYPE_NAME_CACHE_POOL;
+ } else if (!strcmp(lp->type_str, SEG_TYPE_NAME_CACHE_POOL))
cachepool = 1;
else if ((lp->pool_data_name = arg_str_value(cmd, thinpool_ARG, NULL))) {
if (lp->type_str[0] &&
- strcmp(lp->type_str, "thin") &&
- strcmp(lp->type_str, "thin-pool")) {
+ strcmp(lp->type_str, SEG_TYPE_NAME_THIN) &&
+ strcmp(lp->type_str, SEG_TYPE_NAME_THIN_POOL)) {
log_error("--thinpool argument is only valid with "
"the thin or thin-pool segment type.");
return 0;
}
thinpool = 1;
- lp->type_str = "thin-pool";
- } else if (!strcmp(lp->type_str, "thin-pool"))
+ lp->type_str = SEG_TYPE_NAME_THIN_POOL;
+ } else if (!strcmp(lp->type_str, SEG_TYPE_NAME_THIN_POOL))
thinpool = 1;
if (lp->cache && !cachepool) {
if (arg_is_set(cmd, cache_ARG))
lp->cache = 1;
- if (!strcmp(lp->type_str, "cache"))
+ if (!strcmp(lp->type_str, SEG_TYPE_NAME_CACHE))
lp->cache = 1;
else if (lp->cache) {
if (lp->type_str[0]) {
log_error("--cache is incompatible with --type %s", lp->type_str);
return 0;
}
- lp->type_str = "cache";
+ lp->type_str = SEG_TYPE_NAME_CACHE;
}
if (arg_is_set(cmd, thin_ARG))
lp->thin = 1;
- if (!strcmp(lp->type_str, "thin"))
+ if (!strcmp(lp->type_str, SEG_TYPE_NAME_THIN))
lp->thin = 1;
else if (lp->thin) {
if (lp->type_str[0]) {
log_error("--thin is incompatible with --type %s", lp->type_str);
return 0;
}
- lp->type_str = "thin";
+ lp->type_str = SEG_TYPE_NAME_THIN;
}
/* May set lp->segtype */
!lp->splitcache && !lp->split && !lp->snapshot && !lp->uncache && !lp->cache && !lp->thin &&
!lp->replace && !lp->repair && !lp->mirrorlog && !lp->corelog &&
(arg_is_set(cmd, stripes_long_ARG) || arg_is_set(cmd, stripesize_ARG)))
- lp->type_str = "striped";
+ lp->type_str = SEG_TYPE_NAME_STRIPED;
if ((_snapshot_type_requested(cmd, lp->type_str) || lp->merge) &&
(lp->mirrorlog || _mirror_or_raid_type_requested(cmd, lp->type_str) ||
- lp->repair || arg_is_set(cmd, thinpool_ARG) || _raid0_type_requested(cmd, lp->type_str) ||
- _striped_type_requested(cmd, lp->type_str))) {
+ lp->repair || arg_is_set(cmd, thinpool_ARG) || _raid0_type_requested(lp->type_str) ||
+ _striped_type_requested(lp->type_str))) {
log_error("--snapshot/--type snapshot or --merge argument "
"cannot be mixed with --mirrors/--type mirror/--type raid*/--stripes/--type striped/--type linear, "
"--mirrorlog, --repair or --thinpool.");
}
if ((arg_is_set(cmd, stripes_long_ARG) || arg_is_set(cmd, stripesize_ARG)) &&
- !(_mirror_or_raid_type_requested(cmd, lp->type_str) || _striped_type_requested(cmd, lp->type_str) ||
- _raid0_type_requested(cmd, lp->type_str) || lp->repair || arg_is_set(cmd, thinpool_ARG))) {
+ !(_mirror_or_raid_type_requested(cmd, lp->type_str) || _striped_type_requested(lp->type_str) ||
+ _raid0_type_requested(lp->type_str) || lp->repair || arg_is_set(cmd, thinpool_ARG))) {
log_error("--stripes or --stripesize argument is only valid "
"with --mirrors/--type mirror/--type raid*/--type striped/--type linear, --repair and --thinpool");
return 0;
if (!(lp->segtype = get_segtype_from_string(cmd, arg_str_value(cmd, type_ARG, find_config_tree_str(cmd, global_mirror_segtype_default_CFG, NULL)))))
return_0;
}
- } else if (_raid0_type_requested(cmd, lp->type_str) || _striped_type_requested(cmd, lp->type_str)) { /* striped or linear or raid0 */
+ } else if (_raid0_type_requested(lp->type_str) || _striped_type_requested(lp->type_str)) { /* striped or linear or raid0 */
if (arg_from_list_is_set(cmd, "cannot be used with --type raid0 or --type striped or --type linear",
chunksize_ARG, corelog_ARG, mirrors_ARG, mirrorlog_ARG, regionsize_ARG, zero_ARG,
-1))
/* --trackchanges requires --splitmirrors which always has SIGN_MINUS */
if (lp->track_changes && lp->mirrors != 1) {
- log_error("Exactly one image must be split off from %s when tracking changes.",
+ log_error("Exactly one image must be split off from %s when tracking changes.",
display_lvname(lv));
- return 0;
- }
+ return 0;
+ }
}
if (lp->merge_mirror)
*
* for each lvtype,
* _convert_lvtype();
- * for each arg_is_set(operation)
- * _convert_lvtype_operation();
+ * for each arg_is_set(operation)
+ * _convert_lvtype_operation();
*
*/
static int _lvconvert(struct cmd_context *cmd, struct logical_volume *lv,