[lxc-devel] [lxd/master] Storage: CreateVolumeFromCopy only set volume size from expanded config when source is image
tomponline on Github
lxc-bot at linuxcontainers.org
Thu Apr 30 09:09:04 UTC 2020
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 317 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200430/cd655b90/attachment.bin>
-------------- next part --------------
From 1dc036c4e5f798d7284f1425355f67941b8b6f2b Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Wed, 29 Apr 2020 15:58:21 +0100
Subject: [PATCH 1/2] lxd/storage/drivers/driver/lvm/volumes:
CreateVolumeFromCopy only set volume size from expanded config when source is
image
Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
lxd/storage/drivers/driver_lvm_utils.go | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/lxd/storage/drivers/driver_lvm_utils.go b/lxd/storage/drivers/driver_lvm_utils.go
index 22ddb710be..37f914be05 100644
--- a/lxd/storage/drivers/driver_lvm_utils.go
+++ b/lxd/storage/drivers/driver_lvm_utils.go
@@ -650,8 +650,16 @@ func (d *lvm) copyThinpoolVolume(vol, srcVol Volume, srcSnapshots []Volume, refr
}
}
- // Resize the new volume and filesystem to the correct size.
- err = d.SetVolumeQuota(vol, d.volumeSize(vol), nil)
+ // Default to non-expanded config, so we only use user specified volume size.
+ // This is so the pool default volume size isn't take into account for volume copies.
+ volSize := vol.config["size"]
+
+ // If source is an image then use expanded config so that we take into account pool default volume size.
+ if srcVol.volType == VolumeTypeImage {
+ volSize = vol.ExpandedConfig("size")
+ }
+
+ err = d.SetVolumeQuota(vol, volSize, nil)
if err != nil {
return err
}
From 55cb5404090b78b90cf50ce0a243a36312e09389 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Wed, 29 Apr 2020 15:37:39 +0100
Subject: [PATCH 2/2] lxd/storage/drivers/driver/zfs/volumes:
CreateVolumeFromCopy only set volume size from expanded config when source is
image
Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
lxd/storage/drivers/driver_zfs_volumes.go | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/lxd/storage/drivers/driver_zfs_volumes.go b/lxd/storage/drivers/driver_zfs_volumes.go
index 972c63211e..db87f9e4d1 100644
--- a/lxd/storage/drivers/driver_zfs_volumes.go
+++ b/lxd/storage/drivers/driver_zfs_volumes.go
@@ -594,15 +594,22 @@ func (d *zfs) CreateVolumeFromCopy(vol Volume, srcVol Volume, copySnapshots bool
}
}
- // Resize the new volume and filesystem to the correct size.
- err := d.SetVolumeQuota(vol, vol.ExpandedConfig("size"), nil)
+ // Default to non-expanded config, so we only use user specified volume size.
+ // This is so the pool default volume size isn't take into account for volume copies.
+ volSize := vol.config["size"]
+
+ // If source is an image then use expanded config so that we take into account pool default volume size.
+ if srcVol.volType == VolumeTypeImage {
+ volSize = vol.ExpandedConfig("size")
+ }
+
+ err := d.SetVolumeQuota(vol, volSize, op)
if err != nil {
return err
}
// All done.
revert.Success()
-
return nil
}
More information about the lxc-devel
mailing list