Revision 7d585316 lib/bdev.py

b/lib/bdev.py
1056 1056
      # sure its shutdown
1057 1057
      return cls._ShutdownNet(minor)
1058 1058

  
1059
    # Workaround for a race condition. When DRBD is doing its dance to
1060
    # establish a connection with its peer, it also sends the
1061
    # synchronization speed over the wire. In some cases setting the
1062
    # sync speed only after setting up both sides can race with DRBD
1063
    # connecting, hence we set it here before telling DRBD anything
1064
    # about its peer.
1065
    cls._SetMinorSyncSpeed(minor, constants.SYNC_SPEED)
1066

  
1059 1067
    args = ["drbdsetup", cls._DevPath(minor), "net",
1060 1068
            "%s:%s" % (lhost, lport), "%s:%s" % (rhost, rport), protocol,
1061 1069
            "-A", "discard-zero-changes",
......
1145 1153
      raise errors.BlockDeviceError("Can't detach from local storage")
1146 1154
    self._children = []
1147 1155

  
1148
  def SetSyncSpeed(self, kbytes):
1156
  @classmethod
1157
  def _SetMinorSyncSpeed(cls, minor, kbytes):
1149 1158
    """Set the speed of the DRBD syncer.
1150 1159

  
1160
    This is the low-level implementation.
1161

  
1162
    @type minor: int
1163
    @param minor: the drbd minor whose settings we change
1164
    @type kbytes: int
1165
    @param kbytes: the speed in kbytes/second
1166
    @rtype: boolean
1167
    @return: the success of the operation
1168

  
1151 1169
    """
1152
    children_result = super(DRBD8, self).SetSyncSpeed(kbytes)
1153
    if self.minor is None:
1154
      logging.info("Instance not attached to a device")
1155
      return False
1156
    result = utils.RunCmd(["drbdsetup", self.dev_path, "syncer", "-r", "%d" %
1157
                           kbytes])
1170
    result = utils.RunCmd(["drbdsetup", cls._DevPath(minor), "syncer",
1171
                           "-r", "%d" % kbytes, "--create-device"])
1158 1172
    if result.failed:
1159 1173
      logging.error("Can't change syncer rate: %s - %s",
1160 1174
                    result.fail_reason, result.output)
1161
    return not result.failed and children_result
1175
    return not result.failed
1176

  
1177
  def SetSyncSpeed(self, kbytes):
1178
    """Set the speed of the DRBD syncer.
1179

  
1180
    @type kbytes: int
1181
    @param kbytes: the speed in kbytes/second
1182
    @rtype: boolean
1183
    @return: the success of the operation
1184

  
1185
    """
1186
    if self.minor is None:
1187
      logging.info("Not attached during SetSyncSpeed")
1188
      return False
1189
    children_result = super(DRBD8, self).SetSyncSpeed(kbytes)
1190
    return self._SetMinorSyncSpeed(self.minor, kbytes) and children_result
1162 1191

  
1163 1192
  def GetProcStatus(self):
1164 1193
    """Return device data from /proc.

Also available in: Unified diff