Skip to content

Commit

Permalink
core: update actual size after conversion
Browse files Browse the repository at this point in the history
The actual size of a volume is reduced when converting the disk from
COW/preallocated to COW/thin on a block storage domain is not updated,
making it seem like disk consumes more than it actually does.

This patch updates the actual size after conversion.

Bug-Url: https://bugzilla.redhat.com/2086561
Signed-off-by: Benny Zlotnik <bzlotnik@redhat.com>
  • Loading branch information
bennyz committed Jun 26, 2022
1 parent 0e52e51 commit ccf7707
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.ovirt.engine.core.common.businessentities.VM;
import org.ovirt.engine.core.common.businessentities.VdsmImageLocationInfo;
import org.ovirt.engine.core.common.businessentities.storage.DiskImage;
import org.ovirt.engine.core.common.businessentities.storage.DiskImageDynamic;
import org.ovirt.engine.core.common.businessentities.storage.ImageStatus;
import org.ovirt.engine.core.common.businessentities.storage.VolumeFormat;
import org.ovirt.engine.core.common.businessentities.storage.VolumeType;
Expand All @@ -46,6 +47,7 @@
import org.ovirt.engine.core.compat.Guid;
import org.ovirt.engine.core.dao.BaseDiskDao;
import org.ovirt.engine.core.dao.DiskImageDao;
import org.ovirt.engine.core.dao.DiskImageDynamicDao;
import org.ovirt.engine.core.dao.ImageDao;
import org.ovirt.engine.core.dao.StorageDomainDao;
import org.ovirt.engine.core.dao.VmDao;
Expand All @@ -57,6 +59,9 @@ public class ConvertDiskCommand<T extends ConvertDiskCommandParameters> extends
@Inject
private DiskImageDao diskImageDao;

@Inject
private DiskImageDynamicDao diskImageDynamicDao;

@Inject
private ImageDao imageDao;

Expand Down Expand Up @@ -298,6 +303,9 @@ private boolean switchImage() {
DiskImage newImage = DiskImage.copyOf(getDiskImage());
newImage.setImageId(getParameters().getNewVolGuid());
newImage.setSize(info.getSize());
DiskImageDynamic diskImageDynamic = new DiskImageDynamic();
diskImageDynamic.setId(newImage.getImageId());
diskImageDynamic.setActualSize(info.getActualSizeInBytes());
if (getParameters().getVolumeFormat() != null) {
if (info.getVolumeFormat() != getParameters().getVolumeFormat()) {
log.error("Requested format '{}' doesn't match format on storage '{}'",
Expand All @@ -323,6 +331,7 @@ private boolean switchImage() {
TransactionSupport.executeInNewTransaction(() -> {
addDiskImageToDb(newImage, getCompensationContext(), true);
imageDao.update(getDiskImage().getImage());
diskImageDynamicDao.update(diskImageDynamic);

return null;
});
Expand Down

0 comments on commit ccf7707

Please sign in to comment.