Skip to content

Commit

Permalink
lxd/storage/drivers/volume: only apply volume.size on block volumes
Browse files Browse the repository at this point in the history
Signed-off-by: hamistao <[email protected]>
  • Loading branch information
hamistao committed Jan 21, 2025
1 parent 4741e27 commit 16a7426
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions lxd/storage/drivers/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -470,16 +470,23 @@ func (v Volume) ConfigBlockMountOptions() string {
// or pool's volume config, otherwise for block volumes and block-backed volumes the defaultBlockSize. For other
// volumes an empty string is returned if no size is defined.
func (v Volume) ConfigSize() string {
size := v.ExpandedConfig("size")
size, ok := v.config["size"]
if ok && size != "0" {
return size
}

// If volume size isn't defined on the volume config, then for block volumes or block-backed
// volumes return the size from the pool config, if defined, or the driver's DefaultBlockSize.
if !(v.contentType == ContentTypeBlock || v.IsBlockBacked()) {
return size
}

// If volume size isn't defined in either volume or pool config, then for block volumes or block-backed
// volumes return the defaultBlockSize.
if (size == "" || size == "0") && (v.contentType == ContentTypeBlock || v.IsBlockBacked()) {
return v.driver.Info().DefaultBlockSize
size = v.ExpandedConfig("size")
if size != "" && size != "0" {
return size
}

// Return defined size or empty string if not defined.
return size
return v.driver.Info().DefaultBlockSize
}

// ConfigSizeFromSource derives the volume size to use for a new volume when copying from a source volume.
Expand Down

0 comments on commit 16a7426

Please sign in to comment.