Revision 464f8daf

b/lib/backend.py
1124 1124
      clist.append(crdev)
1125 1125

  
1126 1126
  try:
1127
    device = bdev.Create(disk.dev_type, disk.physical_id, clist, size)
1127
    device = bdev.Create(disk.dev_type, disk.physical_id, clist, disk.size)
1128 1128
  except errors.BlockDeviceError, err:
1129 1129
    return False, "Can't create block device: %s" % str(err)
1130 1130

  
......
1234 1234
      children.append(cdev)
1235 1235

  
1236 1236
  if as_primary or disk.AssembleOnSecondary():
1237
    r_dev = bdev.Assemble(disk.dev_type, disk.physical_id, children)
1237
    r_dev = bdev.Assemble(disk.dev_type, disk.physical_id, children, disk.size)
1238 1238
    r_dev.SetSyncSpeed(constants.SYNC_SPEED)
1239 1239
    result = r_dev
1240 1240
    if as_primary or disk.OpenOnSecondary():
......
1404 1404
    for chdisk in disk.children:
1405 1405
      children.append(_RecursiveFindBD(chdisk))
1406 1406

  
1407
  return bdev.FindDevice(disk.dev_type, disk.physical_id, children)
1407
  return bdev.FindDevice(disk.dev_type, disk.physical_id, children, disk.size)
1408 1408

  
1409 1409

  
1410 1410
def BlockdevFind(disk):
b/lib/bdev.py
108 108
  after assembly we'll have our correct major/minor.
109 109

  
110 110
  """
111
  def __init__(self, unique_id, children):
111
  def __init__(self, unique_id, children, size):
112 112
    self._children = children
113 113
    self.dev_path = None
114 114
    self.unique_id = unique_id
115 115
    self.major = None
116 116
    self.minor = None
117 117
    self.attached = False
118
    self.size = size
118 119

  
119 120
  def Assemble(self):
120 121
    """Assemble the device from its components.
......
286 287
  """Logical Volume block device.
287 288

  
288 289
  """
289
  def __init__(self, unique_id, children):
290
  def __init__(self, unique_id, children, size):
290 291
    """Attaches to a LV device.
291 292

  
292 293
    The unique_id is a tuple (vg_name, lv_name)
293 294

  
294 295
    """
295
    super(LogicalVolume, self).__init__(unique_id, children)
296
    super(LogicalVolume, self).__init__(unique_id, children, size)
296 297
    if not isinstance(unique_id, (tuple, list)) or len(unique_id) != 2:
297 298
      raise ValueError("Invalid configuration data %s" % str(unique_id))
298 299
    self._vg_name, self._lv_name = unique_id
......
329 330
    if result.failed:
330 331
      _ThrowError("LV create failed (%s): %s",
331 332
                  result.fail_reason, result.output)
332
    return LogicalVolume(unique_id, children)
333
    return LogicalVolume(unique_id, children, size)
333 334

  
334 335
  @staticmethod
335 336
  def GetPVInfo(vg_name):
......
500 501
    snap_name = self._lv_name + ".snap"
501 502

  
502 503
    # remove existing snapshot if found
503
    snap = LogicalVolume((self._vg_name, snap_name), None)
504
    snap = LogicalVolume((self._vg_name, snap_name), None, size)
504 505
    _IgnoreError(snap.Remove)
505 506

  
506 507
    pvs_info = self.GetPVInfo(self._vg_name)
......
805 806
  # timeout constants
806 807
  _NET_RECONFIG_TIMEOUT = 60
807 808

  
808
  def __init__(self, unique_id, children):
809
  def __init__(self, unique_id, children, size):
809 810
    if children and children.count(None) > 0:
810 811
      children = []
811
    super(DRBD8, self).__init__(unique_id, children)
812
    super(DRBD8, self).__init__(unique_id, children, size)
812 813
    self.major = self._DRBD_MAJOR
813 814
    version = self._GetVersion()
814 815
    if version['k_major'] != 8 :
......
1535 1536
                  aminor, meta)
1536 1537
    cls._CheckMetaSize(meta.dev_path)
1537 1538
    cls._InitMeta(aminor, meta.dev_path)
1538
    return cls(unique_id, children)
1539
    return cls(unique_id, children, size)
1539 1540

  
1540 1541
  def Grow(self, amount):
1541 1542
    """Resize the DRBD device and its backing storage.
......
1559 1560
  The unique_id for the file device is a (file_driver, file_path) tuple.
1560 1561

  
1561 1562
  """
1562
  def __init__(self, unique_id, children):
1563
  def __init__(self, unique_id, children, size):
1563 1564
    """Initalizes a file device backend.
1564 1565

  
1565 1566
    """
1566 1567
    if children:
1567 1568
      raise errors.BlockDeviceError("Invalid setup for file device")
1568
    super(FileStorage, self).__init__(unique_id, children)
1569
    super(FileStorage, self).__init__(unique_id, children, size)
1569 1570
    if not isinstance(unique_id, (tuple, list)) or len(unique_id) != 2:
1570 1571
      raise ValueError("Invalid configuration data %s" % str(unique_id))
1571 1572
    self.driver = unique_id[0]
......
1653 1654
    except IOError, err:
1654 1655
      _ThrowError("Error in file creation: %", str(err))
1655 1656

  
1656
    return FileStorage(unique_id, children)
1657
    return FileStorage(unique_id, children, size)
1657 1658

  
1658 1659

  
1659 1660
DEV_MAP = {
......
1663 1664
  }
1664 1665

  
1665 1666

  
1666
def FindDevice(dev_type, unique_id, children):
1667
def FindDevice(dev_type, unique_id, children, size):
1667 1668
  """Search for an existing, assembled device.
1668 1669

  
1669 1670
  This will succeed only if the device exists and is assembled, but it
......
1672 1673
  """
1673 1674
  if dev_type not in DEV_MAP:
1674 1675
    raise errors.ProgrammerError("Invalid block device type '%s'" % dev_type)
1675
  device = DEV_MAP[dev_type](unique_id, children)
1676
  device = DEV_MAP[dev_type](unique_id, children, size)
1676 1677
  if not device.attached:
1677 1678
    return None
1678 1679
  return device
1679 1680

  
1680 1681

  
1681
def Assemble(dev_type, unique_id, children):
1682
def Assemble(dev_type, unique_id, children, size):
1682 1683
  """Try to attach or assemble an existing device.
1683 1684

  
1684 1685
  This will attach to assemble the device, as needed, to bring it
......
1687 1688
  """
1688 1689
  if dev_type not in DEV_MAP:
1689 1690
    raise errors.ProgrammerError("Invalid block device type '%s'" % dev_type)
1690
  device = DEV_MAP[dev_type](unique_id, children)
1691
  device = DEV_MAP[dev_type](unique_id, children, size)
1691 1692
  device.Assemble()
1692 1693
  return device
1693 1694

  

Also available in: Unified diff