From 3801cb524c2cd4541fce02670c265f1322c54afa Mon Sep 17 00:00:00 2001 From: Petr Rockai Date: Thu, 25 Nov 2010 17:15:46 +0000 Subject: [PATCH] Disallow certain lvconvert operations that need to both allocate and free extents, while physical volumes are specified. Fixes BZ 640051. --- test/t-lvconvert-twostep.sh | 21 +++++++++++++++++++++ tools/lvconvert.c | 9 +++++++++ 2 files changed, 30 insertions(+) create mode 100644 test/t-lvconvert-twostep.sh diff --git a/test/t-lvconvert-twostep.sh b/test/t-lvconvert-twostep.sh new file mode 100644 index 000000000..c499fdda7 --- /dev/null +++ b/test/t-lvconvert-twostep.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# Copyright (C) 2010 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 + +. ./test-utils.sh + +aux prepare_vg 4 +lvcreate -m 1 --mirrorlog disk --ig -L 1 -n mirror $vg +not lvconvert -m 2 --mirrorlog core $vg/mirror $dev3 2>&1 | tee errs +grep "two steps" errs +lvconvert -m 2 $vg/mirror $dev3 +lvconvert --mirrorlog core $vg/mirror +not lvconvert -m 1 --mirrorlog disk $vg/mirror $dev3 2>&1 | tee errs +grep "two steps" errs diff --git a/tools/lvconvert.c b/tools/lvconvert.c index fe5fa002f..58b4ed7f9 100644 --- a/tools/lvconvert.c +++ b/tools/lvconvert.c @@ -1345,6 +1345,15 @@ static int _lvconvert_mirrors(struct cmd_context *cmd, &new_mimage_count, &new_log_count)) return 0; + if (((old_mimage_count < new_mimage_count && old_log_count > new_log_count) || + (old_mimage_count > new_mimage_count && old_log_count < new_log_count)) && + lp->pv_count) { + log_error("Cannot both allocate and free extents when specifying physical" + " volumes to use."); + log_error("Please specify the operation in two steps."); + return 0; + } + /* Nothing to do? (Probably finishing collapse.) */ if ((old_mimage_count == new_mimage_count) && (old_log_count == new_log_count) && !repair) -- 2.43.5