Skip to content

Commit

Permalink
lxd/storage/backend_lxd: Prevent usage of optimized image if zfs.bloc…
Browse files Browse the repository at this point in the history
…ksize differs

Signed-off-by: Din Music <[email protected]>
  • Loading branch information
MusicDin committed Sep 25, 2023
1 parent 33f867f commit 61894c9
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lxd/storage/backend_lxd.go
Original file line number Diff line number Diff line change
Expand Up @@ -3444,7 +3444,16 @@ func (b *lxdBackend) shouldUseOptimizedImage(fingerprint string, contentType dri
func volumeConfigsMatch(vol1, vol2 drivers.Volume) bool {
blockModeChanged := vol1.IsBlockBacked() != vol2.IsBlockBacked()
blockFSChanged := vol1.IsBlockBacked() && vol1.Config()["block.filesystem"] != vol2.Config()["block.filesystem"]
return !blockModeChanged && !blockFSChanged

// TODO: Temporary workaround for zfs.blocksize issue:
// When zfs.blocksize changes, a new optimized image isn't generated. This ensures we don't use an
// optimized image if initial.zfs.blocksize differs from the default pool settings.
//
// Note: If initial.zfs.blocksize is set to 8KiB and volume.zfs.blocksize is unset (defaults to 8KiB),
// they're considered unequal ("" != "8KiB"), preventing the use of a matching optimized image.
blockSizeChanged := vol1.IsBlockBacked() && vol1.Config()["zfs.blocksize"] != vol2.Config()["zfs.blocksize"]

return !blockModeChanged && !blockFSChanged && !blockSizeChanged
}

// DeleteImage removes an image from the database and underlying storage device if needed.
Expand Down

0 comments on commit 61894c9

Please sign in to comment.