From 60db933622f1ef44165bd34405f7a68d5bb25426 Mon Sep 17 00:00:00 2001
From: Michael Hanselmann <hansmi@google.com>
Date: Fri, 1 Oct 2010 16:59:41 +0200
Subject: [PATCH] LUGetTags: Acquire locks in shared mode

Retrieving tags can be done while the lock is shared. Only writing
needs to be exclusive.

Also add a FIXME for cluster tags, where the code currently doesn't
use any locks except the config lock.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>
---
 lib/cmdlib.py | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index abab553f7..8d0b9baf3 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -9786,6 +9786,9 @@ class TagsLU(NoHooksLU): # pylint: disable-msg=W0223
       self.op.name = _ExpandInstanceName(self.cfg, self.op.name)
       self.needed_locks[locking.LEVEL_INSTANCE] = self.op.name
 
+    # FIXME: Acquire BGL for cluster tag operations (as of this writing it's
+    # not possible to acquire the BGL based on opcode parameters)
+
   def CheckPrereq(self):
     """Check prerequisites.
 
@@ -9812,6 +9815,12 @@ class LUGetTags(TagsLU):
     ]
   REQ_BGL = False
 
+  def ExpandNames(self):
+    TagsLU.ExpandNames(self)
+
+    # Share locks as this is only a read operation
+    self.share_locks = dict.fromkeys(locking.LEVELS, 1)
+
   def Exec(self, feedback_fn):
     """Returns the tag list.
 
-- 
GitLab