Revision cad0723b

b/lib/backend.py
2443 2443
  return result
2444 2444

  
2445 2445

  
2446
def BlockdevGrow(disk, amount, dryrun):
2446
def BlockdevGrow(disk, amount, dryrun, backingstore):
2447 2447
  """Grow a stack of block devices.
2448 2448

  
2449 2449
  This function is called recursively, with the childrens being the
......
2456 2456
  @type dryrun: boolean
2457 2457
  @param dryrun: whether to execute the operation in simulation mode
2458 2458
      only, without actually increasing the size
2459
  @param backingstore: whether to execute the operation on backing storage
2460
      only, or on "logical" storage only; e.g. DRBD is logical storage,
2461
      whereas LVM, file, RBD are backing storage
2459 2462
  @rtype: (status, result)
2460 2463
  @return: a tuple with the status of the operation (True/False), and
2461 2464
      the errors message if status is False
......
2466 2469
    _Fail("Cannot find block device %s", disk)
2467 2470

  
2468 2471
  try:
2469
    r_dev.Grow(amount, dryrun)
2472
    r_dev.Grow(amount, dryrun, backingstore)
2470 2473
  except errors.BlockDeviceError, err:
2471 2474
    _Fail("Failed to grow block device: %s", err, exc=True)
2472 2475

  
b/lib/bdev.py
338 338
    for child in self._children:
339 339
      child.SetInfo(text)
340 340

  
341
  def Grow(self, amount, dryrun):
341
  def Grow(self, amount, dryrun, backingstore):
342 342
    """Grow the block device.
343 343

  
344 344
    @type amount: integer
......
346 346
    @type dryrun: boolean
347 347
    @param dryrun: whether to execute the operation in simulation mode
348 348
        only, without actually increasing the size
349
    @param backingstore: whether to execute the operation on backing storage
350
        only, or on "logical" storage only; e.g. DRBD is logical storage,
351
        whereas LVM, file, RBD are backing storage
349 352

  
350 353
    """
351 354
    raise NotImplementedError
......
768 771
      _ThrowError("Command: %s error: %s - %s", result.cmd, result.fail_reason,
769 772
                  result.output)
770 773

  
771
  def Grow(self, amount, dryrun):
774
  def Grow(self, amount, dryrun, backingstore):
772 775
    """Grow the logical volume.
773 776

  
774 777
    """
778
    if not backingstore:
779
      return
775 780
    if self.pe_size is None or self.stripe_count is None:
776 781
      if not self.Attach():
777 782
        _ThrowError("Can't attach to LV during Grow()")
......
2070 2075
    cls._InitMeta(aminor, meta.dev_path)
2071 2076
    return cls(unique_id, children, size, params)
2072 2077

  
2073
  def Grow(self, amount, dryrun):
2078
  def Grow(self, amount, dryrun, backingstore):
2074 2079
    """Resize the DRBD device and its backing storage.
2075 2080

  
2076 2081
    """
......
2078 2083
      _ThrowError("drbd%d: Grow called while not attached", self._aminor)
2079 2084
    if len(self._children) != 2 or None in self._children:
2080 2085
      _ThrowError("drbd%d: cannot grow diskless device", self.minor)
2081
    self._children[0].Grow(amount, dryrun)
2082
    if dryrun:
2083
      # DRBD does not support dry-run mode, so we'll return here
2086
    self._children[0].Grow(amount, dryrun, backingstore)
2087
    if dryrun or backingstore:
2088
      # DRBD does not support dry-run mode and is not backing storage,
2089
      # so we'll return here
2084 2090
      return
2085 2091
    result = utils.RunCmd(["drbdsetup", self.dev_path, "resize", "-s",
2086 2092
                           "%dm" % (self.size + amount)])
......
2163 2169
    # TODO: implement rename for file-based storage
2164 2170
    _ThrowError("Rename is not supported for file-based storage")
2165 2171

  
2166
  def Grow(self, amount, dryrun):
2172
  def Grow(self, amount, dryrun, backingstore):
2167 2173
    """Grow the file
2168 2174

  
2169 2175
    @param amount: the amount (in mebibytes) to grow with
2170 2176

  
2171 2177
    """
2178
    if not backingstore:
2179
      return
2172 2180
    # Check that the file exists
2173 2181
    self.Assemble()
2174 2182
    current_size = self.GetActualSize()
......
2339 2347
    """
2340 2348
    pass
