From: Jonathan Earl Brassow Date: Wed, 5 Jan 2011 20:02:45 +0000 (+0000) Subject: Prevent the user from simultaneously adding a mirror log while removing X-Git-Tag: v2_02_91~1219 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=327dbf10783f8c82d98bdc66db74f09a0a5d373e;p=lvm2.git Prevent the user from simultaneously adding a mirror log while removing a mirror image (or removing a log while adding a mirror). Advise the user to use two separate commands instead. This issue become especially problematic when PVs are specified, as they tend to mean different things when adding vs removing. In a command that mixes adding and removing, it is impossible to decern exactly what the user wants. This change prevents bug 603912. --- diff --git a/WHATS_NEW b/WHATS_NEW index 1a4dcc77d..04920bc6a 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.80 - ==================================== + Prevent adding/removing mirror log while removing/adding an image. Add missing tests in _setup_task(). Fail poll daemon creation when lvmcache_init() fails. Return defined value for errors in _copy_percent() and _snap_percent(). diff --git a/tools/lvconvert.c b/tools/lvconvert.c index 7c7826bbd..3dab0d3f8 100644 --- a/tools/lvconvert.c +++ b/tools/lvconvert.c @@ -926,6 +926,25 @@ static int _lvconvert_mirrors_parse_params(struct cmd_context *cmd, return 0; } + /* + * Disallow adding logs while removing images or + * adding images while removing logs + */ + if ((*old_log_count < *new_log_count) && + (*old_mimage_count > *new_mimage_count)) { + log_error("Mirror logs cannot be added while images are" + " being removed."); + log_error("Try two separate commands."); + return 0; + } + if ((*old_log_count > *new_log_count) && + (*old_mimage_count < *new_mimage_count)) { + log_error("Mirror images cannot be added while logs are" + " being removed."); + log_error("Try two separate commands."); + return 0; + } + /* * No mirrored logs for cluster mirrors until * log daemon is multi-threaded.