[lxc-devel] [lxd/master] lxd/storage/zfs: Fix missing dir on copy
stgraber on Github
lxc-bot at linuxcontainers.org
Wed Dec 12 21:33:28 UTC 2018
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 370 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20181212/68be0f84/attachment.bin>
-------------- next part --------------
From 56ae10944069220b922aa93f81e8b4833ff7f8f2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Wed, 12 Dec 2018 16:02:07 -0500
Subject: [PATCH] lxd/storage/zfs: Fix missing dir on copy
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Closes #5348
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
lxd/storage_zfs.go | 27 ++++++++++++++++++++++++---
1 file changed, 24 insertions(+), 3 deletions(-)
diff --git a/lxd/storage_zfs.go b/lxd/storage_zfs.go
index 647db33b66..ac8757f654 100644
--- a/lxd/storage_zfs.go
+++ b/lxd/storage_zfs.go
@@ -3185,6 +3185,9 @@ func (s *storageZfs) StoragePoolVolumeCopy(source *api.StorageVolumeSource) erro
}
}
+ targetStorageVolumeMountPoint := getStoragePoolVolumeMountPoint(s.pool.Name, s.volume.Name)
+ fs := fmt.Sprintf("custom/%s", s.volume.Name)
+
if source.VolumeOnly || len(snapshots) == 0 {
var err error
@@ -3197,8 +3200,6 @@ func (s *storageZfs) StoragePoolVolumeCopy(source *api.StorageVolumeSource) erro
return err
}
} else {
- targetStorageVolumeMountPoint := getStoragePoolVolumeMountPoint(s.pool.Name, s.volume.Name)
-
tmpSnapshotName := fmt.Sprintf("copy-send-%s", uuid.NewRandom().String())
err := zfsPoolVolumeSnapshotCreate(poolName, fmt.Sprintf("custom/%s", source.Name), tmpSnapshotName)
if err != nil {
@@ -3235,7 +3236,6 @@ func (s *storageZfs) StoragePoolVolumeCopy(source *api.StorageVolumeSource) erro
defer zfsPoolVolumeSnapshotDestroy(poolName, fmt.Sprintf("custom/%s", s.volume.Name), tmpSnapshotName)
- fs := fmt.Sprintf("custom/%s", s.volume.Name)
err = zfsPoolVolumeSet(poolName, fs, "canmount", "noauto")
if err != nil {
return err
@@ -3247,6 +3247,27 @@ func (s *storageZfs) StoragePoolVolumeCopy(source *api.StorageVolumeSource) erro
}
}
+ if !shared.IsMountPoint(targetStorageVolumeMountPoint) {
+ err := zfsMount(poolName, fs)
+ if err != nil {
+ return err
+ }
+ defer zfsUmount(poolName, fs, targetStorageVolumeMountPoint)
+ }
+
+ // apply quota
+ if s.volume.Config["size"] != "" {
+ size, err := shared.ParseByteSizeString(s.volume.Config["size"])
+ if err != nil {
+ return err
+ }
+
+ err = s.StorageEntitySetQuota(storagePoolVolumeTypeCustom, size, nil)
+ if err != nil {
+ return err
+ }
+ }
+
logger.Infof(successMsg)
return nil
}
More information about the lxc-devel
mailing list