summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Brassow <jbrassow@redhat.com>2013-08-26 14:12:31 -0500
committerJonathan Brassow <jbrassow@redhat.com>2013-08-26 14:12:31 -0500
commitcaa77b33f2d5e59f2906b9f08f59ac2e64b14682 (patch)
tree41517b66d9aa54e3208f3108dff826b583a29a57
parentd34ab5e0d39543db4f17994432a49a77709b3487 (diff)
downloadlvm2-caa77b33f2d5e59f2906b9f08f59ac2e64b14682.tar.gz
pvmove: Fix inability to specify LV name when moving RAID, mirror, or thin LV
Top-level LVs (like RAID, mirror or thin) are ignored when determining which portions of an LV to pvmove. If the user specified the name of an LV to move and it was one of the above types, it would be skipped. The code would never move on to check whether its sub-LVs needed moving because their names did not match what the user specified. The solution is to check whether a sub-LVs is part of the LV whose name was specified by the user - not just if there was a name match.
-rw-r--r--WHATS_NEW1
-rw-r--r--tools/pvmove.c26
2 files changed, 26 insertions, 1 deletions
diff --git a/WHATS_NEW b/WHATS_NEW
index c0744f630..069c3c23a 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.101 -
===================================
+ Fix inability to specify LV name when pvmove'ing a RAID, mirror, or thin-LV.
Inform lvmetad about any lost PV label to make it in sync with system state.
Support most of lvchange operations on stacked thin pool meta/data LVs.
Add ability to pvmove RAID, mirror, and thin volumes.
diff --git a/tools/pvmove.c b/tools/pvmove.c
index 8e950489c..286829030 100644
--- a/tools/pvmove.c
+++ b/tools/pvmove.c
@@ -16,6 +16,7 @@
#include "tools.h"
#include "polldaemon.h"
#include "display.h"
+#include "metadata.h" /* for 'get_only_segment_using_this_lv' */
#define PVMOVE_FIRST_TIME 0x00000001 /* Called for first time */
#define PVMOVE_EXCLUSIVE 0x00000002 /* Require exclusive LV */
@@ -209,6 +210,29 @@ static int _insert_pvmove_mirrors(struct cmd_context *cmd,
return 1;
}
+/*
+ * Is 'lv' a sub_lv of the LV by the name of 'lv_name'?
+ *
+ * Returns: 1 if true, 0 otherwise
+ */
+static int sub_lv_of(struct logical_volume *lv, const char *lv_name)
+{
+ struct lv_segment *seg;
+
+ /* Sub-LVs only ever have one segment using them */
+ if (dm_list_size(&lv->segs_using_this_lv) != 1)
+ return 0;
+
+ if (!(seg = get_only_segment_using_this_lv(lv)))
+ return_0;
+
+ if (!strcmp(seg->lv->name, lv_name))
+ return 1;
+
+ /* Continue up the tree */
+ return sub_lv_of(seg->lv, lv_name);
+}
+
/* Create new LV with mirror segments for the required copies */
static struct logical_volume *_set_up_pvmove_lv(struct cmd_context *cmd,
struct volume_group *vg,
@@ -295,7 +319,7 @@ static struct logical_volume *_set_up_pvmove_lv(struct cmd_context *cmd,
if (lv == lv_mirr)
continue;
if (lv_name) {
- if (strcmp(lv->name, lv_name))
+ if (strcmp(lv->name, lv_name) && !sub_lv_of(lv, lv_name))
continue;
lv_found = 1;
}