qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] Trying to get fstrim / discard=unmap to work
@ 2014-03-10 16:11 Richard W.M. Jones
  2014-03-10 16:14 ` Richard W.M. Jones
  0 siblings, 1 reply; 6+ messages in thread
From: Richard W.M. Jones @ 2014-03-10 16:11 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini


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/

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-03-12 17:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-10 16:11 [Qemu-devel] Trying to get fstrim / discard=unmap to work Richard W.M. Jones
2014-03-10 16:14 ` Richard W.M. Jones
2014-03-10 16:57   ` Paolo Bonzini
2014-03-10 17:15     ` Richard W.M. Jones
2014-03-11 20:00     ` Richard W.M. Jones
2014-03-12 17:55       ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).