From 8bb9ff384341b33fc3af27c65aaac1a7b51f275e Mon Sep 17 00:00:00 2001 From: "boh.ricky" Date: Sun, 6 Apr 2014 00:13:48 +0800 Subject: [PATCH] Libvirt-Enable suppport for discard option for disk device Support setting discard option for instance's disk. If discard option is enabled, unused/freed blocks can be return back to the storage device. blueprint libvirt-disk-discard-option Change-Id: Idcf7b35c93422d0d13c3ffb33aca3c5eca4f3c94 --- specs/juno/libvirt-disk-discard-option.rst | 147 +++++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 specs/juno/libvirt-disk-discard-option.rst diff --git a/specs/juno/libvirt-disk-discard-option.rst b/specs/juno/libvirt-disk-discard-option.rst new file mode 100644 index 000000000..30faea96f --- /dev/null +++ b/specs/juno/libvirt-disk-discard-option.rst @@ -0,0 +1,147 @@ +.. + This work is licensed under a Creative Commons Attribution 3.0 Unported + License. + + http://creativecommons.org/licenses/by/3.0/legalcode + +====================================================== +Libvirt-Enable support discard option for disk device +====================================================== + +https://blueprints.launchpad.net/nova/+spec/libvirt-disk-discard-option + +Most SCSI devices have supported UNMAP command which is used to return unused +or freed blocks back to the storage. And SSD drive have a similar command +called "Trim" command. + +This blueprint aims to support setting discard option for instance's disk. +If discard option is enabled, unused/freed blocks can be return back to the +storage device. + +Qemu1.5 has supported setting discard option for the raw disk. In Qemu1.6, +qcow2 file supported discard option too. + +Cinder support is out of scope for this spec. This spec only covers disks +managed by nova. + +Problem description +=================== + +Thin provision volume +--------------------- +When we write data to a thin provision volume, storage device will allocate +blocks to it and it will grow. +But without discard option supported, the blocks will not be freed to the +storage device even if we deleted the data in the volume. The result is the +thin volume can grow, but can't shrink. +With discard option supported, when user deleted the data in the volume, +the blocks will be freed to the storage device. The volume will shrink. + +It's useful for both ephemeral volume and cinder volume. + +SSD backed volume +-------------------- +Freeing the unused blocks to the SSD storage is useful to improving the +performance and prolonging the lifetime of SSD. + +Proposed change +=============== + +Add support for the deployer to specify the discard option in the nova.conf by +"hw_disk_discard". + +There are two available values for "hw_disk_discard" now:: + + "unmap" : Discard requests("trim" or "unmap") are passed to the filesystem. + "ignore": Discard requests("trim" or "unmap") are ignored and aren't passed + to the filesystem. + +For example:: + + hw_disk_discard=unmap #enable discard + hw_disk_discard=ignore #disable discard, by default + +For an instance running on a host which has the discard option in nova.conf, +nova will produce the XML with a discard option when the nova managed disk +is attached. + +Alternatives +------------ +None + +Data model impact +----------------- +None + +REST API impact +--------------- +None + +Security impact +--------------- +None + +Notifications impact +-------------------- +None + +Other end user impact +--------------------- +None + +Performance Impact +------------------ +Discard option maybe cause performance degradation and fragmentation. +But for the storage based on SSD, discard option is good for the performance. + +The users have control over this behaviour in the guest os if they don't want +it. They can use the mount parameter or the command tools to control the +discard behaviour. + +Other deployer impact +--------------------- +Initially, only the libvirt driver will support this function, and +only with qemu/kvm as the hypervisor. + +A serious consideration is needed before enabling discard option. +With discard option enabled, the freed blocks of the thin provision volume +will be return to the storage and can be reused. But it also maybe cause +performance degradation and fragments. +So it's reasonable to enable the discard option only when you use the thin +provision volume and the storage are UNMAP/TRIM-capable. For example the SSD, +the disk-arrays or other distributed storage which supports the UNMAP/TRIM. + +Developer impact +---------------- +None + + +Implementation +============== + +Assignee(s) +----------- +boh.ricky + +Work Items +---------- + +* Libvirt driver will create a discard option for a disk device which the + instance flavor has discard option. + +Dependencies +============ +Libvirt(1.0.6) Qemu1.5(raw format) Qemu1.6(qcow2 format) + +Testing +======= +None + +Documentation Impact +==================== + +The document should be modified to reflect this new feature. + +References +========== +None