From 5b7b5d49a689c7023aa37b989c60c4483dbc230a Mon Sep 17 00:00:00 2001
From: Guido Trotter <ultrotter@google.com>
Date: Mon, 23 Jul 2007 12:14:01 +0000
Subject: [PATCH] Do the secondary check and subsequently allocate the drive on
 all available logival volumes. This lets you use more than one when none of
 them can support your full drive size.

Reviewed-By: iustinp
---
 lib/bdev.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/lib/bdev.py b/lib/bdev.py
index d3ff77cff..7409493f9 100644
--- a/lib/bdev.py
+++ b/lib/bdev.py
@@ -297,12 +297,17 @@ class LogicalVolume(BlockDev):
                                       vg_name)
     pvs_info.sort()
     pvs_info.reverse()
-    free_size, pv_name = pvs_info[0]
+
+    pvlist = [ pv[1] for pv in pvs_info ]
+    free_size = sum([ pv[0] for pv in pvs_info ])
+
+    # The size constraint should have been checked from the master before
+    # calling the create function.
     if free_size < size:
       raise errors.BlockDeviceError, ("Not enough free space: required %s,"
                                       " available %s" % (size, free_size))
     result = utils.RunCmd(["lvcreate", "-L%dm" % size, "-n%s" % lv_name,
-                           vg_name, pv_name])
+                           vg_name] + pvlist)
     if result.failed:
       raise errors.BlockDeviceError(result.fail_reason)
     return LogicalVolume(unique_id, children)
-- 
GitLab