[blivet:master 14/16] Refine BTRFSVolumeDevice._removeParent() method.

Anne Mulhern amulhern at redhat.com
Wed May 7 12:28:13 UTC 2014





----- Original Message -----
> From: "Vratislav Podzimek" <vpodzime at redhat.com>
> To: "anaconda patch review" <anaconda-patches at lists.fedorahosted.org>
> Sent: Wednesday, May 7, 2014 3:37:39 AM
> Subject: Re: [blivet:master 14/16] Refine BTRFSVolumeDevice._removeParent()	method.
> 
> On Tue, 2014-05-06 at 12:42 -0400, mulhern wrote:
> > Now that LinearRAID("single") is a RAID level it is possible to eliminate
> > special cases. Should be semantics preserving as LinearRAID.min_members is
> > 0.
> > 
> > Signed-off-by: mulhern <amulhern at redhat.com>
> > ---
> >  blivet/devices.py | 26 ++++++++++----------------
> >  1 file changed, 10 insertions(+), 16 deletions(-)
> > 
> > diff --git a/blivet/devices.py b/blivet/devices.py
> > index 8a2d838..89548b2 100644
> > --- a/blivet/devices.py
> > +++ b/blivet/devices.py
> > @@ -4618,22 +4618,16 @@ class BTRFSVolumeDevice(BTRFSDevice,
> > ContainerDevice):
> >          return size
> >  
> >      def _removeParent(self, member):
> > -        # btrfs won't let you degrade it
> > -        limits = []
> > -        levels = btrfs.RAID_levels
> > -        if self.dataLevel and self.dataLevel != "single":
> > -            limits.append(levels.raidLevel(self.dataLevel).min_members)
> > -
> > -        if self.metaDataLevel and self.metaDataLevel != "single":
> > -
> > limits.append(levels.raidLevel(self.metaDataLevel).min_members)
> > -
> > -        if limits:
> > -            min_members = min(limits)
> > -
> > -        if limits and len(self.parents) - 1 < min_members:
> > -            raise errors.DeviceError("cannot remove member due to raid
> > level "
> > -                              "constraints")
> > -
> > +        """ Raises a DeviceError if the device has a raid level and the
> > +            resulting number of parents would be fewer than the minimum
> > +            number required by the raid level.
> > +        """
> > +        levels = [btrfs.RAID_levels.raidLevel(l) for l in [self.dataLevel,
> > self.metaDataLevel] if l]
> > +        if levels:
> > +            min_level = min((l for l in levels), key=lambda l:
> > l.min_members)
> What is the point of this generator ^^^? Could it be 'min(levels, ...)'?
> 
> --
> Vratislav Podzimek
> 
> Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic
> 
> _______________________________________________
> anaconda-patches mailing list
> anaconda-patches at lists.fedorahosted.org
> https://lists.fedorahosted.org/mailman/listinfo/anaconda-patches
> 

None whatsoever :) Fixed in working copy.

- mulhern


More information about the anaconda-patches mailing list