Revision 3b559640

b/lib/bdev.py
848 848
    return highest + 1
849 849

  
850 850
  @classmethod
851
  def _IsValidMeta(cls, meta_device):
852
    """Check if the given meta device looks like a valid one.
853

  
854
    """
855
    minor = cls._FindUnusedMinor()
856
    minor_path = cls._DevPath(minor)
857
    result = utils.RunCmd(["drbdmeta", minor_path,
858
                           "v08", meta_device, "0",
859
                           "dstate"])
860
    if result.failed:
861
      logging.error("Invalid meta device %s: %s", meta_device, result.output)
862
      return False
863
    return True
864

  
865
  @classmethod
866 851
  def _GetShowParser(cls):
867 852
    """Return a parser for `drbd show` output.
868 853

  
......
1023 1008
  def _AssembleLocal(cls, minor, backend, meta):
1024 1009
    """Configure the local part of a DRBD device.
1025 1010

  
1026
    This is the first thing that must be done on an unconfigured DRBD
1027
    device. And it must be done only once.
1028

  
1029 1011
    """
1030
    if not cls._IsValidMeta(meta):
1031
      return False
1032 1012
    args = ["drbdsetup", cls._DevPath(minor), "disk",
1033 1013
            backend, meta, "0", "-e", "detach", "--create-device"]
1034 1014
    result = utils.RunCmd(args)
......
1109 1089
    if not self._CheckMetaSize(meta.dev_path):
1110 1090
      raise errors.BlockDeviceError("Invalid meta device size")
1111 1091
    self._InitMeta(self._FindUnusedMinor(), meta.dev_path)
1112
    if not self._IsValidMeta(meta.dev_path):
1113
      raise errors.BlockDeviceError("Cannot initalize meta device")
1114 1092

  
1115 1093
    if not self._AssembleLocal(self.minor, backend.dev_path, meta.dev_path):
1116 1094
      raise errors.BlockDeviceError("Can't attach to local storage")
......
1551 1529
      raise errors.BlockDeviceError("Can't attach to meta device")
1552 1530
    if not cls._CheckMetaSize(meta.dev_path):
1553 1531
      raise errors.BlockDeviceError("Invalid meta device size")
1554
    cls._InitMeta(cls._FindUnusedMinor(), meta.dev_path)
1555
    if not cls._IsValidMeta(meta.dev_path):
1556
      raise errors.BlockDeviceError("Cannot initalize meta device")
1532
    cls._InitMeta(aminor, meta.dev_path)
1557 1533
    return cls(unique_id, children)
1558 1534

  
1559 1535
  def Grow(self, amount):
b/lib/cmdlib.py
4726 4726
        raise errors.OpPrereqError("Node '%s' not known" %
4727 4727
                                   self.op.remote_node)
4728 4728
      self.op.remote_node = remote_node
4729
      # Warning: do not remove the locking of the new secondary here
4730
      # unless DRBD8.AddChildren is changed to work in parallel;
4731
      # currently it doesn't since parallel invocations of
4732
      # FindUnusedMinor will conflict
4729 4733
      self.needed_locks[locking.LEVEL_NODE] = [remote_node]
4730 4734
      self.recalculate_locks[locking.LEVEL_NODE] = constants.LOCKS_APPEND
4731 4735
    else:

Also available in: Unified diff