[lxc-devel] [lxd/master] Storage: ZFS CreateVolumeFropCopy only set volume size when source is image

tomponline on Github lxc-bot at linuxcontainers.org
Wed Apr 29 14:38:52 UTC 2020


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 363 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200429/e54697e1/attachment.bin>
-------------- next part --------------
From 88b2dd12314707b5b49d4c18026492203bac4bb1 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] lxd/storage/drivers/driver/zfs/volumes: CreateVolumeFropCopy
 only set volume size when source is image

Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
 lxd/storage/drivers/driver_zfs_volumes.go | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/lxd/storage/drivers/driver_zfs_volumes.go b/lxd/storage/drivers/driver_zfs_volumes.go
index 972c63211e..795a72f13a 100644
--- a/lxd/storage/drivers/driver_zfs_volumes.go
+++ b/lxd/storage/drivers/driver_zfs_volumes.go
@@ -594,15 +594,16 @@ 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)
-	if err != nil {
-		return err
+	// Resize the new volume and filesystem to the correct size if the source was an image.
+	if srcVol.volType == VolumeTypeImage {
+		err := d.SetVolumeQuota(vol, vol.ExpandedConfig("size"), nil)
+		if err != nil {
+			return err
+		}
 	}
 
 	// All done.
 	revert.Success()
-
 	return nil
 }
 


More information about the lxc-devel mailing list