diff options
-rw-r--r-- | ChangeLog | 21 | ||||
-rw-r--r-- | anaconda.spec | 1 | ||||
-rw-r--r-- | lvm.py | 44 | ||||
-rw-r--r-- | partRequests.py | 5 | ||||
-rw-r--r-- | partedUtils.py | 4 | ||||
-rw-r--r-- | partitions.py | 22 |
6 files changed, 72 insertions, 25 deletions
@@ -1,5 +1,26 @@ 2005-03-28 Peter Jones <pjones@redhat.com> + * lvm.py (lvlist,vglist,pvlist): make lvm list functions use + a specified separator, explicitly ask for the fields we need, + and get sizes without format specifiers + + * lvm.py (lvlist): list the "origin" of snapshot LVs + + * partRequests.py (LogicalVolumeRequestSpec.__init__): add + "snapshots" and "lvorigin" attributes, so we can track lv + snapshots we need to delete + + * partedUtils.py (DiskSet.findExistingRootPartitions): explictly + ignore snapshot LVs + + * partitions.py (Partitions.setFromDisk): mark snapshot LV requests + with lvorigin, and link snapshots to parents. + + * partitions.py (Partitions.deleteDependentRequests): add snapshot + requests to the delete list when deleting snapshots. + +2005-03-28 Peter Jones <pjones@redhat.com> + * scripts/mk-rescueimage.i386 scripts/mk-rescueimage.x86_64: Make the rescue images identify which arch they're for (#151501) diff --git a/anaconda.spec b/anaconda.spec index 088563f69..b2c3e4589 100644 --- a/anaconda.spec +++ b/anaconda.spec @@ -72,6 +72,7 @@ rm -rf $RPM_BUILD_ROOT * Mon Mar 28 2005 XXX <XXX@redhat.com> - XXX-XXX - Adjust pcmcia module loading for new in-kernel ds (#151235) - Make the rescue images identify which arch they're for (#151501) +- Delete LV snapshots before the parent LV (#151524) * Fri Mar 25 2005 Bill Nottingham <notting@redhat.com> - 10.2.0.33-1 - fix typo in partedUtils.py @@ -207,18 +207,27 @@ def lvlist(): return [] lvs = [] - args = ["lvm", "lvdisplay", "-C", "--noheadings", "--units", "b"] + # field names for "options" are in LVM2.2.01.01/lib/report/columns.h + args = ["lvm", "lvdisplay", "-C", "--noheadings", "--units", "b", + "--nosuffix", "--separator", ":", "--options", + "vg_name,lv_name,lv_size,origin" + ] lvscanout = iutil.execWithCapture(args[0], args, searchPath = 1, stderr = "/dev/tty6") for line in lvscanout.split("\n"): try: - (lv, vg, attr, size) = line.strip()[:-1].split() + (vg, lv, size, origin) = line.strip().split(':') + size = long(math.floor(long(size) / (1024 * 1024))) + if origin == '': + origin = None except: continue - size = long(size) - size = long(math.floor(size / (1024 * 1024))) - log("lv is %s/%s, size of %s" %(vg, lv, size)) - lvs.append( (vg, lv, size) ) + + logmsg = "lv is %s/%s, size of %s" % (vg, lv, size) + if origin: + logmsg += ", snapshot from %s" % (origin,) + log(logmsg) + lvs.append( (vg, lv, size, origin) ) return lvs @@ -228,16 +237,18 @@ def pvlist(): return [] pvs = [] - args = ["lvm", "pvdisplay", "-C", "--noheadings", "--units", "b"] + args = ["lvm", "pvdisplay", "-C", "--noheadings", "--units", "b", + "--nosuffix", "--separator", ":", "--options", + "pv_name,vg_name,dev_size" + ] scanout = iutil.execWithCapture(args[0], args, searchPath = 1, stderr = "/dev/tty6") for line in scanout.split("\n"): try: - (dev, vg, format, attr, size, free) = line.strip()[:-1].split() + (dev, vg, size) = line.strip().split(':') + size = long(math.floor(long(size) / (1024 * 1024))) except: continue - size = long(size[:-1]) - size = long(math.floor(size / (1024 * 1024))) log("pv is %s in vg %s, size is %s" %(dev, vg, size)) pvs.append( (dev, vg, size) ) @@ -249,18 +260,19 @@ def vglist(): return [] vgs = [] - args = ["lvm", "vgdisplay", "-C", "--noheadings", "--units", "b", "-v"] + args = ["lvm", "vgdisplay", "-C", "--noheadings", "--units", "b", + "--nosuffix", "--separator", ":", "--options", + "vg_name,vg_size,vg_extent_size" + ] scanout = iutil.execWithCapture(args[0], args, searchPath = 1, stderr = "/dev/tty6") for line in scanout.split("\n"): try: - (vg, attr, pesize, numpv, numlv, numsn, size, free, uuid) = line.strip().split() + (vg, size, pesize) = line.strip().split(':') + size = long(math.floor(long(size) / (1024 * 1024))) + pesize = long(pesize)/1024 except: continue - size = long(size[:-1]) - size = long(math.floor(size / (1024 * 1024))) - pesize = long(pesize[:-1]) - pesize /= 1024 log("vg %s, size is %s, pesize is %s" %(vg, size, pesize)) vgs.append( (vg, size, pesize) ) diff --git a/partRequests.py b/partRequests.py index 2b9a38ce9..01be85ac5 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): + bytesPerInode = 4096, lvorigin=None): """Create a new VolumeGroupRequestSpec object. fstype is the fsset filesystem type. @@ -812,6 +812,7 @@ 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 @@ -838,6 +839,8 @@ 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/partedUtils.py b/partedUtils.py index e74820a01..b637da08f 100644 --- a/partedUtils.py +++ b/partedUtils.py @@ -615,7 +615,9 @@ class DiskSet: lvm.vgscan() lvm.vgactivate() - for (vg, lv, size) in lvm.lvlist(): + for (vg, lv, size, lvorigin) in lvm.lvlist(): + if lvorigin: + continue dev = "/dev/%s/%s" %(vg, lv) found = 0 for fs in fsset.getFStoTry(dev): diff --git a/partitions.py b/partitions.py index 705300cb2..8fee638a8 100644 --- a/partitions.py +++ b/partitions.py @@ -192,6 +192,7 @@ class Partitions: lvm.vgactivate() pvs = lvm.pvlist() + snapshots = {} for (vg, size, pesize) in lvm.vglist(): try: preexist_size = float(size) @@ -217,9 +218,11 @@ class Partitions: preexist_size = preexist_size) vgid = self.addRequest(spec) - for (lvvg, lv, size) in lvm.lvlist(): + for (lvvg, lv, size, lvorigin) in lvm.lvlist(): if lvvg != vg: continue + snapshots.setdefault(lvorigin, []) + snapshots[lvorigin].append(lv) # size is number of bytes, we want size in megs lvsize = float(size) @@ -235,14 +238,17 @@ class Partitions: format = 0 spec = partRequests.LogicalVolumeRequestSpec(fsystem, - format = format, - size = lvsize, - volgroup = vgid, - lvname = lv, - mountpoint = mnt, - preexist = 1) + format = format, size = lvsize, volgroup = vgid, + lvname = lv, mountpoint = mnt, preexist = 1, + lvorigin = lvorigin) self.addRequest(spec) + for origin, snapnames in snapshots.entries(): + 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) @@ -1286,6 +1292,8 @@ 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: |