summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Brassow <jbrassow@redhat.com>2014-06-19 10:57:08 -0500
committerJonathan Brassow <jbrassow@redhat.com>2014-06-19 10:57:08 -0500
commitc6d82c992b4a4271287233dbedc3a075fa03ca43 (patch)
treeecd4f16b4afa6d9f66b9b3f1274ac5769950be59
parent3964a1a89f52584878c09cf93bc971b96c0d3de1 (diff)
downloadlvm2-c6d82c992b4a4271287233dbedc3a075fa03ca43.tar.gz
pvmove: Fix code that looks up the "move pv" for display
'lvs' would segfault if trying to display the "move pv" if the pvmove was run with '--atomic'. The structure of an atomic pvmove is different and requires us to descend another level in the LV tree to retrieve the PV information.
-rw-r--r--lib/metadata/lv.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/lib/metadata/lv.c b/lib/metadata/lv.c
index 733e9f60c..a1211a85f 100644
--- a/lib/metadata/lv.c
+++ b/lib/metadata/lv.c
@@ -316,11 +316,26 @@ char *lv_convert_lv_dup(struct dm_pool *mem, const struct logical_volume *lv)
char *lv_move_pv_dup(struct dm_pool *mem, const struct logical_volume *lv)
{
+ struct logical_volume *mimage0_lv;
struct lv_segment *seg;
-
- dm_list_iterate_items(seg, &lv->segments)
- if (seg->status & PVMOVE)
- return dm_pool_strdup(mem, dev_name(seg_dev(seg, 0)));
+ const struct device *dev;
+
+ dm_list_iterate_items(seg, &lv->segments) {
+ if (seg->status & PVMOVE) {
+ if (seg_type(seg, 0) == AREA_LV) { /* atomic pvmove */
+ mimage0_lv = seg_lv(seg, 0);
+ if (!lv_is_mirror_type(mimage0_lv)) {
+ log_error(INTERNAL_ERROR
+ "Bad pvmove structure");
+ return NULL;
+ }
+ dev = seg_dev(first_seg(mimage0_lv), 0);
+ } else /* Segment pvmove */
+ dev = seg_dev(seg, 0);
+
+ return dm_pool_strdup(mem, dev_name(dev));
+ }
+ }
return NULL;
}