From bc8e4a1ae0c6836ff1ddc17d474cf06551521644 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Wed, 4 Feb 2009 15:11:58 +0000 Subject: [PATCH] Enable lockless node queries MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- lib/cmdlib.py | 7 ++++--- scripts/gnt-node | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 9f3ab0142..98668b03a 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -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()) diff --git a/scripts/gnt-node b/scripts/gnt-node index e22592db6..8c5ad9723 100755 --- a/scripts/gnt-node +++ b/scripts/gnt-node @@ -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." % -- GitLab