qemu-devel@nongnu.org
[Top] [All Lists]

Re: [kvm-devel] [Qemu-devel] [PATCH] QEMU: fsync AIO writes on flush req

Subject: Re: [kvm-devel] [Qemu-devel] [PATCH] QEMU: fsync AIO writes on flush request
From: Jamie Lokier
Date: Sat, 29 Mar 2008 01:17:52 +0000
Marcelo Tosatti wrote:
>  static void raw_flush(BlockDriverState *bs)
>  {
>      BDRVRawState *s = bs->opaque;
> -    fsync(s->fd);
> +    raw_aio_flush(bs);
> +
> +    /* We rely on the fact that no other AIO will be submitted
> +     * in parallel, but this should be fixed by per-device
> +     * AIO queues when allowing multiple CPU's to process IO
> +     * in QEMU.
> +     */
> +    qemu_aio_flush();
>  }

It depends what raw_flush() is used for.

If you want to be sure this flushes AIO writes in-flight at the time
of the call, I still reckon you need an extra qemu_aio_flush() before
raw_aio_flush() - on at least some POSIX AIO implementations.  (I'd be
very interested to find out otherwise, if you know better).

But if, as Ian Jackson suggests, raw_flush() is _only_ used when the
guest driver issues a CACHE FLUSH command _and_ the guest driver
either cannot overlap operations, or cannot depend on overlapping
operations occuring in order, then you don't need it.

That'll depend on what kind of device is emulated.  Does the SCSI
emulation handle multiple in-flight commands with any guarantee on
order?  To be on the safe side, I'd include the extra qemu_aio_flush,
as I expect it's very unlikely to harm performance and might save
someone's data.

-- Jamie



<Prev in Thread] Current Thread [Next in Thread>