All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff Cody <jcody@redhat.com>
To: Stefan Hajnoczi <stefanha@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
	Deepak C Shetty <deepakcs@linux.vnet.ibm.com>,
	qemu-devel@nongnu.org, Markus Armbruster <armbru@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 2/2] osdep: warn if open(O_DIRECT) on fails with EINVAL
Date: Fri, 6 Sep 2013 16:32:43 -0400	[thread overview]
Message-ID: <20130906203243.GA16486@localhost.localdomain> (raw)
In-Reply-To: <1377163743-25029-3-git-send-email-stefanha@redhat.com>

On Thu, Aug 22, 2013 at 11:29:03AM +0200, Stefan Hajnoczi wrote:
> Print a warning when opening a file O_DIRECT fails with EINVAL.  This
> saves users a lot of time trying to figure out the EINVAL error, which
> is typical when attempting to open a file O_DIRECT on Linux tmpfs.
> 
> Reported-by: Deepak C Shetty <deepakcs@linux.vnet.ibm.com>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
>  util/osdep.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/util/osdep.c b/util/osdep.c
> index 685c8ae..62072b4 100644
> --- a/util/osdep.c
> +++ b/util/osdep.c
> @@ -207,6 +207,13 @@ int qemu_open(const char *name, int flags, ...)
>      }
>  #endif
>  
> +#ifdef O_DIRECT
> +    if (ret == -1 && errno == EINVAL && (flags & O_DIRECT)) {
> +        error_report("file system may not support O_DIRECT");
> +        errno = EINVAL; /* in case it was clobbered */
> +    }
> +#endif /* O_DIRECT */
> +
>      return ret;
>  }
>  
> -- 
> 1.8.3.1
> 
> 

What about putting something similar in error_setg_file_open(), in
util/error.c?  There are other occasions when O_DIRECT causes a file
open to fail (e.g. live snapshots with 'cache=none' to a tmpfs
filesystem).  That would give additional info then for QMP commands.
Of course, it would then be necessary to also pass the open flags (or
other equivalent info) to error_setg_file_open().

  parent reply	other threads:[~2013-09-06 20:33 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-22  9:29 [Qemu-devel] [PATCH 0/2] osdep: warn if open(O_DIRECT) on fails with EINVAL Stefan Hajnoczi
2013-08-22  9:29 ` [Qemu-devel] [PATCH 1/2] libcacard: link against qemu-error.o for error_report() Stefan Hajnoczi
2013-08-22  9:29 ` [Qemu-devel] [PATCH 2/2] osdep: warn if open(O_DIRECT) on fails with EINVAL Stefan Hajnoczi
2013-08-22 17:57   ` Eric Blake
2013-08-22 19:31     ` Alex Bligh
2013-08-22 19:38       ` Eric Blake
2013-09-06 20:32   ` Jeff Cody [this message]
2013-09-18 13:21     ` Stefan Hajnoczi
2013-09-18 13:47 ` [Qemu-devel] [PATCH 0/2] " 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=20130906203243.GA16486@localhost.localdomain \
    --to=jcody@redhat.com \
    --cc=armbru@redhat.com \
    --cc=deepakcs@linux.vnet.ibm.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /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.