Re: [PATCH] Make sure we use 1.0 mdraid metadata when the set is used for boot (#584596)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Looks good.

On Thu, 2010-04-22 at 21:39 +0200, Hans de Goede wrote:
> ---
>  storage/devices.py    |   50 +++++++++++++++++++++++++++++-------------------
>  storage/devicetree.py |    5 ++-
>  2 files changed, 33 insertions(+), 22 deletions(-)
> 
> diff --git a/storage/devices.py b/storage/devices.py
> index a990708..33e8c5e 100644
> --- a/storage/devices.py
> +++ b/storage/devices.py
> @@ -2409,7 +2409,7 @@ class MDRaidArrayDevice(StorageDevice):
>      _type = "mdarray"
>  
>      def __init__(self, name, level=None, major=None, minor=None, size=None,
> -                 memberDevices=None, totalDevices=None, bitmap=False,
> +                 memberDevices=None, totalDevices=None,
>                   uuid=None, format=None, exists=None,
>                   parents=None, sysfsPath=''):
>          """ Create a MDRaidArrayDevice instance.
> @@ -2425,7 +2425,6 @@ class MDRaidArrayDevice(StorageDevice):
>                  size -- the device's size (units/format TBD)
>                  uuid -- the device's UUID
>                  minor -- the device minor
> -                bitmap -- whether to use a bitmap (boolean)
>                  sysfsPath -- sysfs device path
>                  format -- a DeviceFormat instance
>                  exists -- indicates whether this is an existing device
> @@ -2455,16 +2454,16 @@ class MDRaidArrayDevice(StorageDevice):
>          self.chunkSize = 64.0 / 1024.0          # chunk size in MB
>          self.superBlockSize = 128.0 / 1024.0    # superblock size in MB
>  
> +        self.createMetadataVer = "1.1"
> +        # bitmaps are not meaningful on raid0 according to mdadm-3.0.3
> +        self.createBitmap = self.level != 0
> +
>          # For container members probe size now, as we cannot determine it
>          # when teared down.
>          if self.parents and self.parents[0].type == "mdcontainer":
>              self._size = self.currentSize
>              self._type = "mdbiosraidarray"
>  
> -        # FIXME: Bitmap is more complicated than this.
> -        # It can be internal or external. External requires a filename.
> -        self.bitmap = bitmap
> -
>          self.formatClass = get_device_format_class("mdmember")
>          if not self.formatClass:
>              raise DeviceError("cannot find class for 'mdmember'", self.name)
> @@ -2536,17 +2535,17 @@ class MDRaidArrayDevice(StorageDevice):
>  
>      def __str__(self):
>          s = StorageDevice.__str__(self)
> -        s += ("  level = %(level)s  bitmap = %(bitmap)s  spares = %(spares)s\n"
> +        s += ("  level = %(level)s  spares = %(spares)s\n"
>                "  members = %(memberDevices)s\n"
>                "  total devices = %(totalDevices)s" %
> -              {"level": self.level, "bitmap": self.bitmap, "spares": self.spares,
> +              {"level": self.level, "spares": self.spares,
>                 "memberDevices": self.memberDevices, "totalDevices": self.totalDevices})
>          return s
>  
>      @property
>      def dict(self):
>          d = super(MDRaidArrayDevice, self).dict
> -        d.update({"level": self.level, "bitmap": self.bitmap,
> +        d.update({"level": self.level,
>                    "spares": self.spares, "memberDevices": self.memberDevices,
>                    "totalDevices": self.totalDevices})
>          return d
> @@ -2814,6 +2813,26 @@ class MDRaidArrayDevice(StorageDevice):
>          if recursive:
>              self.teardownParents(recursive=recursive)
>  
> +    def preCommitFixup(self, *args, **kwargs):
> +        """ Determine create parameters for this set """
> +        mountpoints = kwargs.pop("mountpoints")
> +        log_method_call(self, self.name, mountpoints)
> +
> +        if "/boot" in mountpoints:
> +            bootmountpoint = "/boot"
> +        else:
> +            bootmountpoint = "/"
> +
> +        # If we are used to boot from we cannot use 1.1 metadata
> +        if getattr(self.format, "mountpoint", None) == bootmountpoint or \
> +           getattr(self.format, "mountpoint", None) == "/boot/efi" or \
> +           self.format.type == "prepboot":
> +            self.createMetadataVer = "1.0"
> +
> +        # Bitmaps are not useful for swap and small partitions
> +        if self.size < 1000 or self.format.type == "swap":
> +            self.createBitmap = False
> +
>      def create(self, intf=None):
>          """ Create the device. """
>          log_method_call(self, self.name, status=self.status)
> @@ -2832,21 +2851,12 @@ class MDRaidArrayDevice(StorageDevice):
>  
>              disks = [disk.path for disk in self.devices]
>              spares = len(self.devices) - self.memberDevices
> -            # Figure out format specific options
> -            metadata="1.1"
> -            # bitmaps are not meaningful on raid0 according to mdadm-3.0.3
> -            bitmap = self.level != 0
> -            if getattr(self.format, "mountpoint", None) == "/boot":
> -                metadata="1.0"
> -                bitmap=False
> -            elif self.format.type == "swap":
> -                bitmap=False
>              mdraid.mdcreate(self.path,
>                              self.level,
>                              disks,
>                              spares,
> -                            metadataVer=metadata,
> -                            bitmap=bitmap,
> +                            metadataVer=self.createMetadataVer,
> +                            bitmap=self.createBitmap,
>                              progress=w)
>          except Exception:
>              raise
> diff --git a/storage/devicetree.py b/storage/devicetree.py
> index 0bc07e5..a128f55 100644
> --- a/storage/devicetree.py
> +++ b/storage/devicetree.py
> @@ -632,14 +632,15 @@ class DeviceTree(object):
>                      device.originalFormat.resetPartedDisk()
>  
>          # Call preCommitFixup on all devices
> +        mpoints = [getattr(d.format, 'mountpoint', "") for d in self.devices]
>          for device in self.devices:
> -            device.preCommitFixup()
> +            device.preCommitFixup(mountpoints=mpoints)
>  
>          # Also call preCommitFixup on any devices we're going to
>          # destroy (these are already removed from the tree)
>          for action in self._actions:
>              if isinstance(action, ActionDestroyDevice):
> -                action.device.preCommitFixup()
> +                action.device.preCommitFixup(mountpoints=mpoints)
>  
>          # setup actions to create any extended partitions we added
>          #


_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux