From 13cd3ff5a0dd1652cf20697dbb0d768c6b5115f1 Mon Sep 17 00:00:00 2001 From: David Teigland Date: Wed, 6 Jul 2016 16:44:18 -0500 Subject: [PATCH] lvconvert: allow converting type raid1 to type linear The code could perform this conversion but ironically did not recognize the standard command form, only the the unpreferred "implication-based" command form. "lvconvert --type linear VG/RaidLV" would fail, but "lvconvert --mirrors 0 VG/RaidLV" would succeed. --- tools/lvconvert.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tools/lvconvert.c b/tools/lvconvert.c index d0aa7337f..ce858ae1d 100644 --- a/tools/lvconvert.c +++ b/tools/lvconvert.c @@ -1823,6 +1823,7 @@ static void _lvconvert_raid_repair_ask(struct cmd_context *cmd, static int _lvconvert_raid(struct logical_volume *lv, struct lvconvert_params *lp) { + const char *new_type; int replace = 0, image_count = 0; struct dm_list *failed_pvs; struct cmd_context *cmd = lv->vg->cmd; @@ -1832,6 +1833,16 @@ static int _lvconvert_raid(struct logical_volume *lv, struct lvconvert_params *l if (!lp->segtype) lp->segtype = seg->segtype; + if ((new_type = arg_str_value(cmd, type_ARG, NULL)) && + !strcmp(new_type, SEG_TYPE_NAME_LINEAR)) { + if (arg_is_set(cmd, mirrors_ARG) && (arg_uint_value(cmd, mirrors_ARG, 0) != 0)) { + log_error("Cannot specify mirrors with linear type."); + return 0; + } + lp->mirrors_supplied = 1; + lp->mirrors = 0; + } + /* Can only change image count for raid1 and linear */ if (lp->mirrors_supplied && !seg_is_mirrored(seg) && !seg_is_linear(seg)) { log_error("'--mirrors/-m' is not compatible with %s",