Revision 38256320
b/lib/bdev.py | ||
---|---|---|
299 | 299 |
self._vg_name, self._lv_name = unique_id |
300 | 300 |
self.dev_path = "/dev/%s/%s" % (self._vg_name, self._lv_name) |
301 | 301 |
self._degraded = True |
302 |
self.major = self.minor = None |
|
302 |
self.major = self.minor = self.pe_size = self.stripe_count = None
|
|
303 | 303 |
self.Attach() |
304 | 304 |
|
305 | 305 |
@classmethod |
... | ... | |
411 | 411 |
""" |
412 | 412 |
self.attached = False |
413 | 413 |
result = utils.RunCmd(["lvs", "--noheadings", "--separator=,", |
414 |
"-olv_attr,lv_kernel_major,lv_kernel_minor", |
|
415 |
self.dev_path]) |
|
414 |
"--units=m", "--nosuffix", |
|
415 |
"-olv_attr,lv_kernel_major,lv_kernel_minor," |
|
416 |
"vg_extent_size,stripes", self.dev_path]) |
|
416 | 417 |
if result.failed: |
417 | 418 |
logging.error("Can't find LV %s: %s, %s", |
418 | 419 |
self.dev_path, result.fail_reason, result.output) |
419 | 420 |
return False |
420 |
out = result.stdout.strip().rstrip(',') |
|
421 |
# the output can (and will) have multiple lines for multi-segment |
|
422 |
# LVs, as the 'stripes' parameter is a segment one, so we take |
|
423 |
# only the last entry, which is the one we're interested in; note |
|
424 |
# that with LVM2 anyway the 'stripes' value must be constant |
|
425 |
# across segments, so this is a no-op actually |
|
426 |
out = result.stdout.splitlines() |
|
427 |
if not out: # totally empty result? splitlines() returns at least |
|
428 |
# one line for any non-empty string |
|
429 |
logging.error("Can't parse LVS output, no lines? Got '%s'", str(out)) |
|
430 |
return False |
|
431 |
out = out[-1].strip().rstrip(',') |
|
421 | 432 |
out = out.split(",") |
422 |
if len(out) != 3:
|
|
423 |
logging.error("Can't parse LVS output, len(%s) != 3", str(out))
|
|
433 |
if len(out) != 5:
|
|
434 |
logging.error("Can't parse LVS output, len(%s) != 5", str(out))
|
|
424 | 435 |
return False |
425 | 436 |
|
426 |
status, major, minor = out[:3]
|
|
437 |
status, major, minor, pe_size, stripes = out
|
|
427 | 438 |
if len(status) != 6: |
428 | 439 |
logging.error("lvs lv_attr is not 6 characters (%s)", status) |
429 | 440 |
return False |
... | ... | |
434 | 445 |
except ValueError, err: |
435 | 446 |
logging.error("lvs major/minor cannot be parsed: %s", str(err)) |
436 | 447 |
|
448 |
try: |
|
449 |
pe_size = int(float(pe_size)) |
|
450 |
except (TypeError, ValueError), err: |
|
451 |
logging.error("Can't parse vg extent size: %s", err) |
|
452 |
return False |
|
453 |
|
|
454 |
try: |
|
455 |
stripes = int(stripes) |
|
456 |
except (TypeError, ValueError), err: |
|
457 |
logging.error("Can't parse the number of stripes: %s", err) |
|
458 |
return False |
|
459 |
|
|
437 | 460 |
self.major = major |
438 | 461 |
self.minor = minor |
462 |
self.pe_size = pe_size |
|
463 |
self.stripe_count = stripes |
|
439 | 464 |
self._degraded = status[0] == 'v' # virtual volume, i.e. doesn't backing |
440 | 465 |
# storage |
441 | 466 |
self.attached = True |
... | ... | |
554 | 579 |
"""Grow the logical volume. |
555 | 580 |
|
556 | 581 |
""" |
582 |
if self.pe_size is None or self.stripe_count is None: |
|
583 |
if not self.Attach(): |
|
584 |
_ThrowError("Can't attach to LV during Grow()") |
|
585 |
full_stripe_size = self.pe_size * self.stripe_count |
|
586 |
rest = amount % full_stripe_size |
|
587 |
if rest != 0: |
|
588 |
amount += full_stripe_size - rest |
|
557 | 589 |
# we try multiple algorithms since the 'best' ones might not have |
558 | 590 |
# space available in the right place, but later ones might (since |
559 | 591 |
# they have less constraints); also note that only recent LVM |
... | ... | |
1609 | 1641 |
if len(self._children) != 2 or None in self._children: |
1610 | 1642 |
_ThrowError("drbd%d: cannot grow diskless device", self.minor) |
1611 | 1643 |
self._children[0].Grow(amount) |
1612 |
result = utils.RunCmd(["drbdsetup", self.dev_path, "resize"]) |
|
1644 |
result = utils.RunCmd(["drbdsetup", self.dev_path, "resize", "-s", |
|
1645 |
"%dm" % (self.size + amount)]) |
|
1613 | 1646 |
if result.failed: |
1614 | 1647 |
_ThrowError("drbd%d: resize failed: %s", self.minor, result.output) |
1615 | 1648 |
|
Also available in: Unified diff