summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Jones <pjones@redhat.com>2005-03-28 21:36:59 +0000
committerPeter Jones <pjones@redhat.com>2005-03-28 21:36:59 +0000
commite1b00db6c794295a0e68ffc8a498f54eed78ebd0 (patch)
tree4ebb3a3addbeaa7f0a565efc864eadad0785199f
parentdc3bdef00ab252648dd31edae9ab299af7007c19 (diff)
downloadanaconda-e1b00db6c794295a0e68ffc8a498f54eed78ebd0.tar.gz
anaconda-e1b00db6c794295a0e68ffc8a498f54eed78ebd0.tar.xz
anaconda-e1b00db6c794295a0e68ffc8a498f54eed78ebd0.zip
update LV snapshot delete code
-rw-r--r--ChangeLog5
-rw-r--r--partRequests.py5
-rw-r--r--partitions.py39
3 files changed, 31 insertions, 18 deletions
diff --git a/ChangeLog b/ChangeLog
index 63cf9f09b..d4d3ebf12 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2005-03-28 Peter Jones <pjones@redhat.com>
+ * partitions.py, partRequests.py: don't put snapshot LVs into
+ RequestSpecs after all. Instead, look for children when we
+ actually do the lvremove()
+
2005-03-28 Jeremy Katz <katzj@redhat.com>
* loader2/loader.c (parseCmdLineFlags): Allow setting mtu on the
diff --git a/partRequests.py b/partRequests.py
index 01be85ac5..2b9a38ce9 100644
--- a/partRequests.py
+++ b/partRequests.py
@@ -798,7 +798,7 @@ class LogicalVolumeRequestSpec(RequestSpec):
def __init__(self, fstype, format = None, mountpoint = None,
size = None, volgroup = None, lvname = None,
preexist = 0, percent = None, grow=0, maxSizeMB=0,
- bytesPerInode = 4096, lvorigin=None):
+ bytesPerInode = 4096):
"""Create a new VolumeGroupRequestSpec object.
fstype is the fsset filesystem type.
@@ -812,7 +812,6 @@ class LogicalVolumeRequestSpec(RequestSpec):
grow is whether or not to use free space remaining.
maxSizeMB is max size to grow to.
bytesPerInode is the size of the inodes on the partition.
- lvorigin is the name of the LV that this snapshot LV is taken from
"""
# if it's preexisting, the original fstype should be set
@@ -839,8 +838,6 @@ class LogicalVolumeRequestSpec(RequestSpec):
self.grow = grow
self.maxSizeMB = maxSizeMB
self.startSize = size
- self.lvorigin = lvorigin
- self.snapshots = []
if not percent and not size and not preexist:
raise RuntimeError, "Error with Volume Group:Logical Volume %s:%s - Logical Volume must specify either percentage of vgsize or size" % (volgroup, lvname)
diff --git a/partitions.py b/partitions.py
index 1a582a432..f6e65496e 100644
--- a/partitions.py
+++ b/partitions.py
@@ -192,7 +192,6 @@ class Partitions:
lvm.vgactivate()
pvs = lvm.pvlist()
- snapshots = {}
for (vg, size, pesize) in lvm.vglist():
try:
preexist_size = float(size)
@@ -219,10 +218,10 @@ class Partitions:
vgid = self.addRequest(spec)
for (lvvg, lv, size, lvorigin) in lvm.lvlist():
+ if lvorigin:
+ continue
if lvvg != vg:
continue
- snapshots.setdefault(lvorigin, [])
- snapshots[lvorigin].append(lv)
# size is number of bytes, we want size in megs
lvsize = float(size)
@@ -239,16 +238,9 @@ class Partitions:
spec = partRequests.LogicalVolumeRequestSpec(fsystem,
format = format, size = lvsize, volgroup = vgid,
- lvname = lv, mountpoint = mnt, preexist = 1,
- lvorigin = lvorigin)
+ lvname = lv, mountpoint = mnt, preexist = 1)
self.addRequest(spec)
- for origin, snapnames in snapshots.items():
- parent = self.getRequestByLogicalVolumeName(origin)
- for snapname in snapnames:
- child = self.getRequestByLogicalVolumeName(snapname)
- parent.snapshots.append(child)
-
for vg in lvm.partialvgs():
spec = partRequests.PartialVolumeGroupSpec(vgname = vg)
self.addDelete(spec)
@@ -1249,13 +1241,34 @@ class Partitions:
diskset.startAllRaid()
lvm.vgactivate()
+ snapshots = {}
+ for (lvvg, lv, size, lvorigin) in lvm.lvlist():
+ snapshots.setdefault(lv, [])
+ if lvorigin:
+ snapshots.setdefault(lvorigin, [])
+ snapshots[lvorigin].append((lv, lvvg))
+
+ lvm_parent_deletes = []
+ tmp = {}
+ def addSnap(name, vg):
+ snaps = snapshots[name]
+ for snap, snapvg in snaps:
+ addSnap(snap, snapvg)
+ if not tmp.has_key((name, vg)):
+ tmp[(name, vg)] = 1
+ lvm_parent_deletes.append((name,vg))
+
# now, go through and delete logical volumes
for delete in self.deletes:
if isinstance(delete, partRequests.DeleteLogicalVolumeSpec):
if not delete.beenDeleted():
- lvm.lvremove(delete.name, delete.vg)
+ addSnap(delete.name, delete.vg)
delete.setDeleted(1)
+ for name,vg in lvm_parent_deletes:
+ log("removing lv %s" % (name,))
+ lvm.lvremove(name, vg)
+
# now, go through and delete volume groups
for delete in self.deletes:
if isinstance(delete, partRequests.DeleteVolumeGroupSpec):
@@ -1292,8 +1305,6 @@ class Partitions:
self.addDelete(delete)
elif isinstance(req, partRequests.LogicalVolumeRequestSpec):
if id == req.volumeGroup:
- for child in req.snapshots:
- toRemove.append(child)
toRemove.append(req)
tmp = self.getRequestByID(req.volumeGroup)
if not tmp: