Skip to content

Commit 7fbd0a9

Browse files
authored
linstor: enable discard for Linstor storage pools (#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 4459772 commit 7fbd0a9

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
@@ -3128,6 +3128,9 @@ public int compare(final DiskTO arg0, final DiskTO arg1) {
31283128
else {
31293129
disk.defBlockBasedDisk(physicalDisk.getPath(), devId, diskBusType);
31303130
}
3131+
if (pool.getType() == StoragePoolType.Linstor) {
3132+
disk.setDiscard(DiscardType.UNMAP);
3133+
}
31313134
} else {
31323135
if (volume.getType() == Volume.Type.DATADISK && !(isWindowsTemplate && isUefiEnabled)) {
31333136
disk.defFileBasedDisk(physicalDisk.getPath(), devId, diskBusTypeData, DiskDef.DiskFmtType.QCOW2);
@@ -3474,6 +3477,9 @@ public synchronized String attachOrDetachDisk(final Connect conn,
34743477
diskdef.defFileBasedDisk(attachingDisk.getPath(), devId, busT, DiskDef.DiskFmtType.QCOW2);
34753478
} else if (attachingDisk.getFormat() == PhysicalDiskFormat.RAW) {
34763479
diskdef.defBlockBasedDisk(attachingDisk.getPath(), devId, busT);
3480+
if (attachingPool.getType() == StoragePoolType.Linstor) {
3481+
diskdef.setDiscard(DiscardType.UNMAP);
3482+
}
34773483
}
34783484
if (bytesReadRate != null && bytesReadRate > 0) {
34793485
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
@@ -1444,6 +1444,9 @@ protected synchronized void attachOrDetachDisk(final Connect conn, final boolean
14441444
diskdef.defFileBasedDisk(attachingDisk.getPath(), devId, busT, DiskDef.DiskFmtType.QCOW2);
14451445
} else if (attachingDisk.getFormat() == PhysicalDiskFormat.RAW) {
14461446
diskdef.defBlockBasedDisk(attachingDisk.getPath(), devId, busT);
1447+
if (attachingPool.getType() == StoragePoolType.Linstor) {
1448+
diskdef.setDiscard(DiscardType.UNMAP);
1449+
}
14471450
}
14481451

14491452
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)