From bee917d710e19940af8eff2577cf59c63d923460 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 0957f86626b2..0ce772cd708a 100644 --- a/lxd/storage/drivers/driver_powerflex.go +++ b/lxd/storage/drivers/driver_powerflex.go @@ -204,5 +204,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 e049f51d7e54..bbfbd7717a81 100644 --- a/lxd/storage/drivers/driver_powerflex_volumes.go +++ b/lxd/storage/drivers/driver_powerflex_volumes.go @@ -235,7 +235,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. @@ -697,7 +697,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.