Commit 1bee66f3 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

Release unneeded locks while replacing disks

If an iallocator is used, “gnt-instance replace-disks” would acquire the
locks of all nodes (only the allocator will decide which node to use).
Unfortunately the unneeded locks were not released during the operation,
causing unnecessary delays for other jobs.

This patch changes the LU to release unneeded locks and adds assertions.
Signed-off-by: default avatarMichael Hanselmann <>
Reviewed-by: default avatarIustin Pop <>
parent 07cba1bc
......@@ -8189,6 +8189,15 @@ class TLReplaceDisks(Tasklet):
for node in check_nodes:
_CheckNodeOnline(, node)
touched_nodes = frozenset([self.new_node, self.other_node,
if[locking.LEVEL_NODE] == locking.ALL_SET:
# Release unneeded node locks
for name in[locking.LEVEL_NODE]:
if name not in touched_nodes:
# Check whether disks are valid
for disk_idx in self.disks:
......@@ -8211,6 +8220,13 @@ class TLReplaceDisks(Tasklet):
if self.delay_iallocator:
if ([locking.LEVEL_NODE] == locking.ALL_SET and
# Verify owned locks before starting operation
owned_locks =
assert set(owned_locks) == set(self.node_secondary_ip), \
"Not owning the correct locks: %s" % (owned_locks, )
if not self.disks:
feedback_fn("No disks need replacement")
......@@ -8239,6 +8255,15 @@ class TLReplaceDisks(Tasklet):
if activate_disks:
_SafeShutdownInstanceDisks(, self.instance)
if __debug__:
# Verify owned locks
owned_locks =
assert ((self.early_release and not owned_locks) or
(not self.early_release and
set(owned_locks) == set(self.node_secondary_ip))), \
("Not owning the correct locks, early_release=%s, owned=%r" %
(self.early_release, owned_locks))
def _CheckVolumeGroup(self, nodes):"Checking volume groups")
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