Skip to content

Commit d646d67

Browse files
Bypass secondary storage for copy volume between zone-wide pools and host in the zone
1 parent e574259 commit d646d67

File tree

2 files changed

+23
-12
lines changed

2 files changed

+23
-12
lines changed

engine/api/src/main/java/org/apache/cloudstack/engine/subsystem/api/storage/HostScope.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.apache.cloudstack.utils.reflectiontostringbuilderutils.ReflectionToStringBuilderUtils;
2323

2424
public class HostScope extends AbstractScope {
25+
private ScopeType type = ScopeType.HOST;
2526
private Long hostId;
2627
private Long clusterId;
2728
private Long zoneId;
@@ -35,7 +36,7 @@ public HostScope(Long hostId, Long clusterId, Long zoneId) {
3536

3637
@Override
3738
public ScopeType getScopeType() {
38-
return ScopeType.HOST;
39+
return this.type;
3940
}
4041

4142
@Override

engine/storage/datamotion/src/main/java/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ protected Answer copyVolumeBetweenPools(DataObject srcData, DataObject destData)
363363

364364
if (cacheStore == null) {
365365
if (bypassSecondaryStorage) {
366+
logger.debug("Secondary storage is bypassed, copy volume between pools directly");
366367
CopyCommand cmd = new CopyCommand(srcData.getTO(), destData.getTO(), _copyvolumewait, VirtualMachineManager.ExecuteInSequence.value());
367368
EndPoint ep = selector.select(srcData, destData, encryptionRequired);
368369
Answer answer = null;
@@ -462,9 +463,8 @@ private boolean canBypassSecondaryStorage(DataObject srcData, DataObject destDat
462463
if (destData instanceof VolumeInfo) {
463464
Scope srcDataStoreScope = srcData.getDataStore().getScope();
464465
Scope destDataStoreScope = destData.getDataStore().getScope();
465-
logger.info("srcDataStoreScope: {}, destDataStoreScope: {}", srcDataStoreScope, destDataStoreScope);
466-
logger.info("srcData - pool type: {}, scope: {}; destData - pool type: {}, scope: {}",
467-
((VolumeInfo)srcData).getStoragePoolType(), srcDataStoreScope != null ? srcDataStoreScope.getScopeType() : null, ((VolumeInfo)destData).getStoragePoolType(), destDataStoreScope != null ? destDataStoreScope.getScopeType() : null);
466+
logger.info("srcDataStoreScope: {}, srcData pool type: {}; destDataStoreScope: {}, destData pool type: {}",
467+
srcDataStoreScope, ((VolumeInfo)srcData).getStoragePoolType(), destDataStoreScope, ((VolumeInfo)destData).getStoragePoolType());
468468

469469
if (srcDataStoreScope != null && destDataStoreScope != null &&
470470
SUPPORTED_POOL_TYPES_TO_BYPASS_SECONDARY_STORE.contains(((VolumeInfo)srcData).getStoragePoolType()) &&
@@ -474,16 +474,26 @@ private boolean canBypassSecondaryStorage(DataObject srcData, DataObject destDat
474474
return true;
475475
}
476476

477-
if (srcDataStoreScope.getScopeType() == ScopeType.CLUSTER &&
478-
destDataStoreScope.getScopeType() == ScopeType.HOST &&
479-
(Objects.equals(((ClusterScope) srcDataStoreScope).getScopeId(), ((HostScope) destDataStoreScope).getClusterId()))) {
480-
return true;
477+
if (srcDataStoreScope.getScopeType() == ScopeType.HOST) {
478+
if (destDataStoreScope.getScopeType() == ScopeType.CLUSTER &&
479+
(Objects.equals(((HostScope) srcDataStoreScope).getClusterId(), ((ClusterScope) destDataStoreScope).getScopeId()))) {
480+
return true;
481+
}
482+
if (destDataStoreScope.getScopeType() == ScopeType.ZONE &&
483+
(Objects.equals(((HostScope) srcDataStoreScope).getZoneId(), ((ZoneScope) destDataStoreScope).getScopeId()))) {
484+
return true;
485+
}
481486
}
482487

483-
if (srcDataStoreScope.getScopeType() == ScopeType.HOST &&
484-
destDataStoreScope.getScopeType() == ScopeType.CLUSTER &&
485-
(Objects.equals(((HostScope) srcDataStoreScope).getClusterId(), ((ClusterScope) destDataStoreScope).getScopeId()))) {
486-
return true;
488+
if (destDataStoreScope.getScopeType() == ScopeType.HOST) {
489+
if (srcDataStoreScope.getScopeType() == ScopeType.CLUSTER &&
490+
(Objects.equals(((ClusterScope) srcDataStoreScope).getScopeId(), ((HostScope) destDataStoreScope).getClusterId()))) {
491+
return true;
492+
}
493+
if (srcDataStoreScope.getScopeType() == ScopeType.ZONE &&
494+
(Objects.equals(((ZoneScope) srcDataStoreScope).getScopeId(), ((HostScope) destDataStoreScope).getZoneId()))) {
495+
return true;
496+
}
487497
}
488498
}
489499
}

0 commit comments

Comments
 (0)