[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] Trying to get fstrim / discard=unmap to work
From: |
Richard W.M. Jones |
Subject: |
[Qemu-devel] Trying to get fstrim / discard=unmap to work |
Date: |
Mon, 10 Mar 2014 16:11:20 +0000 |
User-agent: |
Mutt/1.5.20 (2009-12-10) |
I'm trying to get fstrim in a guest to cause the host disk to become
sparse, without success so far. I wonder if anyone can see what I'm
missing?
Guest:
- guest kernel: 3.13.4-200.fc20.x86_64
- ext4 guest filesystem
- fstrim from util-linux 2.24.1
- cat /sys/block/sda/device/scsi_disk/*/provisioning_mode
unmap
Qemu:
- qemu from git today (e9d818b8b1a)
- Drive uses virtio-scsi
- Drive uses discard=unmap
/home/rjones/d/qemu/x86_64-softmmu/qemu-system-x86_64 -L
/home/rjones/d/qemu/pc-bios -global virtio-blk-pci.scsi=off -nodefconfig
-enable-fips -nodefaults -display none -machine accel=kvm:tcg -m 500 -no-reboot
-rtc driftfix=slew -no-hpet -global kvm-pit.lost_tick_policy=discard -kernel
/home/rjones/d/libguestfs/tmp/.guestfs-1000/appliance.d/kernel -initrd
/home/rjones/d/libguestfs/tmp/.guestfs-1000/appliance.d/initrd -device
virtio-scsi-pci,id=scsi -drive
file=/home/rjones/d/libguestfs/test1.img,cache=writeback,discard=unmap,format=raw,id=hd0,if=none
-device scsi-hd,drive=hd0 -drive
file=/home/rjones/d/libguestfs/tmp/.guestfs-1000/appliance.d/root,snapshot=on,id=appliance,cache=unsafe,if=none
-device scsi-hd,drive=appliance -device virtio-serial-pci -serial stdio
-device sga -chardev
socket,path=/home/rjones/d/libguestfs/tmp/libguestfsSwrSCg/guestfsd.sock,id=channel0
-device virtserialport,chardev=channel0,name=org.libguestfs.channel.0 -append
"panic=1 console=ttyS0 udevtimeout=600 no_timer_check acpi=off printk.time=1
cgroup_disable=memory root=/dev/sdb selinux=0 TERM=xterm-256color"
Host:
- host kernel: 3.12.5-302.fc20.x86_64
- ext4 host filesystem
- backed by m-SATA SDD
Methodology:
(0) Observe the file size on host:
$ ls -ls test1.img
0 -rw-rw-r--. 1 rjones rjones 1073741824 Mar 10 16:08 test1.img
^
+---- sparse file, 0 blocks used
(1) Create an ext4 filesystem on /dev/sda in the guest.
(2) Create a big data file of random data (10 MB) & sync.
(3) Observe the file size on the host:
$ ls -ls test1.img
59804 -rw-rw-r--. 1 rjones rjones 1073741824 Mar 10 16:09 test1.img
(4) rm /data in guest
(5) fstrim / in guest [actually, I do this several times]
(6) sync
(6) Observe the file size on host:
$ ls -ls test1.img
59804 -rw-rw-r--. 1 rjones rjones 1073741824 Mar 10 16:10 test1.img
Unchanged! I'm expecting the first number (59804 blocks) to get
substantially smaller.
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine. Supports Linux and Windows.
http://people.redhat.com/~rjones/virt-df/
- [Qemu-devel] Trying to get fstrim / discard=unmap to work,
Richard W.M. Jones <=