2341 2349

  
2342
  def Grow(self, amount, dryrun):
2350
  def Grow(self, amount, dryrun, backingstore):
2343 2351
    """Grow the logical volume.
2344 2352

  
2345 2353
    """
......
2605 2613
    """
2606 2614
    pass
2607 2615

  
2608
  def Grow(self, amount, dryrun):
2616
  def Grow(self, amount, dryrun, backingstore):
2609 2617
    """Grow the Volume.
2610 2618

  
2611 2619
    @type amount: integer
......
2615 2623
        only, without actually increasing the size
2616 2624

  
2617 2625
    """
2626
    if not backingstore:
2627
      return
2618 2628
    if not self.Attach():
2619 2629
      _ThrowError("Can't attach to rbd device during Grow()")
2620 2630

  
b/lib/cmdlib.py
11683 11683
    for node in instance.all_nodes:
11684 11684
      self.cfg.SetDiskID(disk, node)
11685 11685
      result = self.rpc.call_blockdev_grow(node, (disk, instance), self.delta,
11686
                                           True)
11686
                                           True, True)
11687 11687
      result.Raise("Grow request failed to node %s" % node)
11688 11688

  
11689 11689
    # We know that (as far as we can test) operations across different
11690
    # nodes will succeed, time to run it for real
11690
    # nodes will succeed, time to run it for real on the backing storage
11691 11691
    for node in instance.all_nodes:
11692 11692
      self.cfg.SetDiskID(disk, node)
11693 11693
      result = self.rpc.call_blockdev_grow(node, (disk, instance), self.delta,
11694
                                           False)
11694
                                           False, True)
11695 11695
      result.Raise("Grow request failed to node %s" % node)
11696 11696

  
11697
      # TODO: Rewrite code to work properly
11698
      # DRBD goes into sync mode for a short amount of time after executing the
11699
      # "resize" command. DRBD 8.x below version 8.0.13 contains a bug whereby
11700
      # calling "resize" in sync mode fails. Sleeping for a short amount of
11701
      # time is a work-around.
11702
      time.sleep(5)
11697
    # And now execute it for logical storage, on the primary node
11698
    node = instance.primary_node
11699
    self.cfg.SetDiskID(disk, node)
11700
    result = self.rpc.call_blockdev_grow(node, (disk, instance), self.delta,
11701
                                         False, False)
11702
    result.Raise("Grow request failed to node %s" % node)
11703 11703

  
11704 11704
    disk.RecordGrow(self.delta)
11705 11705
    self.cfg.Update(instance, feedback_fn)
b/lib/rpc_defs.py
1 1
#
2 2
#
3 3

  
4
# Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Google Inc.
4
# Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Google Inc.
5 5
#
6 6
# This program is free software; you can redistribute it and/or modify
7 7
# it under the terms of the GNU General Public License as published by
......
393 393
    ("cf_bdev", ED_SINGLE_DISK_DICT_DP, None),
394 394
    ("amount", None, None),
395 395
    ("dryrun", None, None),
396
    ], None, None, "Request a snapshot of the given block device"),
396
    ("backingstore", None, None),
397
    ], None, None, "Request growing of the given block device by a"
398
   " given amount"),
397 399
  ("blockdev_export", SINGLE, None, TMO_1DAY, [
398 400
    ("cf_bdev", ED_SINGLE_DISK_DICT_DP, None),
399 401
    ("dest_node", None, None),
b/lib/server/noded.py
1 1
#
2 2
#
3 3

  
4
# Copyright (C) 2006, 2007, 2010, 2011 Google Inc.
4
# Copyright (C) 2006, 2007, 2010, 2011, 2012 Google Inc.
5 5
#
6 6
# This program is free software; you can redistribute it and/or modify
7 7
# it under the terms of the GNU General Public License as published by
......
332 332
    """Grow a stack of devices.
333 333

  
334 334
    """
335
    if len(params) < 4:
336
      raise ValueError("Received only 3 parameters in blockdev_grow,"
337
                       " old master?")
335 338
    cfbd = objects.Disk.FromDict(params[0])
336 339
    amount = params[1]
337 340
    dryrun = params[2]
338
    return backend.BlockdevGrow(cfbd, amount, dryrun)
341
    backingstore = params[3]
342
    return backend.BlockdevGrow(cfbd, amount, dryrun, backingstore)
339 343

  
340 344
  @staticmethod
341 345
  def perspective_blockdev_close(params):

Also available in: Unified diff