From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: "Daniel P. Berrangé" <berrange@redhat.com>, qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, Max Reitz <mreitz@redhat.com>,
Markus Armbruster <armbru@redhat.com>,
qemu-block@nongnu.org, P J P <ppandit@redhat.com>
Subject: Re: [PATCH v2 1/3] util: validate whether O_DIRECT is supported after failure
Date: Thu, 2 Jul 2020 17:29:00 +0200 [thread overview]
Message-ID: <8793a9e9-5ee1-bebc-d1b5-75b9f53302c2@redhat.com> (raw)
In-Reply-To: <20200702125612.2176194-2-berrange@redhat.com>
On 7/2/20 2:56 PM, Daniel P. Berrangé wrote:
> Currently we suggest that a filesystem may not support O_DIRECT after
> seeing an EINVAL. Other things can cause EINVAL though, so it is better
> to do an explicit check, and then report a definitive error message.
>
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
> util/osdep.c | 15 +++++++++++----
> 1 file changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/util/osdep.c b/util/osdep.c
> index 4829c07ff6..e2b7507ee2 100644
> --- a/util/osdep.c
> +++ b/util/osdep.c
> @@ -332,9 +332,11 @@ int qemu_open(const char *name, int flags, ...)
> }
>
> #ifdef O_CLOEXEC
> - ret = open(name, flags | O_CLOEXEC, mode);
> -#else
> + flags |= O_CLOEXEC;
> +#endif
> ret = open(name, flags, mode);
> +
> +#ifndef O_CLOEXEC
> if (ret >= 0) {
> qemu_set_cloexec(ret);
> }
> @@ -342,8 +344,13 @@ int qemu_open(const char *name, int flags, ...)
Too bad the git-diff removed 2 lines of context to add a comment instead.
In case it helps other reviewers, what was stripped out of the
context is this single line:
#endif
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>
> #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 */
> + int newflags = flags & ~O_DIRECT;
> + ret = open(name, newflags, mode);
> + if (ret != -1) {
> + close(ret);
> + error_report("file system does not support O_DIRECT");
> + errno = EINVAL;
> + }
> }
> #endif /* O_DIRECT */
>
>
next prev parent reply other threads:[~2020-07-02 15:37 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-02 12:56 [PATCH v2 0/3] block: improve error reporting for unsupported O_DIRECT Daniel P. Berrangé
2020-07-02 12:56 ` [PATCH v2 1/3] util: validate whether O_DIRECT is supported after failure Daniel P. Berrangé
2020-07-02 15:29 ` Philippe Mathieu-Daudé [this message]
2020-07-08 6:45 ` Markus Armbruster
2020-07-02 12:56 ` [PATCH v2 2/3] util: support detailed error reporting for qemu_open Daniel P. Berrangé
2020-07-08 6:55 ` Markus Armbruster
2020-07-02 12:56 ` [PATCH v2 3/3] block: switch to use qemu_open_err for improved errors Daniel P. Berrangé
2020-07-08 6:57 ` Markus Armbruster
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=8793a9e9-5ee1-bebc-d1b5-75b9f53302c2@redhat.com \
--to=philmd@redhat.com \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=ppandit@redhat.com \
--cc=qemu-block@nongnu.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 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).