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 28, 2022
1 parent 0e52e51 commit e4f92ae
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,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 +58,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 +302,8 @@ private boolean switchImage() {
DiskImage newImage = DiskImage.copyOf(getDiskImage());
newImage.setImageId(getParameters().getNewVolGuid());
newImage.setSize(info.getSize());
newImage.setActualSize(info.getActualSize());
newImage.setActualSizeInBytes(info.getActualSizeInBytes());
if (getParameters().getVolumeFormat() != null) {
if (info.getVolumeFormat() != getParameters().getVolumeFormat()) {
log.error("Requested format '{}' doesn't match format on storage '{}'",
Expand All @@ -323,7 +329,6 @@ private boolean switchImage() {
TransactionSupport.executeInNewTransaction(() -> {
addDiskImageToDb(newImage, getCompensationContext(), true);
imageDao.update(getDiskImage().getImage());

return null;
});

Expand Down

0 comments on commit e4f92ae

Please sign in to comment.