Revision fecbe9d5

b/lib/bdev.py
319 319

  
320 320
    pvlist = [ pv[1] for pv in pvs_info ]
321 321
    free_size = sum([ pv[0] for pv in pvs_info ])
322
    current_pvs = len(pvlist)
323
    stripes = min(current_pvs, constants.LVM_STRIPECOUNT)
322 324

  
323 325
    # The size constraint should have been checked from the master before
324 326
    # calling the create function.
325 327
    if free_size < size:
326 328
      _ThrowError("Not enough free space: required %s,"
327 329
                  " available %s", size, free_size)
328
    result = utils.RunCmd(["lvcreate", "-L%dm" % size, "-n%s" % lv_name,
329
                           vg_name] + pvlist)
330
    cmd = ["lvcreate", "-L%dm" % size, "-n%s" % lv_name]
331
    # If the free space is not well distributed, we won't be able to
332
    # create an optimally-striped volume; in that case, we want to try
333
    # with N, N-1, ..., 2, and finally 1 (non-stripped) number of
334
    # stripes
335
    for stripes_arg in range(stripes, 0, -1):
336
      result = utils.RunCmd(cmd + ["-i%d" % stripes_arg] + [vg_name] + pvlist)
337
      if not result.failed:
338
        break
330 339
    if result.failed:
331 340
      _ThrowError("LV create failed (%s): %s",
332 341
                  result.fail_reason, result.output)

Also available in: Unified diff