this patch will add the discard-options to ganeti (KVM only), it can be helpful if you are using ext-storage (iSCSI) or ceph (RBD) so free space on a SAN is possible
diff --git a/lib/hypervisor/hv_kvm/__init__.py b/lib/hypervisor/hv_kvm/__init__.py index 1f4184d..c1838ae 100644 --- a/lib/hypervisor/hv_kvm/__init__.py +++ b/lib/hypervisor/hv_kvm/__init__.py @@ -488,6 +488,8 @@ class KVMHypervisor(hv_base.BaseHypervisor): hv_base.ParamInSet(True, constants.HT_KVM_VALID_DISK_TYPES), constants.HV_KVM_SCSI_CONTROLLER_TYPE: hv_base.ParamInSet(True, constants.HT_KVM_VALID_SCSI_CONTROLLER_TYPES), + constants.HV_DISK_DISCARD: + hv_base.ParamInSet(False, constants.HT_VALID_DISCARD_TYPES), constants.HV_KVM_CDROM_DISK_TYPE: hv_base.ParamInSet(False, constants.HT_KVM_VALID_DISK_TYPES), constants.HV_USB_MOUSE: @@ -1112,6 +1114,12 @@ class KVMHypervisor(hv_base.BaseHypervisor): aio_val = ",aio=%s" % aio_mode else: aio_val = "" + # discard mode + discard_mode = up_hvp[constants.HV_DISK_DISCARD] + if discard_mode == 'unmap': + discard_val = ",discard=unmap" + else: + discard_val = "" # Cache mode disk_cache = up_hvp[constants.HV_DISK_CACHE] for cfdev, link_name, uri in kvm_disks: @@ -1139,8 +1147,8 @@ class KVMHypervisor(hv_base.BaseHypervisor): drive_uri = _GetDriveURI(cfdev, link_name, uri) - drive_val = "file=%s,format=raw%s%s%s%s" % \ - (drive_uri, if_val, boot_val, cache_val, aio_val) + drive_val = "file=%s,format=raw%s%s%s%s%s" % \ + (drive_uri, if_val, boot_val, cache_val, aio_val, discard_val) # virtio-blk-pci case if device_driver is not None: diff --git a/man/gnt-instance.rst b/man/gnt-instance.rst index 493ae92..8fc51d9 100644 --- a/man/gnt-instance.rst +++ b/man/gnt-instance.rst @@ -649,6 +649,14 @@ disk\_aio so if not explicitly specified, the native mode will not be used. Possible values are: threads or native. +disk\_discard + Valid for the KVM hypervisor. + + discard is one of "ignore" or "unmap" and controls whether + discard (also known as trim or unmap) requests are ignored + or passed to the filesystem. + Some machine types may not support discard requests. + security\_model Valid for the KVM hypervisor. diff --git a/src/Ganeti/Constants.hs b/src/Ganeti/Constants.hs index 4aa5edf..614882b 100644 --- a/src/Ganeti/Constants.hs +++ b/src/Ganeti/Constants.hs @@ -1652,6 +1652,9 @@ hvDeviceModel = "device_model" hvDiskCache :: String hvDiskCache = "disk_cache" +hvDiskDiscard :: String +hvDiskDiscard = "disk_discard" + hvDiskType :: String hvDiskType = "disk_type" @@ -1897,6 +1900,7 @@ hvsParameterTypes = Map.fromList , (hvCpuWeight, VTypeInt) , (hvDeviceModel, VTypeString) , (hvDiskCache, VTypeString) + , (hvDiskDiscard, VTypeString) , (hvDiskType, VTypeString) , (hvInitrdPath, VTypeString) , (hvInitScript, VTypeString) @@ -2816,6 +2820,21 @@ htValidCacheTypes = htCacheWback, htCacheWthrough] +htDiscardDefault :: String +htDiscardDefault = "ignore" + +htDiscardIgnore :: String +htDiscardIgnore = "ignore" + +htDiscardUnmap :: String +htDiscardUnmap = "unmap" + +htValidDiscardTypes :: FrozenSet String +htValidDiscardTypes = + ConstantUtils.mkSet [htDiscardDefault, + htDiscardIgnore, + htDiscardUnmap] + htKvmAioThreads :: String htKvmAioThreads = "threads" @@ -4106,6 +4125,7 @@ hvcDefaults = , (hvUseGuestAgent, PyValueEx False) , (hvUseLocaltime, PyValueEx False) , (hvDiskCache, PyValueEx htCacheDefault) + , (hvDiskDiscard, PyValueEx htDiscardDefault) , (hvSecurityModel, PyValueEx htSmNone) , (hvSecurityDomain, PyValueEx "") , (hvKvmFlag, PyValueEx "")