Commit 61cf6b5e authored by Iustin Pop's avatar Iustin Pop
Browse files

Automatically release DRBD minors on success

This patch converts the DRBD minors reservation protocol from explicit
release to automatic release on the success paths. On the errors paths,
it's still needed to manual release.

The patch doesn't bring much by itself, but is needed for a future patch
which enhances the automatic verification of configuration consistency.

Reviewed-by: ultrotter
parent c979d253
......@@ -4566,8 +4566,6 @@ class LUCreateInstance(LogicalUnit):
# Declare that we don't want to remove the instance lock anymore, as we've
# added the instance to the config
del self.remove_locks[locking.LEVEL_INSTANCE]
# Remove the temp. assignements for the instance's drbds
self.cfg.ReleaseDRBDMinors(instance)
# Unlock all the nodes
if self.op.mode == constants.INSTANCE_IMPORT:
nodes_keep = [self.op.src_node]
......@@ -5164,9 +5162,6 @@ class LUReplaceDisks(LogicalUnit):
dev.logical_id = new_logical_id
cfg.SetDiskID(dev, pri_node)
cfg.Update(instance)
# we can remove now the temp minors as now the new values are
# written to the config file (and therefore stable)
self.cfg.ReleaseDRBDMinors(instance.name)
# and now perform the drbd attach
info("attaching primary drbds to new secondary (standalone => connected)")
......
......@@ -478,13 +478,9 @@ class ConfigWriter:
nodes, result)
return result
@locking.ssynchronized(_config_lock)
def ReleaseDRBDMinors(self, instance):
def _UnlockedReleaseDRBDMinors(self, instance):
"""Release temporary drbd minors allocated for a given instance.
This should be called on both the error paths and on the success
paths (after the instance has been added or updated).
@type instance: string
@param instance: the instance for which temporary minors should be
released
......@@ -496,6 +492,23 @@ class ConfigWriter:
if name == instance:
del self._temporary_drbds[key]
@locking.ssynchronized(_config_lock)
def ReleaseDRBDMinors(self, instance):
"""Release temporary drbd minors allocated for a given instance.
This should be called on the error paths, on the success paths
it's automatically called by the ConfigWriter add and update
functions.
This function is just a wrapper over L{_UnlockedReleaseDRBDMinors}.
@type instance: string
@param instance: the instance for which temporary minors should be
released
"""
self._UnlockedReleaseDRBDMinors(instance)
@locking.ssynchronized(_config_lock, shared=1)
def GetConfigVersion(self):
"""Get the configuration version.
......@@ -582,6 +595,7 @@ class ConfigWriter:
instance.serial_no = 1
self._config_data.instances[instance.name] = instance
self._UnlockedReleaseDRBDMinors(instance.name)
self._WriteConfig()
def _SetInstanceStatus(self, instance_name, status):
......@@ -1118,4 +1132,7 @@ class ConfigWriter:
# for node updates, we need to increase the cluster serial too
self._config_data.cluster.serial_no += 1
if isinstance(target, objects.Instance):
self._UnlockedReleaseDRBDMinors(target.name)
self._WriteConfig()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment