LUGetTags: Acquire locks in shared mode
authorMichael Hanselmann <hansmi@google.com>
Fri, 1 Oct 2010 14:59:41 +0000 (16:59 +0200)
committerMichael Hanselmann <hansmi@google.com>
Tue, 5 Oct 2010 14:59:06 +0000 (16:59 +0200)
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

index abab553..8d0b9ba 100644 (file)
@@ -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.