[lxc-devel] [lxd/master] lxd/storage/zfs: Fix transfer on encrypted pool

stgraber on Github lxc-bot at linuxcontainers.org
Fri Aug 9 16:29:42 UTC 2019


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/20190809/20f7f159/attachment.bin>
-------------- next part --------------
From bcd51cadd62f272f3c12148c509b0cb292cc9ef3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Fri, 9 Aug 2019 12:28:48 -0400
Subject: [PATCH] lxd/storage/zfs: Fix transfer on encrypted pool
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Closes #5999

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxd/storage_zfs.go | 18 +++++-------------
 1 file changed, 5 insertions(+), 13 deletions(-)

diff --git a/lxd/storage_zfs.go b/lxd/storage_zfs.go
index 9239caf35b..c2e86ebbf3 100644
--- a/lxd/storage_zfs.go
+++ b/lxd/storage_zfs.go
@@ -2723,6 +2723,7 @@ func (s *storageZfs) MigrationSource(args MigrationSourceArgs) (MigrationStorage
 
 func (s *storageZfs) MigrationSink(conn *websocket.Conn, op *operation, args MigrationSinkArgs) error {
 	poolName := s.getOnDiskPoolName()
+	zfsName := fmt.Sprintf("containers/%s", project.Prefix(args.Container.Project(), args.Container.Name()))
 	zfsRecv := func(zfsName string, writeWrapper func(io.WriteCloser) io.WriteCloser) error {
 		zfsFsName := fmt.Sprintf("%s/%s", poolName, zfsName)
 		args := []string{"receive", "-F", "-u", zfsFsName}
@@ -2761,19 +2762,10 @@ func (s *storageZfs) MigrationSink(conn *websocket.Conn, op *operation, args Mig
 		return err
 	}
 
-	/* In some versions of zfs we can write `zfs recv -F` to mounted
-	 * filesystems, and in some versions we can't. So, let's always unmount
-	 * this fs (it's empty anyway) before we zfs recv. N.B. that `zfs recv`
-	 * of a snapshot also needs tha actual fs that it has snapshotted
-	 * unmounted, so we do this before receiving anything.
-	 */
-	zfsName := fmt.Sprintf("containers/%s", project.Prefix(args.Container.Project(), args.Container.Name()))
-	containerMntPoint := getContainerMountPoint(args.Container.Project(), s.pool.Name, args.Container.Name())
-	if shared.IsMountPoint(containerMntPoint) {
-		err := zfsUmount(poolName, zfsName, containerMntPoint)
-		if err != nil {
-			return err
-		}
+	// Destroy the pre-existing (empty) dataset, this avoids issues with encryption
+	err := zfsPoolVolumeDestroy(poolName, zfsName)
+	if err != nil {
+		return err
 	}
 
 	if len(args.Snapshots) > 0 {


More information about the lxc-devel mailing list