summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2017-04-11 12:07:14 -0500
committerDavid Teigland <teigland@redhat.com>2017-04-11 12:11:00 -0500
commita96c8b46b62c316381eb029416b92197d9cfa4de (patch)
tree74f9b18846aa63fe4133c691ad991979a2a11a2a
parente0c169f8b7f214100ad11c68b1cab799e8adaaed (diff)
downloadlvm2-a96c8b46b62c316381eb029416b92197d9cfa4de.tar.gz
lvconvert: prevent duplicate use of metadata lv
The LV being processed cannot be used as the pool metadata LV.
-rw-r--r--tools/lvconvert.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index ee7fb8b48..c18b5a4d5 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -2658,10 +2658,15 @@ static int _lvconvert_swap_pool_metadata(struct cmd_context *cmd,
* Create a new pool LV, using the lv arg as the data sub LV.
* The metadata sub LV is either a new LV created here, or an
* existing LV specified by --poolmetadata.
+ *
+ * process_single_lv is the LV currently being processed by
+ * process_each_lv(). It will sometimes be the same as the
+ * lv arg, and sometimes not.
*/
static int _lvconvert_to_pool(struct cmd_context *cmd,
struct logical_volume *lv,
+ struct logical_volume *process_single_lv,
int to_thinpool,
int to_cachepool,
struct dm_list *use_pvh)
@@ -2773,6 +2778,12 @@ static int _lvconvert_to_pool(struct cmd_context *cmd,
return 0;
}
+ if (metadata_lv == process_single_lv) {
+ log_error("Use a different LV for pool metadata %s.",
+ display_lvname(metadata_lv));
+ return 0;
+ }
+
if (!lv_is_visible(metadata_lv)) {
log_error("Can't convert internal LV %s.",
display_lvname(metadata_lv));
@@ -3765,7 +3776,7 @@ static int _lvconvert_to_pool_single(struct cmd_context *cmd,
} else
use_pvh = &lv->vg->pvs;
- if (!_lvconvert_to_pool(cmd, lv, to_thinpool, to_cachepool, use_pvh))
+ if (!_lvconvert_to_pool(cmd, lv, lv, to_thinpool, to_cachepool, use_pvh))
return_ECMD_FAILED;
return ECMD_PROCESSED;
@@ -3815,7 +3826,7 @@ static int _lvconvert_to_cache_vol_single(struct cmd_context *cmd,
goto out;
}
- if (!_lvconvert_to_pool(cmd, cachepool_lv, 0, 1, &vg->pvs)) {
+ if (!_lvconvert_to_pool(cmd, cachepool_lv, lv, 0, 1, &vg->pvs)) {
log_error("LV %s could not be converted to a cache pool.",
display_lvname(cachepool_lv));
goto out;
@@ -3913,7 +3924,7 @@ static int _lvconvert_to_thin_with_external_single(struct cmd_context *cmd,
goto out;
}
- if (!_lvconvert_to_pool(cmd, thinpool_lv, 1, 0, &vg->pvs)) {
+ if (!_lvconvert_to_pool(cmd, thinpool_lv, lv, 1, 0, &vg->pvs)) {
log_error("LV %s could not be converted to a thin pool.",
display_lvname(thinpool_lv));
goto out;
@@ -4066,7 +4077,7 @@ static int _lvconvert_to_pool_or_swap_metadata_single(struct cmd_context *cmd,
return _lvconvert_swap_pool_metadata_single(cmd, lv, handle);
}
- if (!_lvconvert_to_pool(cmd, lv, to_thinpool, to_cachepool, use_pvh))
+ if (!_lvconvert_to_pool(cmd, lv, lv, to_thinpool, to_cachepool, use_pvh))
return_ECMD_FAILED;
return ECMD_PROCESSED;