David Lehman wrote:
On Fri, 2009-04-10 at 15:24 +0200, Jacek Danecki wrote:
This patch add activation of MD container and add disk to the container.
Tell me again why you couldn't create a separate class for these
containers?
We are awfully late in the F11 development cycle to be changing so much
of the MDRaidArrayDevice behavior so drastically.
I've created new class MDRaidContainerDevice for isw md containers.
This class set variable _type as "mdcontainer", and containers are not displayed
in the list of the devices anymore. Only isw md array are displayed as a "Hard Drives".
This is similar to how DM isw devices are shown.
To make this possible name of devDir was changes to /dev/md.
Name of container is created as imsm[number].
Container path can be for example /dev/md/imsm0
See -- if you created a subclass for your containers you could do this
without disrupting the already-working mdraid class.
I'm changing only class MDRaidContainerDevice, so devDir in MDRaidArrayDevice
is not changed now.
Name of the native format array is changed from md[number] to [number] only.
Array path can be for example /dev/md/0
So now regular md devices' names will be '0' and '1'? Not acceptable.
You are breaking the connection between device name and device path.
For regular md devices I don't change names in this patch.
Function mdraid.mdadd_no_degraded is use only for adding first member to the array.
It is needed for isw format. For the next disks function md_array._addDevice is used in
other path.
This belongs in the Device class, not in the devicetree. The
storage.devicelibs modules are meant to be used by the Device classes.
It was moved to function addFirstDevice in MDRaidContainerDevice class.
sysfsPath is set correctly since container has been created.
commit 2984043d36a6a0306a6b9a9524e3a77d50c95a69
Author: Jacek Danecki <Jacek.Danecki@xxxxxxxxx>
Date: Tue Apr 14 13:32:36 2009 -0400
activate mdmember
diff --git a/storage/devices.py b/storage/devices.py
index 080cd7f..66947fc 100644
--- a/storage/devices.py
+++ b/storage/devices.py
@@ -2369,6 +2369,42 @@ class MDRaidArrayDevice(StorageDevice):
# real work, but it isn't our place to do it from here.
self.exists = False
+class MDRaidContainerDevice(MDRaidArrayDevice):
+ """ An mdraid container device.
+ """
+ _type = "mdcontainer"
+ _devDir = "/dev/md"
+
+ def __init__(self, name, level=None, minor=None, size=None,
+ memberDevices=None, totalDevices=None, bitmap=False,
+ uuid=None, format=None, exists=None,
+ parents=None, sysfsPath=''):
+ """ Create a MDRaidContainerDevice instance.
+
+ Arguments:
+
+ name -- the device name (generally a device node's basename)
+
+ Keyword Arguments:
+
+ level -- the device's RAID level (a string, eg: '1' or 'raid1')
+ parents -- list of member devices (StorageDevice instances)
+ 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
+ """
+ MDRaidArrayDevice.__init__(self, name, format=format, exists=exists,
+ minor=minor, size=size, uuid=uuid,
+ parents=parents, sysfsPath=sysfsPath)
+
+ def addFirstDevice(self, path):
+ mdraid.mdadd_no_degraded(path)
+ real=os.readlink(self.path).split('/')[1]
+ self.sysfsPath = "/devices/virtual/block/%s" % real
class DMRaidArrayDevice(DiskDevice):
""" A dmraid (device-mapper RAID) device """
diff --git a/storage/devicetree.py b/storage/devicetree.py
index 741f5ab..03fd1f8 100644
--- a/storage/devicetree.py
+++ b/storage/devicetree.py
@@ -945,6 +945,12 @@ class DeviceTree(object):
return device
+ def md_is_container(self, md_level):
+ if md_level == "container":
+ return True
+ else:
+ return False
+
def addUdevMDDevice(self, info):
name = udev_device_get_name(info)
log_method_call(self, name=name)
@@ -1299,29 +1305,51 @@ class DeviceTree(object):
except (KeyError, ValueError) as e:
log.warning("invalid data for %s: %s" % (name, e))
return
+
+ if self.md_is_container(md_level):
+ minor = 0
+ while True:
+ if self.getDeviceByName("imsm%d" % minor):
+ minor += 1
+ else:
+ break
+ md_name = "imsm%d" % minor
+ md_array = MDRaidContainerDevice(md_name,
+ level=md_level,
+ minor=minor,
+ memberDevices=md_devices,
+ uuid=md_uuid,
+ sysfsPath=sysfs_path,
+ exists=True,
+ parents=[device])
+ try:
+ md_array.addFirstDevice(device.path)
+ except MDRaidError as e:
+ log.warning("failed to add member to md array %s" % e)
- # find the first unused minor
- minor = 0
- while True:
- if self.getDeviceByName("md%d" % minor):
- minor += 1
- else:
- break
-
- md_name = "md%d" % minor
- md_array = MDRaidArrayDevice(md_name,
- level=md_level,
- minor=minor,
- memberDevices=md_devices,
- uuid=md_uuid,
- sysfsPath=sysfs_path,
- exists=True,
- parents=[device])
- try:
- md_array.setup()
- except (DeviceError, MDRaidError) as e:
- log.info("setup of md array %s failed: %s"
- % (md_array.name, e))
+ else:
+ # find the first unused minor
+ minor = 0
+ while True:
+ if self.getDeviceByName("md%d" % minor):
+ minor += 1
+ else:
+ break
+ md_name = "md%d" % minor
+
+ md_array = MDRaidArrayDevice(md_name,
+ level=md_level,
+ minor=minor,
+ memberDevices=md_devices,
+ uuid=md_uuid,
+ sysfsPath=sysfs_path,
+ exists=True,
+ parents=[device])
+ try:
+ md_array.setup()
+ except (DeviceError, MDRaidError) as e:
+ log.info("setup of md array %s failed: %s"
+ % (md_array.name, e))
self._addDevice(md_array)
def handleUdevDMRaidMemberFormat(self, info, device):
_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list