[PATCH 09/17] Add Device classes for snapshots.
Vratislav Podzimek
vpodzime at redhat.com
Fri Jun 6 07:16:47 UTC 2014
On Fri, 2014-06-06 at 09:02 +0200, Vratislav Podzimek wrote:
> On Thu, 2014-06-05 at 11:47 -0500, David Lehman wrote:
> > ---
> > blivet/devices.py | 321 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
> > 1 file changed, 317 insertions(+), 4 deletions(-)
> >
> > diff --git a/blivet/devices.py b/blivet/devices.py
> > index 2e911f8..53a1234 100644
> > --- a/blivet/devices.py
> > +++ b/blivet/devices.py
> > @@ -2537,6 +2537,11 @@ class LVMVolumeGroupDevice(ContainerDevice):
> > log.debug("Adding %s/%s to %s", lv.name, lv.size, self.name)
> > self._lvs.append(lv)
> >
> > + # snapshot accounting
> > + origin = getattr(lv, "origin", None)
> > + if origin:
> > + origin.snapshots.append(lv)
> > +
> > def _removeLogVol(self, lv):
> > """ Remove an LV from this VG. """
> > if lv not in self.lvs:
> > @@ -2547,6 +2552,11 @@ class LVMVolumeGroupDevice(ContainerDevice):
> > if self.poolMetaData and not self.thinpools:
> > self.poolMetaData = 0
> >
> > + # snapshot accounting
> > + origin = getattr(lv, "origin", None)
> > + if origin:
> > + origin.snapshots.remove(lv)
> > +
> > def _addParent(self, member):
> > super(LVMVolumeGroupDevice, self)._addParent(member)
> >
> > @@ -2800,6 +2810,7 @@ class LVMLogicalVolumeDevice(DMDevice):
> > self.metaDataSize = 0
> > self.singlePV = singlePV
> > self.segType = segType or "linear"
> > + self.snapshots = []
> >
> > self.req_grow = None
> > self.req_max_size = Size(0)
> > @@ -3013,6 +3024,15 @@ class LVMLogicalVolumeDevice(DMDevice):
> > udev.udev_settle()
> > lvm.lvresize(self.vg.name, self._name, self.size)
> >
> > + @property
> > + def isleaf(self):
> > + # Thin snapshots do not need to be removed prior to removal of the
> > + # origin, but the old snapshots do.
> > + non_thin_snapshots = any(s for s in self.snapshots
> > + if not isinstance(s, LVMThinSnapShotDevice))
> > + return (super(LVMLogicalVolumeDevice, self).isleaf and
> > + not non_thin_snapshots)
> > +
> > def dracutSetupArgs(self):
> > # Note no mapName usage here, this is a lvm cmdline name, which
> > # is different (ofcourse)
> > @@ -3080,6 +3100,165 @@ class LVMLogicalVolumeDevice(DMDevice):
> >
> > return True
> >
> > +class LVMSnapShotBase(object):
> Do we consider "shot" a standalone word/part of "snapshot"? I think
> LVMSnapshotBase makes more sense than LVMSnapShotBase.
>
> > + """ Abstract base class for lvm snapshots
> > +
> > + This class is intended to be used with multiple inheritance in addition
> > + to some subclass of :class:`~.StorageDevice`.
> > +
> > + Snapshots do not have their origin/source volume as parent. They are
> > + like other LVs except that they have an origin attribute and are in that
> > + instance's snapshots list.
> > +
> > + Normal/old snapshots must be removed with their origin, while thin
> > + snapshots can remain after their origin is removed.
> > +
> > + It is also impossible to set the format for a snapshot explicitly as it
> > + always has the same format as its origin.
> > + """
> > + _type = "lvmsnapshotbase"
> > + __metaclass__ = abc.ABCMeta
> > +
> > + def __init__(self, origin=None, vorigin=False, exists=False):
> I believe I know quite something about LVM snapshots, but I have no idea
> what 'vorigin' here stands for. Maybe a better name for it? Or at least
> a docstring would be welcome.
Okay, now that I've searched for 'vorigin' in lvcreate(8) I think
there's no better name for the parameter. But still I believe it
deserves a docstring.
--
Vratislav Podzimek
Anaconda Rider | RHCE | Red Hat, Inc. | Brno - Czech Republic
More information about the anaconda-patches
mailing list