From 800ac39940a3c3598d9d53814e329a64b831d51e Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Thu, 2 Dec 2010 14:04:59 +0000 Subject: [PATCH] Make snapshots multi-vg aware Currently, the Snapshot() function of LogicalVolume returns only the logical volume path, with the assumption that we only have one VG. But with the recent changes, it makes more sense to return the full data (vg and lv) from it, so as to not require computing it in the master. Signed-off-by: Iustin Pop <iustin@google.com> Reviewed-by: Michael Hanselmann <hansmi@google.com> --- lib/backend.py | 2 +- lib/bdev.py | 4 +++- lib/masterd/instance.py | 10 ++++++---- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/backend.py b/lib/backend.py index b42ebe7be..57c2ce403 100644 --- a/lib/backend.py +++ b/lib/backend.py @@ -2143,7 +2143,7 @@ def BlockdevSnapshot(disk): @type disk: L{objects.Disk} @param disk: the disk to be snapshotted @rtype: string - @return: snapshot disk path + @return: snapshot disk ID as (vg, lv) """ if disk.dev_type == constants.LD_DRBD8: diff --git a/lib/bdev.py b/lib/bdev.py index 1378a2ff7..13b856625 100644 --- a/lib/bdev.py +++ b/lib/bdev.py @@ -694,6 +694,8 @@ class LogicalVolume(BlockDev): def Snapshot(self, size): """Create a snapshot copy of an lvm block device. + @returns: tuple (vg, lv) + """ snap_name = self._lv_name + ".snap" @@ -715,7 +717,7 @@ class LogicalVolume(BlockDev): _ThrowError("command: %s error: %s - %s", result.cmd, result.fail_reason, result.output) - return snap_name + return (self._vg_name, snap_name) def SetInfo(self, text): """Update metadata with info text. diff --git a/lib/masterd/instance.py b/lib/masterd/instance.py index f09763956..d83e83625 100644 --- a/lib/masterd/instance.py +++ b/lib/masterd/instance.py @@ -1151,8 +1151,6 @@ class ExportInstanceHelper: instance = self._instance src_node = instance.primary_node - vgname = self._lu.cfg.GetVGName() - for idx, disk in enumerate(instance.disks): self._feedback_fn("Creating a snapshot of disk/%s on node %s" % (idx, src_node)) @@ -1160,13 +1158,17 @@ class ExportInstanceHelper: # result.payload will be a snapshot of an lvm leaf of the one we # passed result = self._lu.rpc.call_blockdev_snapshot(src_node, disk) + new_dev = False msg = result.fail_msg if msg: self._lu.LogWarning("Could not snapshot disk/%s on node %s: %s", idx, src_node, msg) - new_dev = False + elif (not isinstance(result.payload, (tuple, list)) or + len(result.payload) != 2): + self._lu.LogWarning("Could not snapshot disk/%s on node %s: invalid" + " result '%s'", idx, src_node, result.payload) else: - disk_id = (vgname, result.payload) + disk_id = tuple(result.payload) new_dev = objects.Disk(dev_type=constants.LD_LV, size=disk.size, logical_id=disk_id, physical_id=disk_id, iv_name=disk.iv_name) -- GitLab