From bd6a89939d6a5472582ff6cd90ee04e008205ee9 Mon Sep 17 00:00:00 2001 From: Mike Tutkowski Date: Thu, 29 Jan 2015 15:50:42 -0700 Subject: [PATCH] Adding/updating comments around the volume's hypervisor snapshot reserve field --- .../cloudstack/engine/orchestration/VolumeOrchestrator.java | 6 +++--- .../storage/motion/StorageSystemDataMotionStrategy.java | 2 +- server/src/com/cloud/storage/StorageManagerImpl.java | 5 +++++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java index 7c6d3e24f93..9ddaa9f2883 100644 --- a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java @@ -482,7 +482,7 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati @DB public VolumeInfo createVolume(VolumeInfo volume, VirtualMachine vm, VirtualMachineTemplate template, DataCenter dc, Pod pod, Long clusterId, ServiceOffering offering, DiskOffering diskOffering, List avoids, long size, HypervisorType hyperType) { - // update the volume's hypervisor_ss_reserve from its disk offering (used for managed storage) + // update the volume's hv_ss_reserve (hypervisor snapshot reserve) from a disk offering (used for managed storage) volume = volService.updateHypervisorSnapshotReserveForVolume(diskOffering, volume.getId(), hyperType); StoragePool pool = null; @@ -1235,7 +1235,7 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati DiskOffering diskOffering = _entityMgr.findById(DiskOffering.class, volume.getDiskOfferingId()); HypervisorType hyperType = vm.getVirtualMachine().getHypervisorType(); - // update the volume's hypervisor_ss_reserve from its disk offering (used for managed storage) + // update the volume's hv_ss_reserve (hypervisor snapshot reserve) from a disk offering (used for managed storage) volService.updateHypervisorSnapshotReserveForVolume(diskOffering, volume.getId(), hyperType); volume = volFactory.getVolume(newVol.getId(), destPool); @@ -1255,7 +1255,7 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati DiskOffering diskOffering = _entityMgr.findById(DiskOffering.class, volume.getDiskOfferingId()); HypervisorType hyperType = vm.getVirtualMachine().getHypervisorType(); - // update the volume's hypervisor_ss_reserve from its disk offering (used for managed storage) + // update the volume's hv_ss_reserve (hypervisor snapshot reserve) from a disk offering (used for managed storage) volService.updateHypervisorSnapshotReserveForVolume(diskOffering, volume.getId(), hyperType); long hostId = vm.getVirtualMachine().getHostId(); diff --git a/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/StorageSystemDataMotionStrategy.java b/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/StorageSystemDataMotionStrategy.java index e9244be4f99..3c9334df73f 100644 --- a/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/StorageSystemDataMotionStrategy.java +++ b/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/StorageSystemDataMotionStrategy.java @@ -250,7 +250,7 @@ public class StorageSystemDataMotionStrategy implements DataMotionStrategy { DiskOfferingVO diskOffering = _diskOfferingDao.findByIdIncludingRemoved(volumeInfo.getDiskOfferingId()); SnapshotVO snapshot = _snapshotDao.findById(snapshotInfo.getId()); - // update the volume's hypervisor_ss_reserve from its disk offering (used for managed storage) + // update the volume's hv_ss_reserve (hypervisor snapshot reserve) from a disk offering (used for managed storage) _volumeService.updateHypervisorSnapshotReserveForVolume(diskOffering, volumeInfo.getId(), snapshot.getHypervisorType()); AsyncCallFuture future = _volumeService.createVolumeAsync(volumeInfo, volumeInfo.getDataStore()); diff --git a/server/src/com/cloud/storage/StorageManagerImpl.java b/server/src/com/cloud/storage/StorageManagerImpl.java index ba8925aac3f..bfaa461aa84 100644 --- a/server/src/com/cloud/storage/StorageManagerImpl.java +++ b/server/src/com/cloud/storage/StorageManagerImpl.java @@ -1582,11 +1582,16 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C long allocatedSizeWithtemplate = _capacityMgr.getAllocatedPoolCapacity(poolVO, null); long totalAskingSize = 0; for (Volume volume : volumes) { + // refreshing the volume from the DB to get latest hv_ss_reserve (hypervisor snapshot reserve) field + // I could have just assigned this to "volume", but decided to make a new variable for it so that it + // might be clearer that this "volume" in "volumes" still might have an old value for hv_ss_reverse. VolumeVO volumeVO = _volumeDao.findById(volume.getId()); if (volumeVO.getHypervisorSnapshotReserve() == null) { + // update the volume's hv_ss_reserve (hypervisor snapshot reserve) from a disk offering (used for managed storage) volService.updateHypervisorSnapshotReserveForVolume(getDiskOfferingVO(volumeVO), volumeVO.getId(), getHypervisorType(volumeVO)); + // hv_ss_reserve field might have been updated; refresh from DB to make use of it in getVolumeSizeIncludingHypervisorSnapshotReserve volumeVO = _volumeDao.findById(volume.getId()); }