diff --git a/lib/backend.py b/lib/backend.py index 54dc0237e354a0f64496c28271472aedca725eed..68dcf7f66ebb78bea6b20828e7ff8d5c89daa82e 100644 --- a/lib/backend.py +++ b/lib/backend.py @@ -1124,7 +1124,7 @@ def BlockdevCreate(disk, size, owner, on_primary, info): clist.append(crdev) try: - device = bdev.Create(disk.dev_type, disk.physical_id, clist, size) + device = bdev.Create(disk.dev_type, disk.physical_id, clist, disk.size) except errors.BlockDeviceError, err: return False, "Can't create block device: %s" % str(err) @@ -1234,7 +1234,7 @@ def _RecursiveAssembleBD(disk, owner, as_primary): children.append(cdev) if as_primary or disk.AssembleOnSecondary(): - r_dev = bdev.Assemble(disk.dev_type, disk.physical_id, children) + r_dev = bdev.Assemble(disk.dev_type, disk.physical_id, children, disk.size) r_dev.SetSyncSpeed(constants.SYNC_SPEED) result = r_dev if as_primary or disk.OpenOnSecondary(): @@ -1404,7 +1404,7 @@ def _RecursiveFindBD(disk): for chdisk in disk.children: children.append(_RecursiveFindBD(chdisk)) - return bdev.FindDevice(disk.dev_type, disk.physical_id, children) + return bdev.FindDevice(disk.dev_type, disk.physical_id, children, disk.size) def BlockdevFind(disk): diff --git a/lib/bdev.py b/lib/bdev.py index 9d3f08b096e3c71fa215f1a268313fc483e1b26a..af4f4079ded987fbfac9d2ef94ac68bf95083b87 100644 --- a/lib/bdev.py +++ b/lib/bdev.py @@ -108,13 +108,14 @@ class BlockDev(object): after assembly we'll have our correct major/minor. """ - def __init__(self, unique_id, children): + def __init__(self, unique_id, children, size): self._children = children self.dev_path = None self.unique_id = unique_id self.major = None self.minor = None self.attached = False + self.size = size def Assemble(self): """Assemble the device from its components. @@ -286,13 +287,13 @@ class LogicalVolume(BlockDev): """Logical Volume block device. """ - def __init__(self, unique_id, children): + def __init__(self, unique_id, children, size): """Attaches to a LV device. The unique_id is a tuple (vg_name, lv_name) """ - super(LogicalVolume, self).__init__(unique_id, children) + super(LogicalVolume, self).__init__(unique_id, children, size) if not isinstance(unique_id, (tuple, list)) or len(unique_id) != 2: raise ValueError("Invalid configuration data %s" % str(unique_id)) self._vg_name, self._lv_name = unique_id @@ -329,7 +330,7 @@ class LogicalVolume(BlockDev): if result.failed: _ThrowError("LV create failed (%s): %s", result.fail_reason, result.output) - return LogicalVolume(unique_id, children) + return LogicalVolume(unique_id, children, size) @staticmethod def GetPVInfo(vg_name): @@ -500,7 +501,7 @@ class LogicalVolume(BlockDev): snap_name = self._lv_name + ".snap" # remove existing snapshot if found - snap = LogicalVolume((self._vg_name, snap_name), None) + snap = LogicalVolume((self._vg_name, snap_name), None, size) _IgnoreError(snap.Remove) pvs_info = self.GetPVInfo(self._vg_name) @@ -805,10 +806,10 @@ class DRBD8(BaseDRBD): # timeout constants _NET_RECONFIG_TIMEOUT = 60 - def __init__(self, unique_id, children): + def __init__(self, unique_id, children, size): if children and children.count(None) > 0: children = [] - super(DRBD8, self).__init__(unique_id, children) + super(DRBD8, self).__init__(unique_id, children, size) self.major = self._DRBD_MAJOR version = self._GetVersion() if version['k_major'] != 8 : @@ -1535,7 +1536,7 @@ class DRBD8(BaseDRBD): aminor, meta) cls._CheckMetaSize(meta.dev_path) cls._InitMeta(aminor, meta.dev_path) - return cls(unique_id, children) + return cls(unique_id, children, size) def Grow(self, amount): """Resize the DRBD device and its backing storage. @@ -1559,13 +1560,13 @@ class FileStorage(BlockDev): The unique_id for the file device is a (file_driver, file_path) tuple. """ - def __init__(self, unique_id, children): + def __init__(self, unique_id, children, size): """Initalizes a file device backend. """ if children: raise errors.BlockDeviceError("Invalid setup for file device") - super(FileStorage, self).__init__(unique_id, children) + super(FileStorage, self).__init__(unique_id, children, size) if not isinstance(unique_id, (tuple, list)) or len(unique_id) != 2: raise ValueError("Invalid configuration data %s" % str(unique_id)) self.driver = unique_id[0] @@ -1653,7 +1654,7 @@ class FileStorage(BlockDev): except IOError, err: _ThrowError("Error in file creation: %", str(err)) - return FileStorage(unique_id, children) + return FileStorage(unique_id, children, size) DEV_MAP = { @@ -1663,7 +1664,7 @@ DEV_MAP = { } -def FindDevice(dev_type, unique_id, children): +def FindDevice(dev_type, unique_id, children, size): """Search for an existing, assembled device. This will succeed only if the device exists and is assembled, but it @@ -1672,13 +1673,13 @@ def FindDevice(dev_type, unique_id, children): """ if dev_type not in DEV_MAP: raise errors.ProgrammerError("Invalid block device type '%s'" % dev_type) - device = DEV_MAP[dev_type](unique_id, children) + device = DEV_MAP[dev_type](unique_id, children, size) if not device.attached: return None return device -def Assemble(dev_type, unique_id, children): +def Assemble(dev_type, unique_id, children, size): """Try to attach or assemble an existing device. This will attach to assemble the device, as needed, to bring it @@ -1687,7 +1688,7 @@ def Assemble(dev_type, unique_id, children): """ if dev_type not in DEV_MAP: raise errors.ProgrammerError("Invalid block device type '%s'" % dev_type) - device = DEV_MAP[dev_type](unique_id, children) + device = DEV_MAP[dev_type](unique_id, children, size) device.Assemble() return device