summaryrefslogtreecommitdiffstats
path: root/tools/vgsplit.c
diff options
context:
space:
mode:
authorDave Wysochanski <dwysocha@redhat.com>2008-04-09 20:56:06 +0000
committerDave Wysochanski <dwysocha@redhat.com>2008-04-09 20:56:06 +0000
commiteec663aa3bea9ecdc393b506eaa1111876b6dce4 (patch)
treeafe99dd5ac337669c98ffdb181ec0505a7667536 /tools/vgsplit.c
parentf2696211dc1c0e15344f1ffc7fdc893f5eb462c2 (diff)
downloadlvm2-eec663aa3bea9ecdc393b506eaa1111876b6dce4.tar.gz
lvm2-eec663aa3bea9ecdc393b506eaa1111876b6dce4.tar.xz
lvm2-eec663aa3bea9ecdc393b506eaa1111876b6dce4.zip
Fix vgsplit to only move hidden 'snapshotN' LVs when necessary.
This bug has been around for a long time as far as I can tell. Without this fix, a vgsplit would unconditionally move the 'hidden/internal' snapshot LVs, and result in corrupted metadata in the following case: vg1: contains lv1, lv1snap, both on pvset1 vg1: contains lv2, on pvset2 "vgsplit vg1 vg2 pvset2" would result in "snapshot0" hidden LV being moved to vg2, and the origin and cow being left in vg1. The tools detect the corruption in vg2, but not in vg1.
Diffstat (limited to 'tools/vgsplit.c')
-rw-r--r--tools/vgsplit.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/tools/vgsplit.c b/tools/vgsplit.c
index 3c11b0d7..c0838893 100644
--- a/tools/vgsplit.c
+++ b/tools/vgsplit.c
@@ -164,6 +164,9 @@ static int _move_lvs(struct volume_group *vg_from, struct volume_group *vg_to)
return 1;
}
+/*
+ * Move the hidden / internal "snapshotN" LVs.from 'vg_from' to 'vg_to'.
+ */
static int _move_snapshots(struct volume_group *vg_from,
struct volume_group *vg_to)
{
@@ -191,14 +194,21 @@ static int _move_snapshots(struct volume_group *vg_from,
" two Volume Groups", seg->cow->name);
return 0;
}
- }
- /* Move this snapshot */
- list_del(lvh);
- list_add(&vg_to->lvs, lvh);
+ /*
+ * At this point, the cow and origin should already be
+ * in vg_to.
+ */
+ if (_lv_is_in_vg(vg_to, seg->cow) &&
+ _lv_is_in_vg(vg_to, seg->origin)) {
+ list_del(lvh);
+ list_add(&vg_to->lvs, lvh);
+
+ vg_from->snapshot_count--;
+ vg_to->snapshot_count++;
+ }
+ }
- vg_from->snapshot_count--;
- vg_to->snapshot_count++;
}
return 1;