From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
Markus Armbruster <armbru@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
Deepak C Shetty <deepakcs@linux.vnet.ibm.com>
Subject: [Qemu-devel] [RFC 0/2] osdep: warn if opening a file O_DIRECT on tmpfs fails
Date: Thu, 22 Aug 2013 10:34:57 +0200 [thread overview]
Message-ID: <1377160499-11323-1-git-send-email-stefanha@redhat.com> (raw)
This is an implementation of Dan and Eric's idea for probing a failed O_DIRECT
open(2) call to see if the file system does not support O_DIRECT.
I wanted to see what the implementation looks like but I don't like it:
1. We still need to guess if O_DIRECT is supported in the O_CREAT EINVAL case
because we can't probe if O_CREAT | O_DIRECT | O_EXCL returned EINVAL.
2. There is a race condition between open(O_CREAT | O_EXCL | O_DIRECT) and
opening again without O_CREAT. If the file is deleted we'll get ENOENT
which would have been impossible before.
3. It's way complicated.
Issue #1 gives me an idea: why play games when we can simply warn the user?
if (ret == -1 && errno == EINVAL && (flags & O_DIRECT)) {
error_report("file system may not support O_DIRECT");
errno = EINVAL; /* in case it was clobbered */
}
I think this simple, portable approach beats statfs tmpfs and open probing.
Will send a patch for that and plan to merge it.
Stefan Hajnoczi (2):
libcacard: link against qemu-error.o for error_report()
osdep: warn if opening a file O_DIRECT on tmpfs fails
libcacard/Makefile | 3 ++-
util/osdep.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++------
2 files changed, 57 insertions(+), 8 deletions(-)
--
1.8.3.1
next reply other threads:[~2013-08-22 8:35 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-22 8:34 Stefan Hajnoczi [this message]
2013-08-22 8:34 ` [Qemu-devel] [RFC 1/2] libcacard: link against qemu-error.o for error_report() Stefan Hajnoczi
2013-08-22 8:34 ` [Qemu-devel] [RFC 2/2] osdep: warn if opening a file O_DIRECT on tmpfs fails Stefan Hajnoczi
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=1377160499-11323-1-git-send-email-stefanha@redhat.com \
--to=stefanha@redhat.com \
--cc=armbru@redhat.com \
--cc=deepakcs@linux.vnet.ibm.com \
--cc=kwolf@redhat.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).