From 99d79431e3e00f15b33a6d1db7c0b9ba4d2a8e05 Mon Sep 17 00:00:00 2001 From: Eric Harney Date: Wed, 19 Jul 2017 11:00:41 -0400 Subject: [PATCH] LVM: Activate LV before creating exports In some circumstances (such as after a reboot), especially with thin LVM, the LV may not be activated, so creating a target from it will fail. Activate the LV before creating a target. When using permanent=True for activation, don't supply the -K/ignoreskipactivation argument. This is rejected by LVM 2.02.171, and is not a reasonable request, since it asks to simultaneously unset a flag, and also to ignore the flag (which should now be unset) during the same activation operation. This fixes a failure to clone a volume from another thin LVM volume in the same pool. Closes-Bug: #1701545 Change-Id: I925ece8833cc99a95c4cf693804ca3698f8cb114 --- cinder/brick/local_dev/lvm.py | 3 ++- cinder/volume/drivers/lvm.py | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/cinder/brick/local_dev/lvm.py b/cinder/brick/local_dev/lvm.py index 3c21c29d5..7dcb20838 100644 --- a/cinder/brick/local_dev/lvm.py +++ b/cinder/brick/local_dev/lvm.py @@ -676,11 +676,12 @@ class LVM(executor.Executor): cmd = ['lvchange', '-a', 'y', '--yes'] if self.supports_lvchange_ignoreskipactivation: - cmd.append('-K') # If permanent=True is specified, drop the skipactivation flag in # order to make this LV automatically activated after next reboot. if permanent: cmd += ['-k', 'n'] + else: + cmd.append('-K') cmd.append(lv_path) diff --git a/cinder/volume/drivers/lvm.py b/cinder/volume/drivers/lvm.py index ccd6158ec..6a6460268 100644 --- a/cinder/volume/drivers/lvm.py +++ b/cinder/volume/drivers/lvm.py @@ -790,6 +790,8 @@ class LVMVolumeDriver(driver.VolumeDriver): volume_path = "/dev/%s/%s" % (self.configuration.volume_group, volume['name']) + self.vg.activate_lv(volume['name']) + model_update = \ self.target_driver.ensure_export(context, volume, volume_path) return model_update @@ -800,6 +802,8 @@ class LVMVolumeDriver(driver.VolumeDriver): volume_path = "/dev/%s/%s" % (vg, volume['name']) + self.vg.activate_lv(volume['name']) + export_info = self.target_driver.create_export( context, volume,