Commit 0c3c965a authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

LUInstanceGrowDisk: Use node resource lock

Also add one more feedback line. Downgrade instance lock to shared mode
while we're only waiting for disks to sync. The node lock is released
when not needed anymore.
Signed-off-by: default avatarMichael Hanselmann <>
Reviewed-by: default avatarIustin Pop <>
parent eaee9e3b
......@@ -10570,11 +10570,16 @@ class LUInstanceGrowDisk(LogicalUnit):
def ExpandNames(self):
self.needed_locks[locking.LEVEL_NODE] = []
self.recalculate_locks[locking.LEVEL_NODE] = constants.LOCKS_REPLACE
self.needed_locks[locking.LEVEL_NODE_RES] = []
self.recalculate_locks[locking.LEVEL_NODE_RES] = constants.LOCKS_REPLACE
def DeclareLocks(self, level):
if level == locking.LEVEL_NODE:
elif level == locking.LEVEL_NODE_RES:
# Copy node locks
self.needed_locks[locking.LEVEL_NODE_RES] = \
def BuildHooksEnv(self):
"""Build hooks env.
......@@ -10631,10 +10636,18 @@ class LUInstanceGrowDisk(LogicalUnit):
instance = self.instance
disk = self.disk
assert set([]) == self.owned_locks(locking.LEVEL_INSTANCE)
assert (self.owned_locks(locking.LEVEL_NODE) ==
disks_ok, _ = _AssembleInstanceDisks(self, self.instance, disks=[disk])
if not disks_ok:
raise errors.OpExecError("Cannot activate block device to grow")
feedback_fn("Growing disk %s of instance '%s' by %s" %
utils.FormatUnit(self.op.amount, "h")))
# First run all grow ops in dry-run mode
for node in instance.all_nodes:
self.cfg.SetDiskID(disk, node)
......@@ -10657,6 +10670,13 @@ class LUInstanceGrowDisk(LogicalUnit):
self.cfg.Update(instance, feedback_fn)
# Changes have been recorded, release node lock
_ReleaseLocks(self, locking.LEVEL_NODE)
# Downgrade lock while waiting for sync
if self.op.wait_for_sync:
disk_abort = not _WaitForSync(self, instance, disks=[disk])
if disk_abort:
......@@ -10669,6 +10689,9 @@ class LUInstanceGrowDisk(LogicalUnit):
" not supposed to be running because no wait for"
" sync mode was requested")
assert self.owned_locks(locking.LEVEL_NODE_RES)
assert set([]) == self.owned_locks(locking.LEVEL_INSTANCE)
class LUInstanceQueryData(NoHooksLU):
"""Query runtime instance data.
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