Commit 48aaca91 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

locking: Change locking order, move NAL after instances



Some opcodes, for example LUInstanceFailover and LUInstanceMigrate,
can't know whether they need to acquire all nodes until they have a lock
on the instance. In turn they would have to acquire the node allocation
lock “just in case” and could only release it once the instance had been
acquired.

Since there is no good reason for the node allocation lock to be before
instances in the locking order, this patch changes the order so that
instances are locked first.
Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarHelga Velroyen <helgav@google.com>
parent 4349c24d
......@@ -1496,8 +1496,8 @@ class LockSet:
# Once the set of acquired locks for an opcode has been reduced to the working
# set, the NAL should be released as well to allow allocations to proceed.
(LEVEL_CLUSTER,
LEVEL_NODE_ALLOC,
LEVEL_INSTANCE,
LEVEL_NODE_ALLOC,
LEVEL_NODEGROUP,
LEVEL_NODE,
LEVEL_NODE_RES,
......@@ -1505,8 +1505,8 @@ class LockSet:
LEVELS = [
LEVEL_CLUSTER,
LEVEL_NODE_ALLOC,
LEVEL_INSTANCE,
LEVEL_NODE_ALLOC,
LEVEL_NODEGROUP,
LEVEL_NODE,
LEVEL_NODE_RES,
......@@ -1526,11 +1526,11 @@ LEVELS_MOD = frozenset([
LEVEL_NAMES = {
LEVEL_CLUSTER: "cluster",
LEVEL_INSTANCE: "instance",
LEVEL_NODE_ALLOC: "node-alloc",
LEVEL_NODEGROUP: "nodegroup",
LEVEL_NODE: "node",
LEVEL_NODE_RES: "node-res",
LEVEL_NETWORK: "network",
LEVEL_NODE_ALLOC: "node-alloc",
}
# Constant for the big ganeti lock
......
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