"""
raise NotImplementedError
- def SetSyncSpeed(self, speed):
- """Adjust the sync speed of the mirror.
+ def SetSyncParams(self, params):
+ """Adjust the synchronization parameters of the mirror.
In case this is not a mirroring device, this is no-op.
+ @param params: dictionary of LD level disk parameters related to the
+ synchronization.
+
"""
result = True
if self._children:
for child in self._children:
- result = result and child.SetSyncSpeed(speed)
+ result = result and child.SetSyncParams(params)
return result
def PauseResumeSync(self, pause):
In case this is not a mirroring device, this is no-op.
- @param pause: Wheater to pause or resume
+ @param pause: Whether to pause or resume
"""
result = True
# sync speed only after setting up both sides can race with DRBD
# connecting, hence we set it here before telling DRBD anything
# about its peer.
- sync_speed = self.params.get(constants.LDP_RESYNC_RATE)
- self._SetMinorSyncSpeed(minor, sync_speed)
+ self._SetMinorSyncParams(minor, self.params)
if netutils.IP6Address.IsValid(lhost):
if not netutils.IP6Address.IsValid(rhost):
self._children = []
@classmethod
- def _SetMinorSyncSpeed(cls, minor, kbytes):
- """Set the speed of the DRBD syncer.
+ def _SetMinorSyncParams(cls, minor, params):
+ """Set the parameters of the DRBD syncer.
This is the low-level implementation.
@type minor: int
@param minor: the drbd minor whose settings we change
- @type kbytes: int
- @param kbytes: the speed in kbytes/second
+ @type params: dict
+ @param params: LD level disk parameters related to the synchronization
@rtype: boolean
@return: the success of the operation
"""
- result = utils.RunCmd(["drbdsetup", cls._DevPath(minor), "syncer",
- "-r", "%d" % kbytes, "--create-device"])
+
+ args = ["drbdsetup", cls._DevPath(minor), "syncer"]
+ if params[constants.LDP_DYNAMIC_RESYNC]:
+ version = cls._GetVersion(cls._GetProcData())
+ vmin = version["k_minor"]
+ vrel = version["k_point"]
+
+ # By definition we are using 8.x, so just check the rest of the version
+ # number
+ if vmin != 3 or vrel < 9:
+ logging.error("The current DRBD version (8.%d.%d) does not support the"
+ " dynamic resync speed controller", vmin, vrel)
+ return False
+
+ # add the c-* parameters to args
+ # TODO(spadaccio) use the actual parameters
+ args.extend(["--c-plan-ahead", "20"])
+
+ else:
+ args.extend(["-r", "%d" % params[constants.LDP_RESYNC_RATE]])
+
+ args.append("--create-device")
+ result = utils.RunCmd(args)
if result.failed:
logging.error("Can't change syncer rate: %s - %s",
result.fail_reason, result.output)
return not result.failed
- def SetSyncSpeed(self, kbytes):
- """Set the speed of the DRBD syncer.
+ def SetSyncParams(self, params):
+ """Set the synchronization parameters of the DRBD syncer.
- @type kbytes: int
- @param kbytes: the speed in kbytes/second
+ @type params: dict
+ @param params: LD level disk parameters related to the synchronization
@rtype: boolean
@return: the success of the operation
"""
if self.minor is None:
- logging.info("Not attached during SetSyncSpeed")
+ logging.info("Not attached during SetSyncParams")
return False
- children_result = super(DRBD8, self).SetSyncSpeed(kbytes)
- return self._SetMinorSyncSpeed(self.minor, kbytes) and children_result
+ children_result = super(DRBD8, self).SetSyncParams(params)
+ return self._SetMinorSyncParams(self.minor, params) and children_result
def PauseResumeSync(self, pause):
"""Pauses or resumes the sync of a DRBD device.
# the device
self._SlowAssemble()
- sync_speed = self.params.get(constants.LDP_RESYNC_RATE)
- self.SetSyncSpeed(sync_speed)
+ self.SetSyncParams(self.params)
def _SlowAssemble(self):
"""Assembles the DRBD device from a (partially) configured device.
LDP_DEFAULT_METAVG = "default-metavg"
LDP_DISK_CUSTOM = "disk-custom"
LDP_NET_CUSTOM = "net-custom"
+LDP_DYNAMIC_RESYNC = "dynamic-resync"
DISK_LD_TYPES = {
LDP_RESYNC_RATE: VTYPE_INT,
LDP_STRIPES: VTYPE_INT,
LDP_DEFAULT_METAVG: VTYPE_STRING,
LDP_DISK_CUSTOM: VTYPE_STRING,
LDP_NET_CUSTOM: VTYPE_STRING,
+ LDP_DYNAMIC_RESYNC: VTYPE_BOOL,
}
DISK_LD_PARAMETERS = frozenset(DISK_LD_TYPES.keys())
-# Disk template parameters
+# Disk template parameters (can be set/changed by the user via gnt-cluster and
+# gnt-group)
DRBD_RESYNC_RATE = "resync-rate"
DRBD_DATA_STRIPES = "data-stripes"
DRBD_META_STRIPES = "meta-stripes"
DRBD_DEFAULT_METAVG = "metavg"
DRBD_DISK_CUSTOM = "disk-custom"
DRBD_NET_CUSTOM = "net-custom"
+DRBD_DYNAMIC_RESYNC = "dynamic-resync"
LV_STRIPES = "stripes"
DISK_DT_TYPES = {
DRBD_RESYNC_RATE: VTYPE_INT,
DRBD_DEFAULT_METAVG: VTYPE_STRING,
DRBD_DISK_CUSTOM: VTYPE_STRING,
DRBD_NET_CUSTOM: VTYPE_STRING,
+ DRBD_DYNAMIC_RESYNC: VTYPE_BOOL,
LV_STRIPES: VTYPE_INT,
}
LDP_DEFAULT_METAVG: DEFAULT_VG,
LDP_DISK_CUSTOM: "",
LDP_NET_CUSTOM: "",
+ LDP_DYNAMIC_RESYNC: False,
},
LD_LV: {
LDP_STRIPES: _autoconf.LVM_STRIPECOUNT
DRBD_DEFAULT_METAVG: DISK_LD_DEFAULTS[LD_DRBD8][LDP_DEFAULT_METAVG],
DRBD_DISK_CUSTOM: DISK_LD_DEFAULTS[LD_DRBD8][LDP_DISK_CUSTOM],
DRBD_NET_CUSTOM: DISK_LD_DEFAULTS[LD_DRBD8][LDP_NET_CUSTOM],
+ DRBD_DYNAMIC_RESYNC: DISK_LD_DEFAULTS[LD_DRBD8][LDP_DYNAMIC_RESYNC],
},
DT_DISKLESS: {
},