From 1ed8558f6f71316919101fe353f78a316b627bc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20Peliz=C3=A4us?= Date: Mon, 9 Oct 2023 08:53:29 +0000 Subject: [PATCH] lxd/storage/drivers/powerflex: Add volume migration support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julian Pelizäus --- lxd/storage/drivers/driver_powerflex.go | 43 ++++++++++++++++++- .../drivers/driver_powerflex_volumes.go | 4 +- 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/lxd/storage/drivers/driver_powerflex.go b/lxd/storage/drivers/driver_powerflex.go index 78162d22b065..a7871e421bae 100644 --- a/lxd/storage/drivers/driver_powerflex.go +++ b/lxd/storage/drivers/driver_powerflex.go @@ -202,5 +202,46 @@ func (d *powerflex) GetResources() (*api.ResourcesStoragePool, error) { // MigrationType returns the type of transfer methods to be used when doing migrations between pools in preference order. func (d *powerflex) MigrationTypes(contentType ContentType, refresh bool, copySnapshots bool) []migration.Type { - return []migration.Type{} + var rsyncFeatures []string + + // Do not pass compression argument to rsync if the associated + // config key, that is rsync.compression, is set to false. + if shared.IsFalse(d.Config()["rsync.compression"]) { + rsyncFeatures = []string{"xattrs", "delete", "bidirectional"} + } else { + rsyncFeatures = []string{"xattrs", "delete", "compress", "bidirectional"} + } + + if refresh { + var transportType migration.MigrationFSType + + if IsContentBlock(contentType) { + transportType = migration.MigrationFSType_BLOCK_AND_RSYNC + } else { + transportType = migration.MigrationFSType_RSYNC + } + + return []migration.Type{ + { + FSType: transportType, + Features: rsyncFeatures, + }, + } + } + + if contentType == ContentTypeBlock { + return []migration.Type{ + { + FSType: migration.MigrationFSType_BLOCK_AND_RSYNC, + Features: rsyncFeatures, + }, + } + } + + return []migration.Type{ + { + FSType: migration.MigrationFSType_RSYNC, + Features: rsyncFeatures, + }, + } } diff --git a/lxd/storage/drivers/driver_powerflex_volumes.go b/lxd/storage/drivers/driver_powerflex_volumes.go index f368975fcad4..4851441d30ed 100644 --- a/lxd/storage/drivers/driver_powerflex_volumes.go +++ b/lxd/storage/drivers/driver_powerflex_volumes.go @@ -248,7 +248,7 @@ func (d *powerflex) CreateVolumeFromCopy(vol Volume, srcVol Volume, copySnapshot // CreateVolumeFromMigration creates a volume being sent via a migration. func (d *powerflex) CreateVolumeFromMigration(vol Volume, conn io.ReadWriteCloser, volTargetArgs migration.VolumeTargetArgs, preFiller *VolumeFiller, op *operations.Operation) error { - return ErrNotSupported + return genericVFSCreateVolumeFromMigration(d, nil, vol, conn, volTargetArgs, preFiller, op) } // RefreshVolume updates an existing volume to match the state of another. @@ -719,7 +719,7 @@ func (d *powerflex) RenameVolume(vol Volume, newVolName string, op *operations.O // MigrateVolume sends a volume for migration. func (d *powerflex) MigrateVolume(vol Volume, conn io.ReadWriteCloser, volSrcArgs *migration.VolumeSourceArgs, op *operations.Operation) error { - return ErrNotSupported + return genericVFSMigrateVolume(d, d.state, vol, conn, volSrcArgs, op) } // BackupVolume creates an exported version of a volume.