From: "Denis V. Lunev" <den@openvz.org>
To: Kevin Wolf <kwolf@redhat.com>, qemu-block@nongnu.org
Cc: borntraeger@de.ibm.com, qemu-devel@nongnu.org, stefanha@redhat.com
Subject: Re: [Qemu-devel] [PATCH] block: Fix .bdrv_open flags
Date: Tue, 12 Jan 2016 08:58:00 +0300 [thread overview]
Message-ID: <569495E8.5020101@openvz.org> (raw)
In-Reply-To: <1452537156-7683-1-git-send-email-kwolf@redhat.com>
On 01/11/2016 09:32 PM, Kevin Wolf wrote:
> bdrv_common_open() modified bs->open_flags after inferring the set of
> options to pass to the driver's .bdrv_open callback. This means that the
> cache options were correctly set in bs->open_flags (and therefore
> correctly displayed in 'info block'), but the image would actually be
> opened with the default cache mode instead.
>
> This patch removes the flags parameter to bdrv_common_open() (except for
> BDRV_O_NO_BACKING it's the same as bs->open_flags anyway, and having two
> names for the same thing is confusing), and moves the assignment of
> open_flags down to immediately before calling into the block drivers. In
> all other places, bs->open_flags is now used consistently.
>
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
> block.c | 13 +++++++------
> 1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/block.c b/block.c
> index 01655de..ef37d51 100644
> --- a/block.c
> +++ b/block.c
> @@ -905,7 +905,7 @@ static QemuOptsList bdrv_runtime_opts = {
> * Removes all processed options from *options.
> */
> static int bdrv_open_common(BlockDriverState *bs, BdrvChild *file,
> - QDict *options, int flags, Error **errp)
> + QDict *options, Error **errp)
> {
> int ret, open_flags;
> const char *filename;
> @@ -943,7 +943,8 @@ static int bdrv_open_common(BlockDriverState *bs, BdrvChild *file,
> goto fail_opts;
> }
>
> - trace_bdrv_open_common(bs, filename ?: "", flags, drv->format_name);
> + trace_bdrv_open_common(bs, filename ?: "", bs->open_flags,
> + drv->format_name);
>
> node_name = qemu_opt_get(opts, "node-name");
> bdrv_assign_node_name(bs, node_name, &local_err);
> @@ -955,8 +956,7 @@ static int bdrv_open_common(BlockDriverState *bs, BdrvChild *file,
>
> bs->request_alignment = 512;
> bs->zero_beyond_eof = true;
> - open_flags = bdrv_open_flags(bs, flags);
> - bs->read_only = !(open_flags & BDRV_O_RDWR);
> + bs->read_only = !(bs->open_flags & BDRV_O_RDWR);
>
> if (use_bdrv_whitelist && !bdrv_is_whitelisted(drv, bs->read_only)) {
> error_setg(errp,
> @@ -969,7 +969,7 @@ static int bdrv_open_common(BlockDriverState *bs, BdrvChild *file,
> }
>
> assert(bs->copy_on_read == 0); /* bdrv_new() and bdrv_close() make it so */
> - if (flags & BDRV_O_COPY_ON_READ) {
> + if (bs->open_flags & BDRV_O_COPY_ON_READ) {
> if (!bs->read_only) {
> bdrv_enable_copy_on_read(bs);
> } else {
> @@ -994,6 +994,7 @@ static int bdrv_open_common(BlockDriverState *bs, BdrvChild *file,
> bdrv_set_enable_write_cache(bs, bs->open_flags & BDRV_O_CACHE_WB);
>
> /* Open the image, either directly or using a protocol */
> + open_flags = bdrv_open_flags(bs, bs->open_flags);
> if (drv->bdrv_file_open) {
> assert(file == NULL);
> assert(!drv->bdrv_needs_filename || filename != NULL);
> @@ -1660,7 +1661,7 @@ static int bdrv_open_inherit(BlockDriverState **pbs, const char *filename,
> assert(!(flags & BDRV_O_PROTOCOL) || !file);
>
> /* Open the image */
> - ret = bdrv_open_common(bs, file, options, flags, &local_err);
> + ret = bdrv_open_common(bs, file, options, &local_err);
> if (ret < 0) {
> goto fail;
> }
Reviewed-by: Denis V. Lunev <den@openvz.org>
next prev parent reply other threads:[~2016-01-12 5:58 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-11 18:32 [Qemu-devel] [PATCH] block: Fix .bdrv_open flags Kevin Wolf
2016-01-12 5:58 ` Denis V. Lunev [this message]
2016-01-12 7:28 ` Christian Borntraeger
2016-01-14 14:09 ` 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=569495E8.5020101@openvz.org \
--to=den@openvz.org \
--cc=borntraeger@de.ibm.com \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--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 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).