From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:46837) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uff2g-0005DN-HI for qemu-devel@nongnu.org; Thu, 23 May 2013 19:35:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uff2f-0001dy-4x for qemu-devel@nongnu.org; Thu, 23 May 2013 19:35:30 -0400 Received: from atl4mhob05.myregisteredsite.com ([209.17.115.43]:40394) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uff2e-0001dr-Vw for qemu-devel@nongnu.org; Thu, 23 May 2013 19:35:29 -0400 From: "Mark Trumpold" Message-ID: Date: Thu, 23 May 2013 23:35:24 +0000 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] 'qemu-nbd' explicit flush List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Mark Trumpold , Paolo Bonzini , Stefan Hajnoczi Cc: qemu-devel@nongnu.org, markt@tachyon.net I had one question I forgot to ask.. Is it possible to switch from '--cache=3Dwriteback' functionality to '--cache=3Dwritethrough' (and visa versa) while qemu-nbd is connected to the '/dev/nbd' device? Thank you, Mark T. -----Original Message----- From: Mark Trumpold [mailto:markt@netqa.com] Sent: Thursday, May 23, 2013 02:58 PM To: 'Paolo Bonzini', 'Stefan Hajnoczi' Cc: 'Mark Trumpold', qemu-devel@nongnu.org, markt@tachyon.net Subject: Re: 'qemu-nbd' explicit flush I have a working configuration using the signal approach suggested by Ste= fan. 'qemu-nbd.c' is patched as follows: do { main_loop_wait(false); + if (sighup_reported) { + sighup_reported =3D false; + bdrv_drain_all(); + bdrv_flush_all(); } } while (!sigterm_reported && (persistent || !nbd_started || nb_fds >= 0)); The driving script was patched as follows: mount -o remount,ro /dev/nbd0 blockdev --flushbufs /dev/nbd0 + kill -HUP I needed to retain 'blockdev --flushbufs' for things to work. Seems the = 'bdrv_flush_all' is flushing what is being missed by the blockdev flush. = I did not go back an retest with 'fsync' or other approaches I had tried= before. Thanks again Paolo and Stefan for your help!! Regards, Mark T. -----Original Message----- From: Paolo Bonzini [mailto:pbonzini@redhat.com] Sent: Wednesday, May 22, 2013 04:07 AM To: 'Stefan Hajnoczi' Cc: 'Mark Trumpold', qemu-devel@nongnu.org, markt@tachyon.net Subject: Re: 'qemu-nbd' explicit flush Il 22/05/2013 11:47, Stefan Hajnoczi ha scritto: > On Tue, May 21, 2013 at 08:01:10PM +0000, Mark Trumpold wrote: >> Linux kernel 3.3.1 with Qemu patch to enable kernel flushing: >> http://thread.gmane.org/gmane.linux.drivers.nbd.general/1108 > > Did you check that the kernel is sending NBD_FLUSH commands? You can > use tcpdump and then check the captured network traffic. > >> Usage example: >> 'qemu-nbd --cache=3Dwriteback -c /dev/nbd0 /images/my-qcow.img' >> 'mount /dev/nbd0 /my-mount-point' >> >> Everything does flush correctly when I first unmount and then disconne= ct the device; however, in my case I am not able to unmount things before= snapshotting. >> >> I tried several approaches externally to flush the device. For exampl= e: >> 'mount -o remount,ro /dev/nbd0' >> 'blockdev --flushbufs /dev/nbd0' > > Did you try plain old sync(1)? This could also work: dd if=3D/dev/zero of=3Ddummy oflag=3Dsync bs=3D512 count=3D1 > 1. Add a signal handler (like SIGHUP or SIGUSR1) to qemu-nbd which > flushes all exports. That would be a useful addition anyway. Paolo