Change in vdsm[master]: storage: Add resize_if_needed method in multipath.py
frolland at redhat.com
frolland at redhat.com
Sun May 3 08:44:52 UTC 2015
Hello Fred Rolland,
I'd like you to do a code review. Please visit
https://gerrit.ovirt.org/40468
to review the following change.
Change subject: storage: Add resize_if_needed method in multipath.py
......................................................................
storage: Add resize_if_needed method in multipath.py
This method checks if a multipath device should be resized.
It will check the slaves sizes and if it is bigger than the multipath
device it will call "multipathd resize".
Change-Id: Ib1020667baeb5976fb1c78daedcc88727648f13d
Bug-Url:https://bugzilla.redhat.com/609689
Signed-off-by: Fred Rolland <frolland at redhat.com>
---
M vdsm/storage/multipath.py
1 file changed, 34 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/68/40468/1
diff --git a/vdsm/storage/multipath.py b/vdsm/storage/multipath.py
index 53374bc..1a9c729 100644
--- a/vdsm/storage/multipath.py
+++ b/vdsm/storage/multipath.py
@@ -53,6 +53,10 @@
"/lib/udev/scsi_id", # EL6, Ubuntu
)
+MULTIPATHD = utils.CommandPath("multipathd",
+ "/usr/sbin/multipathd",
+ "/sbin/multipathd")
+
def rescan():
"""
@@ -309,6 +313,36 @@
yield dmInfoDir.split("/")[3], guid
+def resize_if_needed(guid):
+ log.debug("Check if device %r needs resize", guid)
+ name = devicemapper.getDmId(guid)
+ deviceSize = getDeviceSize(name)
+ for slave in devicemapper.getSlaves(name):
+ if getDeviceSize(slave) > deviceSize:
+ log.debug("Slave size is larger, %r needs resize", guid)
+ try:
+ resize_map(name)
+ except Exception as e:
+ log.error("Error: %s while trying to resize device: "
+ "%s", str(e.message), guid)
+ break
+
+
+def resize_map(name):
+ log.debug("Resizing map %r", name)
+ cmd = [MULTIPATHD.cmd, "-kresize map %s" % name]
+ start = utils.monotonic_time()
+ rc, out, err = utils.execCmd(cmd, raw=True, execCmdLogger=log)
+ # multipathd reports some errors using non-zero exit code and stderr (need
+ # to be root), but -k commands always return 0, and the result is reported
+ # using stdout.
+ if rc != 0 or out != "ok\n":
+ raise Exception("Resizing map %r failed: out=%r err=%r"
+ % (name, out, err))
+ elapsed = utils.monotonic_time() - start
+ log.debug("Resized map %r in %.2f seconds", name, elapsed)
+
+
def devIsiSCSI(type):
return type in [DEV_ISCSI, DEV_MIXED]
--
To view, visit https://gerrit.ovirt.org/40468
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib1020667baeb5976fb1c78daedcc88727648f13d
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Freddy Rolland <frolland at redhat.com>
Gerrit-Reviewer: Fred Rolland <frolland at redhat.com>
More information about the vdsm-patches
mailing list