The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/8172
This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) ===
From 7cad91eccb88fc38a221d0bec30adaa2970216f1 Mon Sep 17 00:00:00 2001 From: Thomas Parrott <thomas.parr...@canonical.com> Date: Fri, 20 Nov 2020 10:44:38 +0000 Subject: [PATCH 1/2] lxd/db/storage/volumes: Adds content type constants and populates ContentType field in storagePoolVolumeGetType Signed-off-by: Thomas Parrott <thomas.parr...@canonical.com> --- lxd/db/storage_volumes.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lxd/db/storage_volumes.go b/lxd/db/storage_volumes.go index 19ba3a3045..16a834c7a6 100644 --- a/lxd/db/storage_volumes.go +++ b/lxd/db/storage_volumes.go @@ -278,6 +278,13 @@ func (c *Cluster) storagePoolVolumeGetType(project string, volumeName string, vo storageVolume.Config = volumeConfig storageVolume.Location = volumeNode + // Populate volume's ContentType based on volume type (this is before custom block volumes were supported). + // The ContentType field is used for volume mount ref counting so important it is consistently populated. + storageVolume.ContentType = StoragePoolVolumeContentTypeNameFS + if volumeType == StoragePoolVolumeTypeVM { + storageVolume.ContentType = StoragePoolVolumeContentTypeNameBlock + } + return volumeID, &storageVolume, nil } @@ -523,6 +530,18 @@ const ( StoragePoolVolumeTypeNameCustom string = "custom" ) +// Content types. +const ( + StoragePoolVolumeContentTypeFS = iota + StoragePoolVolumeContentTypeBlock +) + +// Content type names. +const ( + StoragePoolVolumeContentTypeNameFS string = "filesystem" + StoragePoolVolumeContentTypeNameBlock string = "block" +) + // StorageVolumeArgs is a value object holding all db-related details about a // storage volume. type StorageVolumeArgs struct { From 030ca18bff04fda53b351f8fc1860945345b83e0 Mon Sep 17 00:00:00 2001 From: Thomas Parrott <thomas.parr...@canonical.com> Date: Fri, 20 Nov 2020 10:45:12 +0000 Subject: [PATCH 2/2] lxd/storage/backend/lxd: Use volume's ContentType field in MountCustomVolume Signed-off-by: Thomas Parrott <thomas.parr...@canonical.com> --- lxd/storage/backend_lxd.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lxd/storage/backend_lxd.go b/lxd/storage/backend_lxd.go index f7040022c1..68948a9211 100644 --- a/lxd/storage/backend_lxd.go +++ b/lxd/storage/backend_lxd.go @@ -2923,7 +2923,7 @@ func (b *lxdBackend) MountCustomVolume(projectName, volName string, op *operatio // Get the volume name on storage. volStorageName := project.StorageVolume(projectName, volName) - vol := b.newVolume(drivers.VolumeTypeCustom, drivers.ContentTypeFS, volStorageName, volume.Config) + vol := b.newVolume(drivers.VolumeTypeCustom, drivers.ContentType(volume.ContentType), volStorageName, volume.Config) return b.driver.MountVolume(vol, op) }
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel