summaryrefslogtreecommitdiffstats
path: root/tools/vgsplit.c
diff options
context:
space:
mode:
authorAlasdair Kergon <agk@redhat.com>2005-04-07 12:39:44 +0000
committerAlasdair Kergon <agk@redhat.com>2005-04-07 12:39:44 +0000
commit072893aabd31b78b23b8235fe5f99146a40c7543 (patch)
tree274b1084fb8dec9c6c218c5c326c547437ea3648 /tools/vgsplit.c
parent3a6edbed16e1515a1b72da06608ac5172bd3b06f (diff)
downloadlvm2-072893aabd31b78b23b8235fe5f99146a40c7543.tar.gz
lvm2-072893aabd31b78b23b8235fe5f99146a40c7543.tar.xz
lvm2-072893aabd31b78b23b8235fe5f99146a40c7543.zip
Internal snapshot code restructuring.
Diffstat (limited to 'tools/vgsplit.c')
-rw-r--r--tools/vgsplit.c66
1 files changed, 41 insertions, 25 deletions
diff --git a/tools/vgsplit.c b/tools/vgsplit.c
index 2ff4e93d..741075c1 100644
--- a/tools/vgsplit.c
+++ b/tools/vgsplit.c
@@ -44,6 +44,19 @@ static int _move_pv(struct volume_group *vg_from, struct volume_group *vg_to,
return 1;
}
+/* FIXME Why not (lv->vg == vg) ? */
+static int _lv_is_in_vg(struct volume_group *vg, struct logical_volume *lv)
+{
+ struct lv_list *lvl;
+
+ list_iterate_items(lvl, &vg->lvs)
+ if (lv == lvl->lv)
+ return 1;
+
+ return 0;
+}
+
+
static int _move_lvs(struct volume_group *vg_from, struct volume_group *vg_to)
{
struct list *lvh, *lvht;
@@ -56,6 +69,9 @@ static int _move_lvs(struct volume_group *vg_from, struct volume_group *vg_to)
list_iterate_safe(lvh, lvht, &vg_from->lvs) {
lv = list_item(lvh, struct lv_list)->lv;
+ if ((lv->status & SNAPSHOT))
+ continue;
+
/* Ensure all the PVs used by this LV remain in the same */
/* VG as each other */
vg_with = NULL;
@@ -89,8 +105,9 @@ static int _move_lvs(struct volume_group *vg_from, struct volume_group *vg_to)
dev_name(pv->dev));
return 0;
}
- }
+ }
+
if (vg_with == vg_from)
continue;
@@ -107,39 +124,38 @@ static int _move_lvs(struct volume_group *vg_from, struct volume_group *vg_to)
return 1;
}
-static int _lv_is_in_vg(struct volume_group *vg, struct logical_volume *lv)
+static int _move_snapshots(struct volume_group *vg_from,
+ struct volume_group *vg_to)
{
- struct lv_list *lvl;
+ struct list *lvh, *lvht;
+ struct logical_volume *lv;
+ struct lv_segment *seg;
+ int cow_from = 0;
+ int origin_from = 0;
- list_iterate_items(lvl, &vg->lvs)
- if (lv == lvl->lv)
- return 1;
+ list_iterate_safe(lvh, lvht, &vg_from->lvs) {
+ lv = list_item(lvh, struct lv_list)->lv;
- return 0;
-}
+ if (!(lv->status & SNAPSHOT))
+ continue;
-static int _move_snapshots(struct volume_group *vg_from,
- struct volume_group *vg_to)
-{
- struct list *slh, *slth;
- struct snapshot *snap;
- int cow_from, origin_from;
-
- list_iterate_safe(slh, slth, &vg_from->snapshots) {
- snap = list_item(slh, struct snapshot_list)->snapshot;
- cow_from = _lv_is_in_vg(vg_from, snap->cow);
- origin_from = _lv_is_in_vg(vg_from, snap->origin);
+ list_iterate_items(seg, &lv->segments) {
+ cow_from = _lv_is_in_vg(vg_from, seg->cow);
+ origin_from = _lv_is_in_vg(vg_from, seg->origin);
+ }
if (cow_from && origin_from)
- return 1;
+ continue;
if ((!cow_from && origin_from) || (cow_from && !origin_from)) {
- log_error("Snapshot %s split", snap->cow->name);
+ log_error("Snapshot %s split", seg->cow->name);
return 0;
- }
+ }
+
+ /* Move this snapshot */
+ list_del(lvh);
+ list_add(&vg_to->lvs, lvh);
+
vg_from->snapshot_count--;
vg_to->snapshot_count++;
-
- list_del(slh);
- list_add(&vg_to->snapshots, slh);
}
return 1;