Commit 35705d8f authored by Guido Trotter's avatar Guido Trotter
Browse files

Parallelize LUQueryNodes

As for LUQueryInstances the first version just acquires a shared lock on all
nodes. In the future further optimizations are possible, as outlined by
comments in the code.

Reviewed-by: imsnah
parent 7eb9d8f7
......@@ -1366,13 +1366,9 @@ class LUQueryNodes(NoHooksLU):
_OP_REQP = ["output_fields", "names"]
REQ_BGL = False
def CheckPrereq(self):
"""Check prerequisites.
This checks that the fields required are valid output fields.
def ExpandNames(self):
self.dynamic_fields = frozenset([
"dtotal", "dfree",
"mtotal", "mnode", "mfree",
......@@ -1386,7 +1382,23 @@ class LUQueryNodes(NoHooksLU):
self.wanted = _GetWantedNodes(self, self.op.names)
self.needed_locks = {}
self.share_locks[locking.LEVEL_NODE] = 1
# TODO: we could lock nodes only if the user asked for dynamic fields. For
# that we need atomic ways to get info for a group of nodes from the
# config, though.
if not self.op.names:
self.needed_locks[locking.LEVEL_NODE] = None
self.needed_locks[locking.LEVEL_NODE] = \
_GetWantedNodes(self, self.op.names)
def CheckPrereq(self):
"""Check prerequisites.
# This of course is valid only if we locked the nodes
self.wanted = self.needed_locks[locking.LEVEL_NODE]
def Exec(self, feedback_fn):
"""Computes the list of nodes and their attributes.
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