All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jamie Lokier <jamie@shareable.org>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [4367] Align file accesses with cache=off (Kevin Wolf, Laurent Vivier)
Date: Wed, 7 May 2008 08:48:10 +0100	[thread overview]
Message-ID: <20080507074810.GA28519@shareable.org> (raw)
In-Reply-To: <4820D905.4020407@bellard.org>

Fabrice Bellard wrote:
> A note: in order to avoid uncontrolled recursions, it is better to call
> the read/write AIO callback outside the aio_read/write (see
> bdrv_aio_read_em).

Definitely, I've been bitten by equivalent recursions and deadlocks in
my own code recently.

> Personally I would not trust the OS to correctly handle the mix of
> O_DIRECT and buffered operations, especially if the corresponding file
> regions intersect !

I agree.  Several OSes document that _any_ open buffered descriptors
suppress O_DIRECT, causing all descriptors to do buffered I/O, and
(explicitly or implied) opening a descriptor with O_DIRECT, and no
buffered descriptors at the time, flushes any buffers for that file so
that switching between them is coherent.  (Though I picked up hints
that some OSes don't even manage that coherence.)

Because it's not merely a flag change, it requires some cache flushing
for coherence, I would not trust fcntl(fd, F_SETFL, x) where x changes
between O_DIRECT and non-O_DIRECT to do the right thing on some OSes -
even for _synchronous_ I/O on separate regions.

-- Jamie

  parent reply	other threads:[~2008-05-07  7:48 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-06 17:27 [Qemu-devel] [4367] Align file accesses with cache=off (Kevin Wolf, Laurent Vivier) Blue Swirl
2008-05-06 22:17 ` Fabrice Bellard
2008-05-06 22:33   ` Anthony Liguori
2008-05-07  7:48   ` Jamie Lokier [this message]
2008-05-07  8:16   ` Kevin Wolf
2008-05-07 12:37     ` Jamie Lokier
2008-05-07 13:04       ` Kevin Wolf
2008-05-07 16:19         ` Blue Swirl
2008-05-07 16:39           ` Kevin Wolf
2008-05-07 16:26         ` Jamie Lokier
2008-05-07 17:23           ` Kevin Wolf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080507074810.GA28519@shareable.org \
    --to=jamie@shareable.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.