From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35401) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WOS6L-0001RZ-3h for qemu-devel@nongnu.org; Fri, 14 Mar 2014 09:24:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WOS6G-0001W8-JS for qemu-devel@nongnu.org; Fri, 14 Mar 2014 09:24:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:24468) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WOS6G-0001Vv-CH for qemu-devel@nongnu.org; Fri, 14 Mar 2014 09:24:36 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s2EDOZfU027060 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 14 Mar 2014 09:24:35 -0400 Date: Fri, 14 Mar 2014 13:24:33 +0000 From: "Richard W.M. Jones" Message-ID: <20140314132433.GS1346@redhat.com> References: <20140313214814.GC1985@redhat.com> <5322F670.50906@redhat.com> <20140314124216.GQ1346@redhat.com> <5322FA7F.3030802@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5322FA7F.3030802@redhat.com> Subject: Re: [Qemu-devel] fstrim & upstream kernel not working List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-devel@nongnu.org On Fri, Mar 14, 2014 at 01:47:59PM +0100, Paolo Bonzini wrote: > Il 14/03/2014 13:42, Richard W.M. Jones ha scritto: > >I worked around this in any case by rearranging the test [2]: > > > >Doing: > > > > rm /a_big_file > > fstrim / > > sync > > umount / > > [shut down qemu] > > > >would only trim 64 KB on the host. > > > >Doing: > > > > rm /a_big_file > > umount / # added > > mount -o nodiscard /dev/sda / # added > > fstrim / > > sync > > umount / > > [shut down qemu] > > > >would trim the expected amount (around 10 MB). > > > >I've no idea why this is (looks like an ext4/kernel bug to me), but in > >any case the tests now use the second method[2]. > > Could be a race condition (something going on in the background > between rm and fstrim). Not much happens in the libguestfs appliance. There are usually only two processes (udev + guestfsd). > Try syncing before fstrim, not after. In > fact the sync before umount should not be necessary. Yes, that works with both upstream kernel+qemu and with F21 kernel+qemu. https://github.com/libguestfs/libguestfs/commit/d46ceea6014006ab19b6f795e2e28a7360d90b2c Thanks, Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://libguestfs.org