Commit bc8e4a1a authored by Iustin Pop's avatar Iustin Pop
Browse files

Enable lockless node queries

Similar to the instance list, this patch enables lockless node queris.
“gnt-node list” accepts now the “--sync” flag which enables locking, the
default is lockless.

Reviewed-by: imsnah
parent 85414b69
......@@ -1753,7 +1753,7 @@ class LUQueryNodes(NoHooksLU):
"""Logical unit for querying nodes.
"""
_OP_REQP = ["output_fields", "names"]
_OP_REQP = ["output_fields", "names", "use_locking"]
REQ_BGL = False
_FIELDS_DYNAMIC = utils.FieldSet(
"dtotal", "dfree",
......@@ -1785,7 +1785,8 @@ class LUQueryNodes(NoHooksLU):
else:
self.wanted = locking.ALL_SET
self.do_locking = self._FIELDS_STATIC.NonMatching(self.op.output_fields)
self.do_node_query = self._FIELDS_STATIC.NonMatching(self.op.output_fields)
self.do_locking = self.do_node_query and self.op.use_locking
if self.do_locking:
# if we don't request only static fields, we need to lock the nodes
self.needed_locks[locking.LEVEL_NODE] = self.wanted
......@@ -1820,7 +1821,7 @@ class LUQueryNodes(NoHooksLU):
# begin data gathering
if self.do_locking:
if self.do_node_query:
live_data = {}
node_data = self.rpc.call_node_info(nodenames, self.cfg.GetVGName(),
self.cfg.GetHypervisorType())
......
......@@ -119,7 +119,7 @@ def ListNodes(opts, args):
else:
selected_fields = opts.output.split(",")
output = GetClient().QueryNodes([], selected_fields, True)
output = GetClient().QueryNodes([], selected_fields, opts.do_locking)
if not opts.no_headers:
headers = _LIST_HEADERS
......@@ -495,7 +495,7 @@ commands = {
"[<node_name>...]", "Show information about the node(s)"),
'list': (ListNodes, ARGS_NONE,
[DEBUG_OPT, NOHDR_OPT, SEP_OPT, USEUNITS_OPT, FIELDS_OPT,
SUBMIT_OPT],
SUBMIT_OPT, SYNC_OPT],
"", "Lists the nodes in the cluster. The available fields"
" are (see the man page for details): %s"
" The default field list is (in order): %s." %
......
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