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 <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 07cba1bc
......@@ -8189,6 +8189,15 @@ class TLReplaceDisks(Tasklet):
for node in check_nodes:
_CheckNodeOnline(self.lu, node)
touched_nodes = frozenset([self.new_node, self.other_node,
self.target_node])
if self.lu.needed_locks[locking.LEVEL_NODE] == locking.ALL_SET:
# Release unneeded node locks
for name in self.lu.acquired_locks[locking.LEVEL_NODE]:
if name not in touched_nodes:
self._ReleaseNodeLock(name)
# Check whether disks are valid
for disk_idx in self.disks:
instance.FindDisk(disk_idx)
......@@ -8211,6 +8220,13 @@ class TLReplaceDisks(Tasklet):
if self.delay_iallocator:
self._CheckPrereq2()
if (self.lu.needed_locks[locking.LEVEL_NODE] == locking.ALL_SET and
__debug__):
# Verify owned locks before starting operation
owned_locks = self.lu.context.glm.list_owned(locking.LEVEL_NODE)
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")
return
......@@ -8239,6 +8255,15 @@ class TLReplaceDisks(Tasklet):
if activate_disks:
_SafeShutdownInstanceDisks(self.lu, self.instance)
if __debug__:
# Verify owned locks
owned_locks = self.lu.context.glm.list_owned(locking.LEVEL_NODE)
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):
self.lu.LogInfo("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