qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com,
	mreitz@redhat.com, jsnow@redhat.com
Subject: [Qemu-devel] [PATCH 1/5] block: Remove copy-on-read from bdrv_move_feature_fields()
Date: Mon, 14 Mar 2016 16:44:48 +0100	[thread overview]
Message-ID: <1457970292-12291-2-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1457970292-12291-1-git-send-email-kwolf@redhat.com>

Ever since we first introduced bdrv_append() in commit 8802d1fd ('qapi:
Introduce blockdev-group-snapshot-sync command'), the copy-on-read flag
was moved to the new top layer when taking a snapshot. The only problem
is that it doesn't make a whole lot of sense.

The use case for manually enabled CoR is to avoid reading data twice
from a slow remote image, so we want to save it to a local overlay, say
an ISO image accessed via HTTP to a local qcow2 overlay. When taking a
snapshot, we end up with a backing chain like this:

    http <- local.qcow2 <- snap_overlay.qcow2

There is no point in doing CoR from local.qcow2 into snap_overlay.qcow2,
we just want to keep copying data from the remote source into
local.qcow2.

The other use case of CoR is in the context of streaming, which isn't
very interesting for bdrv_move_feature_fields() because op blockers
prevent this combination.

This patch makes the copy-on-read flag stay on the image for which it
was originally set and prevents it from being propagated to the new
overlay. It is no longer intended to move CoR to the BlockBackend level.
In order for this to make sense, we also need to keep the respective
image read-write.

As a side effect of these changes, creating a live snapshot image (as
opposed to using an existing externally created one) on top of a COR
block device works now. It used to fail because it tried to open its
backing file both read-only and with COR.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block.c    | 2 --
 blockdev.c | 7 +++++--
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/block.c b/block.c
index cf5eb34..a75c4b3 100644
--- a/block.c
+++ b/block.c
@@ -2283,8 +2283,6 @@ static void bdrv_move_feature_fields(BlockDriverState *bs_dest,
     /* move some fields that need to stay attached to the device */
 
     /* dev info */
-    bs_dest->copy_on_read       = bs_src->copy_on_read;
-
     bs_dest->enable_write_cache = bs_src->enable_write_cache;
 
     /* dirty bitmap */
diff --git a/blockdev.c b/blockdev.c
index 322ca03..a22b444 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -1728,6 +1728,7 @@ static void external_snapshot_prepare(BlkActionState *common,
         }
 
         flags = state->old_bs->open_flags;
+        flags &= ~(BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING | BDRV_O_COPY_ON_READ);
 
         /* create new image w/backing file */
         mode = s->has_mode ? s->mode : NEW_IMAGE_MODE_ABSOLUTE_PATHS;
@@ -1798,8 +1799,10 @@ static void external_snapshot_commit(BlkActionState *common)
     /* We don't need (or want) to use the transactional
      * bdrv_reopen_multiple() across all the entries at once, because we
      * don't want to abort all of them if one of them fails the reopen */
-    bdrv_reopen(state->old_bs, state->old_bs->open_flags & ~BDRV_O_RDWR,
-                NULL);
+    if (!state->old_bs->copy_on_read) {
+        bdrv_reopen(state->old_bs, state->old_bs->open_flags & ~BDRV_O_RDWR,
+                    NULL);
+    }
 }
 
 static void external_snapshot_abort(BlkActionState *common)
-- 
1.8.3.1

  reply	other threads:[~2016-03-14 15:45 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-14 15:44 [Qemu-devel] [PATCH 0/5] block: API changes for 2.6 Kevin Wolf
2016-03-14 15:44 ` Kevin Wolf [this message]
2016-03-14 15:51   ` [Qemu-devel] [PATCH 1/5] block: Remove copy-on-read from bdrv_move_feature_fields() Eric Blake
2016-03-14 15:44 ` [Qemu-devel] [PATCH 2/5] block: Remove dirty bitmaps " Kevin Wolf
2016-03-14 15:55   ` Eric Blake
2016-03-14 15:44 ` [Qemu-devel] [PATCH 3/5] block: Remove cache.writeback from blockdev-add Kevin Wolf
2016-03-14 16:10   ` Eric Blake
2016-03-14 16:22     ` Kevin Wolf
2016-03-14 15:44 ` [Qemu-devel] [PATCH 4/5] block: Make backing files always writeback Kevin Wolf
2016-03-14 16:46   ` Eric Blake
2016-03-14 15:44 ` [Qemu-devel] [PATCH 5/5] block: Reject writethrough mode except at the root Kevin Wolf
2016-03-14 16:50   ` Eric Blake
2016-03-18 17:10 ` [Qemu-devel] [PATCH 0/5] block: API changes for 2.6 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=1457970292-12291-2-git-send-email-kwolf@redhat.com \
    --to=kwolf@redhat.com \
    --cc=armbru@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=mreitz@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).