From 42189e272f8975a0e4822f3726fa5f7c700877b2 Mon Sep 17 00:00:00 2001 From: Jesse Pretorius Date: Thu, 23 Aug 2018 14:59:06 +0100 Subject: [PATCH] MNAIO: Use discard option for all mount points Using the discard option for all mount points ensures that the deletes actually release the blocks on the disk. This ensures that SSD performance is optimised and that file-backed images are kept as small as possible. Change-Id: I648cbaca56d75e355cf6c8af01e2e3ad20dfc398 --- multi-node-aio/playbooks/deploy-vms.yml | 2 ++ .../playbooks/pxe/configs/debian/vm.config.j2 | 12 ++++++++++++ .../playbooks/pxe/configs/redhat/vm.config.j2 | 12 ++++++------ 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/multi-node-aio/playbooks/deploy-vms.yml b/multi-node-aio/playbooks/deploy-vms.yml index 3bfa14ab..c1de1948 100644 --- a/multi-node-aio/playbooks/deploy-vms.yml +++ b/multi-node-aio/playbooks/deploy-vms.yml @@ -315,6 +315,7 @@ src: /dev/mapper/vmvg00-machines00 state: mounted fstype: btrfs + opts: defaults,discard - name: Setup cinder host volume @@ -381,6 +382,7 @@ src: "/dev/mapper/vmvg00-{{ item }}" fstype: xfs state: mounted + opts: defaults,discard with_items: - disk1 - disk2 diff --git a/multi-node-aio/playbooks/pxe/configs/debian/vm.config.j2 b/multi-node-aio/playbooks/pxe/configs/debian/vm.config.j2 index 78dd06e4..c21cc5f1 100644 --- a/multi-node-aio/playbooks/pxe/configs/debian/vm.config.j2 +++ b/multi-node-aio/playbooks/pxe/configs/debian/vm.config.j2 @@ -107,6 +107,8 @@ d-i partman-auto/expert_recipe string \ use_filesystem{ } filesystem{ ext2 } \ label{ boot } \ mountpoint{ /boot } \ + options/defaults{ defaults } \ + options/discard{ discard } \ . \ 1024 1 100% ext4 \ $primary{ } \ @@ -126,6 +128,8 @@ d-i partman-auto/expert_recipe string \ use_filesystem{ } filesystem{ ext4 } \ label{ root } \ mountpoint{ / } \ + options/defaults{ defaults } \ + options/discard{ discard } \ . \ 16384 1 16384 ext4 \ $lvmok{ } in_vg{ vmvg00 } \ @@ -134,6 +138,8 @@ d-i partman-auto/expert_recipe string \ use_filesystem{ } filesystem{ ext4 } \ label{ openstack } \ mountpoint{ /openstack } \ + options/defaults{ defaults } \ + options/discard{ discard } \ . \ {% if default_container_tech == 'nspawn' %} 8192 1 24576 btrfs \ @@ -143,6 +149,8 @@ d-i partman-auto/expert_recipe string \ use_filesystem{ } filesystem{ btrfs } \ label{ machines } \ mountpoint{ /var/lib/machines } \ + options/defaults{ defaults } \ + options/discard{ discard } \ . \ {% elif default_container_tech == 'lxc' %} 4096 1 8192 btrfs \ @@ -152,6 +160,8 @@ d-i partman-auto/expert_recipe string \ use_filesystem{ } filesystem{ btrfs } \ label{ machines } \ mountpoint{ /var/lib/machines } \ + options/defaults{ defaults } \ + options/discard{ discard } \ . \ 8192 1 10240000 ext4 \ $lvmok{ } in_vg{ vmvg00 } \ @@ -160,6 +170,8 @@ d-i partman-auto/expert_recipe string \ use_filesystem{ } filesystem{ ext4 } \ label{ lxc } \ mountpoint{ /var/lib/lxc } \ + options/defaults{ defaults } \ + options/discard{ discard } \ . \ {% endif %} diff --git a/multi-node-aio/playbooks/pxe/configs/redhat/vm.config.j2 b/multi-node-aio/playbooks/pxe/configs/redhat/vm.config.j2 index af333d18..32155917 100644 --- a/multi-node-aio/playbooks/pxe/configs/redhat/vm.config.j2 +++ b/multi-node-aio/playbooks/pxe/configs/redhat/vm.config.j2 @@ -18,14 +18,14 @@ clearpart --all --initlabel part /boot --fstype ext3 --size=512 part pv.01 --size=1 --grow volgroup vmvg00 pv.01 -logvol / --fstype ext4 --name=root00 --vgname=vmvg00 --size=8192 +logvol / --fstype ext4 --name=root00 --vgname=vmvg00 --size=8192 --fsoptions=defaults,discard logvol swap --fstype swap --name=swap00 --vgname=vmvg00 --size=2048 -logvol /openstack --fstype ext4 --name=openstack00 --vgname=vmvg00 --size=16384 +logvol /openstack --fstype ext4 --name=openstack00 --vgname=vmvg00 --size=16384 --fsoptions=defaults,discard {% if default_container_tech == 'nspawn' %} -logvol /var/lib/machines --fstype ext4 --name=machines00 --vgname=vmvg00 --size=8192 --grow +logvol /var/lib/machines --fstype ext4 --name=machines00 --vgname=vmvg00 --size=8192 --grow --fsoptions=defaults,discard {% elif default_container_tech == 'lxc' %} -logvol /var/lib/machines --fstype ext4 --name=machines00 --vgname=vmvg00 --size=4096 -logvol /var/lib/lxc --fstype ext4 --name=lxc00 --vgname=vmvg00 --size=8192 --grow +logvol /var/lib/machines --fstype ext4 --name=machines00 --vgname=vmvg00 --size=4096 --fsoptions=defaults,discard +logvol /var/lib/lxc --fstype ext4 --name=lxc00 --vgname=vmvg00 --size=8192 --grow --fsoptions=defaults,discard {% endif %} rootpw secrete repo --name=base --baseurl={{ images[default_vm_image]['image_repo_base_url'] }}/os/x86_64/ @@ -67,7 +67,7 @@ modprobe btrfs umount /dev/vmvg00/machines00 btrfs-convert /dev/vmvg00/machines00 sed -i '/vmvg00-machines00/d' /etc/fstab -echo "/dev/mapper/vmvg00-machines00 /var/lib/machines btrfs defaults 1 2" >> /etc/fstab +echo "/dev/mapper/vmvg00-machines00 /var/lib/machines btrfs defaults,discard 1 2" >> /etc/fstab wget --no-proxy http://{{ tftp_server }}/scripts/vm-post-install-redhat-script.sh -O /opt/vm-post-install-script.sh chmod +x /opt/vm-post-install-script.sh