Revision 686d24f0

b/lib/cmdlib.py
138 138
    self.owned_locks = context.glm.list_owned
139 139
    self.context = context
140 140
    self.rpc = rpc_runner
141
    # Dicts used to declare locking needs to mcpu
141

  
142
    # Dictionaries used to declare locking needs to mcpu
142 143
    self.needed_locks = None
143 144
    self.share_locks = dict.fromkeys(locking.LEVELS, 0)
145
    self.opportunistic_locks = dict.fromkeys(locking.LEVELS, False)
146

  
144 147
    self.add_locks = {}
145 148
    self.remove_locks = {}
149

  
146 150
    # Used to force good behavior when calling helper functions
147 151
    self.recalculate_locks = {}
152

  
148 153
    # logging
149 154
    self.Log = processor.Log # pylint: disable=C0103
150 155
    self.LogWarning = processor.LogWarning # pylint: disable=C0103
b/lib/mcpu.py
275 275
    if not self._enable_locks:
276 276
      raise errors.ProgrammerError("Attempted to use disabled locks")
277 277

  
278
  def _AcquireLocks(self, level, names, shared, timeout):
278
  def _AcquireLocks(self, level, names, shared, opportunistic, timeout):
279 279
    """Acquires locks via the Ganeti lock manager.
280 280

  
281 281
    @type level: int
......
284 284
    @param names: Lock names
285 285
    @type shared: bool
286 286
    @param shared: Whether the locks should be acquired in shared mode
287
    @type opportunistic: bool
288
    @param opportunistic: Whether to acquire opportunistically
287 289
    @type timeout: None or float
288 290
    @param timeout: Timeout for acquiring the locks
289 291
    @raise LockAcquireTimeout: In case locks couldn't be acquired in specified
......
298 300
      priority = None
299 301

  
300 302
    acquired = self.context.glm.acquire(level, names, shared=shared,
301
                                        timeout=timeout, priority=priority)
303
                                        timeout=timeout, priority=priority,
304
                                        opportunistic=opportunistic)
302 305

  
303 306
    if acquired is None:
304 307
      raise LockAcquireTimeout()
......
384 387

  
385 388
      lu.DeclareLocks(level)
386 389
      share = lu.share_locks[level]
390
      opportunistic = lu.opportunistic_locks[level]
387 391

  
388 392
      try:
389 393
        assert adding_locks ^ acquiring_locks, \
......
393 397
          # Acquiring locks
394 398
          needed_locks = lu.needed_locks[level]
395 399

  
396
          self._AcquireLocks(level, needed_locks, share,
400
          self._AcquireLocks(level, needed_locks, share, opportunistic,
397 401
                             calc_timeout())
398 402
        else:
399 403
          # Adding locks
......
457 461
        # and in a shared fashion otherwise (to prevent concurrent run with
458 462
        # an exclusive LU.
459 463
        self._AcquireLocks(locking.LEVEL_CLUSTER, locking.BGL,
460
                            not lu_class.REQ_BGL, calc_timeout())
464
                            not lu_class.REQ_BGL, False, calc_timeout())
461 465
      elif lu_class.REQ_BGL:
462 466
        raise errors.ProgrammerError("Opcode '%s' requires BGL, but locks are"
463 467
                                     " disabled" % op.OP_ID)

Also available in: Unified diff