commit 6605411d5f5abfe009efb787f7b159dae52f6a0f
Author: Iustin Pop <iustin@google.com>
Date:   Tue Oct 14 16:23:02 2008 +0000

    grow-disk: wait until resync is completed
    
    The patch adds a new ‘--no-wait-for-sync’ parameter to grow-disk similar
    to the one in instance add, and changes the default to wait.
    
    This is cleaner as at the moment when the command returns, we either
    have a fully synced disk or there is an error.
    
    This is a forward-port of rev 1183 on the 1.2 branch.
    
    Reviewed-by: ultrotter

diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index e0cbe86..dafb621 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -4254,7 +4254,7 @@ class LUGrowDisk(LogicalUnit):
   """
   HPATH = "disk-grow"
   HTYPE = constants.HTYPE_INSTANCE
-  _OP_REQP = ["instance_name", "disk", "amount"]
+  _OP_REQP = ["instance_name", "disk", "amount", "wait_for_sync"]
   REQ_BGL = False
 
   def ExpandNames(self):
@@ -4337,7 +4337,11 @@ class LUGrowDisk(LogicalUnit):
                                  (node, result[1]))
     disk.RecordGrow(self.op.amount)
     self.cfg.Update(instance)
-    return
+    if self.op.wait_for_sync:
+      disk_abort = not _WaitForSync(self.cfg, instance, self.proc)
+      if disk_abort:
+        logger.Error("Warning: disk sync-ing has not returned a good status.\n"
+                     " Please check the instance.")
 
 
 class LUQueryInstanceData(NoHooksLU):
diff --git a/lib/opcodes.py b/lib/opcodes.py
index 646b7e9..3f4162a 100644
--- a/lib/opcodes.py
+++ b/lib/opcodes.py
@@ -432,7 +432,7 @@ class OpGrowDisk(OpCode):
   """Grow a disk of an instance."""
   OP_ID = "OP_INSTANCE_GROW_DISK"
   OP_DSC_FIELD = "instance_name"
-  __slots__ = ["instance_name", "disk", "amount"]
+  __slots__ = ["instance_name", "disk", "amount", "wait_for_sync"]
 
 
 # OS opcodes
diff --git a/man/gnt-instance.sgml b/man/gnt-instance.sgml
index 5e314aa..9332dfa 100644
--- a/man/gnt-instance.sgml
+++ b/man/gnt-instance.sgml
@@ -1176,6 +1176,7 @@ node1.example.com:sdb:/dev/drbd1
         <title>GROW-DISK</title>
         <cmdsynopsis>
           <command>grow-disk</command>
+          <arg>--no-wait-for-sync</arg>
           <arg choice="req"><replaceable>instance</replaceable></arg>
           <arg choice="req"><replaceable>disk</replaceable></arg>
           <arg choice="req"><replaceable>amount</replaceable></arg>
@@ -1232,7 +1233,14 @@ node1.example.com:sdb:/dev/drbd1
           create problems (except for unused space).
         </para>
 
-        <para>Example (increasing sda for instance1 with 16GiB):
+        <para>
+          If you do not want gnt-instance to wait for the new disk
+          region to be synced, use the
+          <option>--no-wait-for-sync</option> option.
+        </para>
+
+
+        <para>Example (increase sda for instance1 by 16GiB):
           <screen>
 # gnt-instance grow-disk instance1.example.com sda 16g
           </screen>
diff --git a/scripts/gnt-instance b/scripts/gnt-instance
index 8d31219..e7528fb 100755
--- a/scripts/gnt-instance
+++ b/scripts/gnt-instance
@@ -443,7 +443,8 @@ def GrowDisk(opts, args):
   instance = args[0]
   disk = args[1]
   amount = utils.ParseUnit(args[2])
-  op = opcodes.OpGrowDisk(instance_name=instance, disk=disk, amount=amount)
+  op = opcodes.OpGrowDisk(instance_name=instance, disk=disk, amount=amount,
+                          wait_for_sync=opts.wait_for_sync)
   SubmitOrSend(op, opts)
   return 0
 
@@ -1069,7 +1070,13 @@ commands = {
   'deactivate-disks': (DeactivateDisks, ARGS_ONE, [DEBUG_OPT, SUBMIT_OPT],
                        "<instance>",
                        "Deactivate an instance's disks"),
-  'grow-disk': (GrowDisk, ARGS_FIXED(3), [DEBUG_OPT, SUBMIT_OPT],
+  'grow-disk': (GrowDisk, ARGS_FIXED(3),
+                [DEBUG_OPT, SUBMIT_OPT,
+                 make_option("--no-wait-for-sync",
+                             dest="wait_for_sync", default=True,
+                             action="store_false",
+                             help="Don't wait for sync (DANGEROUS!)"),
+                 ],
                 "<instance> <disk> <size>", "Grow an instance's disk"),
   'list-tags': (ListTags, ARGS_ONE, [DEBUG_OPT],
                 "<instance_name>", "List the tags of the given instance"),
diff --git a/tools/burnin b/tools/burnin
index ace2233..6e34013 100755
--- a/tools/burnin
+++ b/tools/burnin
@@ -288,7 +288,7 @@ class Burner(object):
         growth = getattr(self.opts, '%s_growth' % disk)
         if growth > 0:
           op = opcodes.OpGrowDisk(instance_name=instance, disk=disk,
-                                  amount=growth)
+                                  amount=growth, wait_for_sync=True)
           Log("- Increase %s's %s disk by %s MB" % (instance, disk, growth))
           self.ExecOp(op)
 
