From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53540) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W11Ln-00017D-94 for qemu-devel@nongnu.org; Wed, 08 Jan 2014 17:11:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W11Li-0000dZ-0Q for qemu-devel@nongnu.org; Wed, 08 Jan 2014 17:11:47 -0500 Received: from mail-ea0-x232.google.com ([2a00:1450:4013:c01::232]:50560) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W11Lh-0000dM-P0 for qemu-devel@nongnu.org; Wed, 08 Jan 2014 17:11:41 -0500 Received: by mail-ea0-f178.google.com with SMTP id d10so1113006eaj.9 for ; Wed, 08 Jan 2014 14:11:41 -0800 (PST) Sender: Paolo Bonzini Message-ID: <52CDCD17.8070508@redhat.com> Date: Wed, 08 Jan 2014 23:11:35 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <20140102161503.GA14565@redhat.com> <52CC13D6.6000607@redhat.com> <20140107202708.GB1273@redhat.com> <52CC6811.4000107@redhat.com> <20140107212210.GB4802@redhat.com> In-Reply-To: <20140107212210.GB4802@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] TRIM/DISCARD/UNMAP support on qemu-nbd List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Richard W.M. Jones" Cc: Teng-Feng Yang , qemu-devel@nongnu.org Il 07/01/2014 22:22, Richard W.M. Jones ha scritto: > On Tue, Jan 07, 2014 at 09:48:17PM +0100, Paolo Bonzini wrote: >> Il 07/01/2014 21:27, Richard W.M. Jones ha scritto: >>> Not much more what I said in the original email (especially see the >>> attached script which you can download from the bottom of this page: >>> https://lists.gnu.org/archive/html/qemu-devel/2014-01/msg00084.html ) >>> >>> Basically it tries to dd /dev/zero into the virtio-scsi device exposed >>> by qemu, then calls sg_unmap (there are two devices, it only unmaps >>> the first so we can hopefully see the difference), but it doesn't seem >>> to have any effect on the underlying file. The underlying file is a >>> regular raw-format file on ext4. >>> >>> I called sg_readcap/sg_vpd and we seem to have all the right >>> capability bits exposed. >>> >>> This script won't work with regular libguestfs. I compiled a special >>> appliance that had the sg tools included. >> >> Try again with the pull request of >> http://permalink.gmane.org/gmane.comp.emulators.qemu/248421 > > No difference from before, as far as I can see. > > Here is the output of sparsetest.sh: Is guestfish using "discard=on"? Here is my test: $ qemu-img create test.img 32M Formatting 'test.img', fmt=raw size=33554432 $ qemu-img map --output=json test.img [{ "start": 0, "length": 33554432, "depth": 0, "zero": true, "data": false, "offset": 0}] $ qemu-system-x86_64 ~/rhel6.img \ -drive if=none,cache=none,discard=on,file=test.img,id=test \ -device virtio-scsi-pci -device scsi-disk,drive=test \ --enable-kvm -m 512 ======== In guest ======== # sg_readcap /dev/sdb Device size: 33554432 bytes, 32.0 MiB, 0.03 GB # cat /sys/block/sdb/device/scsi_disk/*/provisioning_mode unmap # yes | mkfs.ext4 /dev/sdb # mount /dev/sdb test # dd if=/dev/zero of=test/test bs=1M $ du -sh test.img 32M test.img ======== In guest ======== # rm xfs/test (sync here if it does not work) # fstrim -v xfs/ xfs/: 27891712 bytes were trimmed $ du -sh test.img 5.2M test.img