Skip to content

Commit 4896572

Browse files
rp-dhslove
authored andcommitted
linstor: enable discard for Linstor storage pools (apache#9770)
* linstor: enable discard for Linstor storage pools All Linstor storage backends support discard, so it can be safely enabled. * linstor: enable discard for Linstor storage pools CHANGELOG.md
1 parent afb1570 commit 4896572

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3458,6 +3458,9 @@ public int compare(final DiskTO arg0, final DiskTO arg1) {
34583458
else {
34593459
disk.defBlockBasedDisk(physicalDisk.getPath(), devId, diskBusType);
34603460
}
3461+
if (pool.getType() == StoragePoolType.Linstor) {
3462+
disk.setDiscard(DiscardType.UNMAP);
3463+
}
34613464
} else {
34623465
if (volume.getType() == Volume.Type.DATADISK && !(isWindowsTemplate && isUefiEnabled)) {
34633466
disk.defFileBasedDisk(physicalDisk.getPath(), devId, diskBusTypeData, DiskDef.DiskFmtType.QCOW2);
@@ -3808,6 +3811,9 @@ public synchronized String attachOrDetachDisk(final Connect conn,
38083811
diskdef.defFileBasedDisk(attachingDisk.getPath(), devId, busT, DiskDef.DiskFmtType.QCOW2);
38093812
} else if (attachingDisk.getFormat() == PhysicalDiskFormat.RAW) {
38103813
diskdef.defBlockBasedDisk(attachingDisk.getPath(), devId, busT);
3814+
if (attachingPool.getType() == StoragePoolType.Linstor) {
3815+
diskdef.setDiscard(DiscardType.UNMAP);
3816+
}
38113817
}
38123818
if (bytesReadRate != null && bytesReadRate > 0) {
38133819
diskdef.setBytesReadRate(bytesReadRate);

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1493,6 +1493,9 @@ protected synchronized void attachOrDetachDisk(final Connect conn, final boolean
14931493
diskdef.defFileBasedDisk(attachingDisk.getPath(), devId, busT, DiskDef.DiskFmtType.QCOW2);
14941494
} else if (attachingDisk.getFormat() == PhysicalDiskFormat.RAW) {
14951495
diskdef.defBlockBasedDisk(attachingDisk.getPath(), devId, busT);
1496+
if (attachingPool.getType() == StoragePoolType.Linstor) {
1497+
diskdef.setDiscard(DiscardType.UNMAP);
1498+
}
14961499
}
14971500

14981501
if (encryptDetails != null) {

plugins/storage/volume/linstor/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to Linstor CloudStack plugin will be documented in this file
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [2024-10-04]
9+
10+
### Added
11+
12+
- Enable qemu discard="unmap" for Linstor block disks
13+
814
## [2024-08-27]
915

1016
### Changed

0 commit comments

Comments
 (0)