From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37906) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WN2nb-00012D-8l for qemu-devel@nongnu.org; Mon, 10 Mar 2014 12:11:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WN2nV-0000eV-8Y for qemu-devel@nongnu.org; Mon, 10 Mar 2014 12:11:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55403) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WN2nV-0000eN-02 for qemu-devel@nongnu.org; Mon, 10 Mar 2014 12:11:25 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s2AGBMKE031808 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 10 Mar 2014 12:11:22 -0400 Date: Mon, 10 Mar 2014 16:11:20 +0000 From: "Richard W.M. Jones" Message-ID: <20140310161119.GA6744@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] Trying to get fstrim / discard=unmap to work List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com 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=3Dunmap /home/rjones/d/qemu/x86_64-softmmu/qemu-system-x86_64 -L /home/rjones/d/qem= u/pc-bios -global virtio-blk-pci.scsi=3Doff -nodefconfig -enable-fips -node= faults -display none -machine accel=3Dkvm:tcg -m 500 -no-reboot -rtc driftf= ix=3Dslew -no-hpet -global kvm-pit.lost_tick_policy=3Ddiscard -kernel /home= /rjones/d/libguestfs/tmp/.guestfs-1000/appliance.d/kernel -initrd /home/rjo= nes/d/libguestfs/tmp/.guestfs-1000/appliance.d/initrd -device virtio-scsi-p= ci,id=3Dscsi -drive file=3D/home/rjones/d/libguestfs/test1.img,cache=3Dwrit= eback,discard=3Dunmap,format=3Draw,id=3Dhd0,if=3Dnone -device scsi-hd,drive= =3Dhd0 -drive file=3D/home/rjones/d/libguestfs/tmp/.guestfs-1000/appliance.= d/root,snapshot=3Don,id=3Dappliance,cache=3Dunsafe,if=3Dnone -device scsi-h= d,drive=3Dappliance -device virtio-serial-pci -serial stdio -device sga -ch= ardev socket,path=3D/home/rjones/d/libguestfs/tmp/libguestfsSwrSCg/guestfsd= =2Esock,id=3Dchannel0 -device virtserialport,chardev=3Dchannel0,name=3Dorg.= libguestfs.channel.0 -append "panic=3D1 console=3DttyS0 udevtimeout=3D600 n= o_timer_check acpi=3Doff printk.time=3D1 cgroup_disable=3Dmemory root=3D/de= v/sdb selinux=3D0 TERM=3Dxterm-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=20 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=20 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=20 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. --=20 Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjon= es 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/