All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/9] block: Add COR filter driver
@ 2018-04-16 16:58 Max Reitz
  2018-04-16 16:58 ` [Qemu-devel] [PATCH 1/9] " Max Reitz
                   ` (9 more replies)
  0 siblings, 10 replies; 29+ messages in thread
From: Max Reitz @ 2018-04-16 16:58 UTC (permalink / raw)
  To: qemu-block; +Cc: qemu-devel, Max Reitz, Kevin Wolf, Stefan Hajnoczi, Fam Zheng

In our quest to... (Oh, man, I always struggle with writing cover
letters.  But rarely have I become stuck so early on.)  Orthogonalize?
the block layer (that is, turn hard-coded special options into
independent data processing nodes you can put anywhere in your data flow
graph), this series adds a copy-on-read filter driver that is supposed
to replace the copy-on-read -drive option in the long run.  In the short
run, it allows you to use COR with blockdev-add.

The patch itself is extremely simple.  It's just patch 1.  All we have
to do for now is to set the BDRV_REQ_COPY_ON_READ flag for read
requests.  We probably want to extend the COR driver's capabilities
later on, though, more on that below under "What to do as a follow-up?".

But there is something to do on top of that.  One real issue with the
current copy-on-read model is that you generally cannot do COR through
filter nodes (-drive copy-on-read=on,driver=raw,file.driver=qcow2,...).
Unless you are lucky that someone has requested WRITE permission, you
will run into a failed assertion from the permission system (see
patch 9).  Actually, you should always run into such an abort, but the
COR code cleverly sneaks its writes around it.  Well, actually, the
respective assertion is just commented out with a comment noting that
we'd need a proper COR filter so we could do the assertion.

So the new COR node will take the permission for its child that the
current code does not (because it cannot, for the lack of a node that
would do this).  However, of course we don't want it to require a WRITE
permission but just WRITE_UNCHANGED.  But when it issues a post-COR
write request that goes down to a filter and that filter re-issues that
write down to its child, then it will just be a normal write.  So
suddenly WRITE_UNCHANGED won't be sufficient, we'd need a standard WRITE
instead.

That isn't what we want, though.  So this series also adds a
BDRV_REQ_WRITE_UNCHANGED write request flag that is set when issuing a
COR write.  This flag tells the block code that the WRITE_UNCHANGED
permission will be sufficient to execute the request.  Filter drivers
need to pass this along; format drivers don't because they take a
full-on WRITE permission on their file anyway.

So most of this series is about adding this new flag.

(Note that this does nothing to fix the situation with the old
 copy-on-read=on.  That will still runs into a failed assertion if you
 poke it the right way.  But the cruel reality is that the only way to
 really fix this is by converting copy-on-read=on into an implicit COR
 node.)


Finally, the test we have for COR (197) is copied and modified to use
the COR filter; and another test is added for the situation described
above (COR through filter nodes).


=== What to do as a follow-up? ===

The obvious thing is to transform the current copy-on-read flag into an
implicit COR node.  Probably not too difficult, actually (just handle it
like snapshot=on), but we need to hide that fact in the query functions.

Also, we want to make the stream block job code use this node.  Maybe we
eventually want this node become the stream block job eventually,
actually.  That is, give it enough runtime options that you can perform
a stream operation just by inserting a COR node into the graph.  But
probably that won't be possible, because someone still needs to submit
reads requests across the whole disk so that everything is actually
copied.  This could be achieved with a blockdev-copy to null-co://,
though.

Once both is done, we want to remove the COR code from block.c and move
it directly into the COR driver.

Max Reitz (9):
  block: Add COR filter driver
  block: BLK_PERM_WRITE includes ..._UNCHANGED
  block: Add BDRV_REQ_WRITE_UNCHANGED flag
  block: Set BDRV_REQ_WRITE_UNCHANGED for COR writes
  block/quorum: Support BDRV_REQ_WRITE_UNCHANGED
  block: Support BDRV_REQ_WRITE_UNCHANGED in filters
  iotests: Clean up wrap image in 197
  iotests: Copy 197 for COR filter driver
  iotests: Add test for COR across nodes

 block/Makefile.objs        |   2 +-
 qapi/block-core.json       |   5 +-
 include/block/block.h      |   9 ++-
 block/blkdebug.c           |   9 +--
 block/blkreplay.c          |   3 +
 block/blkverify.c          |   3 +
 block/cor.c                | 173 +++++++++++++++++++++++++++++++++++++++++++++
 block/io.c                 |  12 +++-
 block/mirror.c             |   2 +
 block/quorum.c             |  19 +++--
 block/raw-format.c         |   9 +--
 block/throttle.c           |   6 +-
 tests/qemu-iotests/197     |   1 +
 tests/qemu-iotests/215     | 120 +++++++++++++++++++++++++++++++
 tests/qemu-iotests/215.out |  26 +++++++
 tests/qemu-iotests/216     | 117 ++++++++++++++++++++++++++++++
 tests/qemu-iotests/216.out |  28 ++++++++
 tests/qemu-iotests/group   |   2 +
 18 files changed, 524 insertions(+), 22 deletions(-)
 create mode 100644 block/cor.c
 create mode 100755 tests/qemu-iotests/215
 create mode 100644 tests/qemu-iotests/215.out
 create mode 100755 tests/qemu-iotests/216
 create mode 100644 tests/qemu-iotests/216.out

-- 
2.14.3

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Qemu-devel] [PATCH 1/9] block: Add COR filter driver
  2018-04-16 16:58 [Qemu-devel] [PATCH 0/9] block: Add COR filter driver Max Reitz
@ 2018-04-16 16:58 ` Max Reitz
  2018-04-20  8:31   ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
  2018-04-16 16:58 ` [Qemu-devel] [PATCH 2/9] block: BLK_PERM_WRITE includes ..._UNCHANGED Max Reitz
                   ` (8 subsequent siblings)
  9 siblings, 1 reply; 29+ messages in thread
From: Max Reitz @ 2018-04-16 16:58 UTC (permalink / raw)
  To: qemu-block; +Cc: qemu-devel, Max Reitz, Kevin Wolf, Stefan Hajnoczi, Fam Zheng

This adds a simple copy-on-read filter driver.  It relies on the already
existing COR functionality in the central block layer code, which may be
moved here once we no longer need it there.

Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 block/Makefile.objs  |   2 +-
 qapi/block-core.json |   5 +-
 block/cor.c          | 171 +++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 176 insertions(+), 2 deletions(-)
 create mode 100644 block/cor.c

diff --git a/block/Makefile.objs b/block/Makefile.objs
index d644bac60a..6fdf786c04 100644
--- a/block/Makefile.objs
+++ b/block/Makefile.objs
@@ -26,7 +26,7 @@ block-obj-y += accounting.o dirty-bitmap.o
 block-obj-y += write-threshold.o
 block-obj-y += backup.o
 block-obj-$(CONFIG_REPLICATION) += replication.o
-block-obj-y += throttle.o
+block-obj-y += throttle.o cor.o
 
 block-obj-y += crypto.o
 
diff --git a/qapi/block-core.json b/qapi/block-core.json
index c50517bff3..3abbf4fcf1 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -2506,11 +2506,12 @@
 # @vxhs: Since 2.10
 # @throttle: Since 2.11
 # @nvme: Since 2.12
+# @cor: Since 2.13
 #
 # Since: 2.9
 ##
 { 'enum': 'BlockdevDriver',
-  'data': [ 'blkdebug', 'blkverify', 'bochs', 'cloop',
+  'data': [ 'blkdebug', 'blkverify', 'bochs', 'cloop', 'cor',
             'dmg', 'file', 'ftp', 'ftps', 'gluster', 'host_cdrom',
             'host_device', 'http', 'https', 'iscsi', 'luks', 'nbd', 'nfs',
             'null-aio', 'null-co', 'nvme', 'parallels', 'qcow', 'qcow2', 'qed',
@@ -3522,6 +3523,7 @@
       'blkverify':  'BlockdevOptionsBlkverify',
       'bochs':      'BlockdevOptionsGenericFormat',
       'cloop':      'BlockdevOptionsGenericFormat',
+      'cor':        'BlockdevOptionsGenericFormat',
       'dmg':        'BlockdevOptionsGenericFormat',
       'file':       'BlockdevOptionsFile',
       'ftp':        'BlockdevOptionsCurlFtp',
@@ -4049,6 +4051,7 @@
       'blkverify':      'BlockdevCreateNotSupported',
       'bochs':          'BlockdevCreateNotSupported',
       'cloop':          'BlockdevCreateNotSupported',
+      'cor':            'BlockdevCreateNotSupported',
       'dmg':            'BlockdevCreateNotSupported',
       'file':           'BlockdevCreateOptionsFile',
       'ftp':            'BlockdevCreateNotSupported',
diff --git a/block/cor.c b/block/cor.c
new file mode 100644
index 0000000000..a4cb4e2b84
--- /dev/null
+++ b/block/cor.c
@@ -0,0 +1,171 @@
+/*
+ * Copy-on-read filter block driver
+ *
+ * Copyright (c) 2018 Red Hat, Inc.
+ *
+ * Author:
+ *   Max Reitz <mreitz@redhat.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 or
+ * (at your option) version 3 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "qemu/osdep.h"
+#include "block/block_int.h"
+
+
+static int cor_open(BlockDriverState *bs, QDict *options, int flags,
+                    Error **errp)
+{
+    bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, false,
+                               errp);
+    if (!bs->file) {
+        return -EINVAL;
+    }
+
+    bs->supported_write_flags = BDRV_REQ_FUA &
+                                    bs->file->bs->supported_write_flags;
+
+    bs->supported_zero_flags = (BDRV_REQ_FUA | BDRV_REQ_MAY_UNMAP) &
+                                    bs->file->bs->supported_zero_flags;
+
+    return 0;
+}
+
+
+static void cor_close(BlockDriverState *bs)
+{
+}
+
+
+#define PERM_PASSTHROUGH (BLK_PERM_CONSISTENT_READ \
+                          | BLK_PERM_WRITE \
+                          | BLK_PERM_RESIZE)
+#define PERM_UNCHANGED (BLK_PERM_ALL & ~PERM_PASSTHROUGH)
+
+static void cor_child_perm(BlockDriverState *bs, BdrvChild *c,
+                           const BdrvChildRole *role,
+                           BlockReopenQueue *reopen_queue,
+                           uint64_t perm, uint64_t shared,
+                           uint64_t *nperm, uint64_t *nshared)
+{
+    if (c == NULL) {
+        *nperm = (perm & PERM_PASSTHROUGH) | BLK_PERM_WRITE_UNCHANGED;
+        *nshared = (shared & PERM_PASSTHROUGH) | PERM_UNCHANGED;
+        return;
+    }
+
+    *nperm = (perm & PERM_PASSTHROUGH) |
+             (c->perm & PERM_UNCHANGED);
+    *nshared = (shared & PERM_PASSTHROUGH) |
+               (c->shared_perm & PERM_UNCHANGED);
+}
+
+
+static int64_t cor_getlength(BlockDriverState *bs)
+{
+    return bdrv_getlength(bs->file->bs);
+}
+
+
+static int cor_truncate(BlockDriverState *bs, int64_t offset,
+                        PreallocMode prealloc, Error **errp)
+{
+    return bdrv_truncate(bs->file, offset, prealloc, errp);
+}
+
+
+static int coroutine_fn cor_co_preadv(BlockDriverState *bs,
+                                      uint64_t offset, uint64_t bytes,
+                                      QEMUIOVector *qiov, int flags)
+{
+    return bdrv_co_preadv(bs->file, offset, bytes, qiov,
+                          flags | BDRV_REQ_COPY_ON_READ);
+}
+
+
+static int coroutine_fn cor_co_pwritev(BlockDriverState *bs,
+                                       uint64_t offset, uint64_t bytes,
+                                       QEMUIOVector *qiov, int flags)
+{
+
+    return bdrv_co_pwritev(bs->file, offset, bytes, qiov, flags);
+}
+
+
+static int coroutine_fn cor_co_pwrite_zeroes(BlockDriverState *bs,
+                                             int64_t offset, int bytes,
+                                             BdrvRequestFlags flags)
+{
+    return bdrv_co_pwrite_zeroes(bs->file, offset, bytes, flags);
+}
+
+
+static int coroutine_fn cor_co_pdiscard(BlockDriverState *bs,
+                                        int64_t offset, int bytes)
+{
+    return bdrv_co_pdiscard(bs->file->bs, offset, bytes);
+}
+
+
+static void cor_eject(BlockDriverState *bs, bool eject_flag)
+{
+    bdrv_eject(bs->file->bs, eject_flag);
+}
+
+
+static void cor_lock_medium(BlockDriverState *bs, bool locked)
+{
+    bdrv_lock_medium(bs->file->bs, locked);
+}
+
+
+static bool cor_recurse_is_first_non_filter(BlockDriverState *bs,
+                                            BlockDriverState *candidate)
+{
+    return bdrv_recurse_is_first_non_filter(bs->file->bs, candidate);
+}
+
+
+BlockDriver bdrv_cor = {
+    .format_name                        = "cor",
+
+    .bdrv_open                          = cor_open,
+    .bdrv_close                         = cor_close,
+    .bdrv_child_perm                    = cor_child_perm,
+
+    .bdrv_getlength                     = cor_getlength,
+    .bdrv_truncate                      = cor_truncate,
+
+    .bdrv_co_preadv                     = cor_co_preadv,
+    .bdrv_co_pwritev                    = cor_co_pwritev,
+    .bdrv_co_pwrite_zeroes              = cor_co_pwrite_zeroes,
+    .bdrv_co_pdiscard                   = cor_co_pdiscard,
+
+    .bdrv_eject                         = cor_eject,
+    .bdrv_lock_medium                   = cor_lock_medium,
+
+    .bdrv_co_block_status               = bdrv_co_block_status_from_file,
+
+    .bdrv_recurse_is_first_non_filter   = cor_recurse_is_first_non_filter,
+
+    .has_variable_length                = true,
+    .is_filter                          = true,
+};
+
+static void bdrv_cor_init(void)
+{
+    bdrv_register(&bdrv_cor);
+}
+
+block_init(bdrv_cor_init);
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [Qemu-devel] [PATCH 2/9] block: BLK_PERM_WRITE includes ..._UNCHANGED
  2018-04-16 16:58 [Qemu-devel] [PATCH 0/9] block: Add COR filter driver Max Reitz
  2018-04-16 16:58 ` [Qemu-devel] [PATCH 1/9] " Max Reitz
@ 2018-04-16 16:58 ` Max Reitz
  2018-04-20  8:32   ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
  2018-04-20 12:04   ` Alberto Garcia
  2018-04-16 16:58 ` [Qemu-devel] [PATCH 3/9] block: Add BDRV_REQ_WRITE_UNCHANGED flag Max Reitz
                   ` (7 subsequent siblings)
  9 siblings, 2 replies; 29+ messages in thread
From: Max Reitz @ 2018-04-16 16:58 UTC (permalink / raw)
  To: qemu-block; +Cc: qemu-devel, Max Reitz, Kevin Wolf, Stefan Hajnoczi, Fam Zheng

Currently we never actually check whether the WRITE_UNCHANGED
permission has been taken for unchanging writes.  But the one check that
is commented out checks both WRITE and WRITE_UNCHANGED; and considering
that WRITE_UNCHANGED is already documented as being weaker then WRITE,
we should probably explicitly document WRITE to include WRITE_UNCHANGED.

Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 include/block/block.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/block/block.h b/include/block/block.h
index cdec3639a3..397b5e8d44 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -205,6 +205,9 @@ enum {
      * This permission (which is weaker than BLK_PERM_WRITE) is both enough and
      * required for writes to the block node when the caller promises that
      * the visible disk content doesn't change.
+     *
+     * As the BLK_PERM_WRITE permission is strictly stronger, either is
+     * sufficient to perform an unchanging write.
      */
     BLK_PERM_WRITE_UNCHANGED    = 0x04,
 
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [Qemu-devel] [PATCH 3/9] block: Add BDRV_REQ_WRITE_UNCHANGED flag
  2018-04-16 16:58 [Qemu-devel] [PATCH 0/9] block: Add COR filter driver Max Reitz
  2018-04-16 16:58 ` [Qemu-devel] [PATCH 1/9] " Max Reitz
  2018-04-16 16:58 ` [Qemu-devel] [PATCH 2/9] block: BLK_PERM_WRITE includes ..._UNCHANGED Max Reitz
@ 2018-04-16 16:58 ` Max Reitz
  2018-04-20  8:33   ` Stefan Hajnoczi
  2018-04-20 12:06   ` [Qemu-devel] [Qemu-block] " Alberto Garcia
  2018-04-16 16:58 ` [Qemu-devel] [PATCH 4/9] block: Set BDRV_REQ_WRITE_UNCHANGED for COR writes Max Reitz
                   ` (6 subsequent siblings)
  9 siblings, 2 replies; 29+ messages in thread
From: Max Reitz @ 2018-04-16 16:58 UTC (permalink / raw)
  To: qemu-block; +Cc: qemu-devel, Max Reitz, Kevin Wolf, Stefan Hajnoczi, Fam Zheng

This flag signifies that a write request will not change the visible
disk content.  With this flag set, it is sufficient to have the
BLK_PERM_WRITE_UNCHANGED permission instead of BLK_PERM_WRITE.

Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 include/block/block.h | 6 +++++-
 block/io.c            | 6 +++++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/include/block/block.h b/include/block/block.h
index 397b5e8d44..3894edda9d 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -54,8 +54,12 @@ typedef enum {
     BDRV_REQ_FUA                = 0x10,
     BDRV_REQ_WRITE_COMPRESSED   = 0x20,
 
+    /* Signifies that this write request will not change the visible disk
+     * content. */
+    BDRV_REQ_WRITE_UNCHANGED    = 0x40,
+
     /* Mask of valid flags */
-    BDRV_REQ_MASK               = 0x3f,
+    BDRV_REQ_MASK               = 0x7f,
 } BdrvRequestFlags;
 
 typedef struct BlockSizes {
diff --git a/block/io.c b/block/io.c
index bd9a19a9c4..134b2a498f 100644
--- a/block/io.c
+++ b/block/io.c
@@ -1501,7 +1501,11 @@ static int coroutine_fn bdrv_aligned_pwritev(BdrvChild *child,
     assert(!waited || !req->serialising);
     assert(req->overlap_offset <= offset);
     assert(offset + bytes <= req->overlap_offset + req->overlap_bytes);
-    assert(child->perm & BLK_PERM_WRITE);
+    if (flags & BDRV_REQ_WRITE_UNCHANGED) {
+        assert(child->perm & (BLK_PERM_WRITE_UNCHANGED | BLK_PERM_WRITE));
+    } else {
+        assert(child->perm & BLK_PERM_WRITE);
+    }
     assert(end_sector <= bs->total_sectors || child->perm & BLK_PERM_RESIZE);
 
     ret = notifier_with_return_list_notify(&bs->before_write_notifiers, req);
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [Qemu-devel] [PATCH 4/9] block: Set BDRV_REQ_WRITE_UNCHANGED for COR writes
  2018-04-16 16:58 [Qemu-devel] [PATCH 0/9] block: Add COR filter driver Max Reitz
                   ` (2 preceding siblings ...)
  2018-04-16 16:58 ` [Qemu-devel] [PATCH 3/9] block: Add BDRV_REQ_WRITE_UNCHANGED flag Max Reitz
@ 2018-04-16 16:58 ` Max Reitz
  2018-04-20  8:33   ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
  2018-04-20 12:06   ` Alberto Garcia
  2018-04-16 16:58 ` [Qemu-devel] [PATCH 5/9] block/quorum: Support BDRV_REQ_WRITE_UNCHANGED Max Reitz
                   ` (5 subsequent siblings)
  9 siblings, 2 replies; 29+ messages in thread
From: Max Reitz @ 2018-04-16 16:58 UTC (permalink / raw)
  To: qemu-block; +Cc: qemu-devel, Max Reitz, Kevin Wolf, Stefan Hajnoczi, Fam Zheng

Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 block/io.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/block/io.c b/block/io.c
index 134b2a498f..fada4efbf3 100644
--- a/block/io.c
+++ b/block/io.c
@@ -1115,13 +1115,15 @@ static int coroutine_fn bdrv_co_do_copy_on_readv(BdrvChild *child,
                 /* FIXME: Should we (perhaps conditionally) be setting
                  * BDRV_REQ_MAY_UNMAP, if it will allow for a sparser copy
                  * that still correctly reads as zero? */
-                ret = bdrv_co_do_pwrite_zeroes(bs, cluster_offset, pnum, 0);
+                ret = bdrv_co_do_pwrite_zeroes(bs, cluster_offset, pnum,
+                                               BDRV_REQ_WRITE_UNCHANGED);
             } else {
                 /* This does not change the data on the disk, it is not
                  * necessary to flush even in cache=writethrough mode.
                  */
                 ret = bdrv_driver_pwritev(bs, cluster_offset, pnum,
-                                          &local_qiov, 0);
+                                          &local_qiov,
+                                          BDRV_REQ_WRITE_UNCHANGED);
             }
 
             if (ret < 0) {
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [Qemu-devel] [PATCH 5/9] block/quorum: Support BDRV_REQ_WRITE_UNCHANGED
  2018-04-16 16:58 [Qemu-devel] [PATCH 0/9] block: Add COR filter driver Max Reitz
                   ` (3 preceding siblings ...)
  2018-04-16 16:58 ` [Qemu-devel] [PATCH 4/9] block: Set BDRV_REQ_WRITE_UNCHANGED for COR writes Max Reitz
@ 2018-04-16 16:58 ` Max Reitz
  2018-04-20  8:44   ` Stefan Hajnoczi
  2018-04-20 12:09   ` [Qemu-devel] [Qemu-block] " Alberto Garcia
  2018-04-16 16:58 ` [Qemu-devel] [PATCH 6/9] block: Support BDRV_REQ_WRITE_UNCHANGED in filters Max Reitz
                   ` (4 subsequent siblings)
  9 siblings, 2 replies; 29+ messages in thread
From: Max Reitz @ 2018-04-16 16:58 UTC (permalink / raw)
  To: qemu-block; +Cc: qemu-devel, Max Reitz, Kevin Wolf, Stefan Hajnoczi, Fam Zheng

We just need to forward it to quorum's children (except in case of a
rewrite because of corruption), but for that we first have to support
flags in child requests at all.

Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 block/quorum.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/block/quorum.c b/block/quorum.c
index cfe484a945..8cd689b2c1 100644
--- a/block/quorum.c
+++ b/block/quorum.c
@@ -115,6 +115,7 @@ struct QuorumAIOCB {
     /* Request metadata */
     uint64_t offset;
     uint64_t bytes;
+    int flags;
 
     QEMUIOVector *qiov;         /* calling IOV */
 
@@ -157,7 +158,8 @@ static bool quorum_64bits_compare(QuorumVoteValue *a, QuorumVoteValue *b)
 static QuorumAIOCB *quorum_aio_get(BlockDriverState *bs,
                                    QEMUIOVector *qiov,
                                    uint64_t offset,
-                                   uint64_t bytes)
+                                   uint64_t bytes,
+                                   int flags)
 {
     BDRVQuorumState *s = bs->opaque;
     QuorumAIOCB *acb = g_new(QuorumAIOCB, 1);
@@ -168,6 +170,7 @@ static QuorumAIOCB *quorum_aio_get(BlockDriverState *bs,
         .bs                 = bs,
         .offset             = offset,
         .bytes              = bytes,
+        .flags              = flags,
         .qiov               = qiov,
         .votes.compare      = quorum_sha256_compare,
         .votes.vote_list    = QLIST_HEAD_INITIALIZER(acb.votes.vote_list),
@@ -271,9 +274,11 @@ static void quorum_rewrite_entry(void *opaque)
     BDRVQuorumState *s = acb->bs->opaque;
 
     /* Ignore any errors, it's just a correction attempt for already
-     * corrupted data. */
+     * corrupted data.
+     * Mask out BDRV_REQ_WRITE_UNCHANGED because this overwrites the
+     * area with different data from the other children. */
     bdrv_co_pwritev(s->children[co->idx], acb->offset, acb->bytes,
-                    acb->qiov, 0);
+                    acb->qiov, acb->flags & ~BDRV_REQ_WRITE_UNCHANGED);
 
     /* Wake up the caller after the last rewrite */
     acb->rewrite_count--;
@@ -673,7 +678,7 @@ static int quorum_co_preadv(BlockDriverState *bs, uint64_t offset,
                             uint64_t bytes, QEMUIOVector *qiov, int flags)
 {
     BDRVQuorumState *s = bs->opaque;
-    QuorumAIOCB *acb = quorum_aio_get(bs, qiov, offset, bytes);
+    QuorumAIOCB *acb = quorum_aio_get(bs, qiov, offset, bytes, flags);
     int ret;
 
     acb->is_read = true;
@@ -699,7 +704,7 @@ static void write_quorum_entry(void *opaque)
 
     sacb->bs = s->children[i]->bs;
     sacb->ret = bdrv_co_pwritev(s->children[i], acb->offset, acb->bytes,
-                                acb->qiov, 0);
+                                acb->qiov, acb->flags);
     if (sacb->ret == 0) {
         acb->success_count++;
     } else {
@@ -719,7 +724,7 @@ static int quorum_co_pwritev(BlockDriverState *bs, uint64_t offset,
                              uint64_t bytes, QEMUIOVector *qiov, int flags)
 {
     BDRVQuorumState *s = bs->opaque;
-    QuorumAIOCB *acb = quorum_aio_get(bs, qiov, offset, bytes);
+    QuorumAIOCB *acb = quorum_aio_get(bs, qiov, offset, bytes, flags);
     int i, ret;
 
     for (i = 0; i < s->num_children; i++) {
@@ -961,6 +966,8 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags,
     }
     s->next_child_index = s->num_children;
 
+    bs->supported_write_flags = BDRV_REQ_WRITE_UNCHANGED;
+
     g_free(opened);
     goto exit;
 
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [Qemu-devel] [PATCH 6/9] block: Support BDRV_REQ_WRITE_UNCHANGED in filters
  2018-04-16 16:58 [Qemu-devel] [PATCH 0/9] block: Add COR filter driver Max Reitz
                   ` (4 preceding siblings ...)
  2018-04-16 16:58 ` [Qemu-devel] [PATCH 5/9] block/quorum: Support BDRV_REQ_WRITE_UNCHANGED Max Reitz
@ 2018-04-16 16:58 ` Max Reitz
  2018-04-20  8:35   ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
  2018-04-20 12:19   ` Alberto Garcia
  2018-04-16 16:58 ` [Qemu-devel] [PATCH 7/9] iotests: Clean up wrap image in 197 Max Reitz
                   ` (3 subsequent siblings)
  9 siblings, 2 replies; 29+ messages in thread
From: Max Reitz @ 2018-04-16 16:58 UTC (permalink / raw)
  To: qemu-block; +Cc: qemu-devel, Max Reitz, Kevin Wolf, Stefan Hajnoczi, Fam Zheng

Update the rest of the filter drivers to support
BDRV_REQ_WRITE_UNCHANGED.  They already forward write request flags to
their children, so we just have to announce support for it.

This patch does not cover the replication driver because that currently
does not support flags at all, and because it just grabs the WRITE
permission for its children when it can, so we should be fine just
submitting the incoming WRITE_UNCHANGED requests as normal writes.

It also does not cover format drivers for similar reasons.  They all use
bdrv_format_default_perms() as their .bdrv_child_perm() implementation
so they just always grab the WRITE permission for their file children
whenever possible.  In addition, it often would be difficult to
ascertain whether incoming unchanging writes end up as unchanging writes
in their files.  So we just leave them as normal potentially changing
writes.

Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 block/blkdebug.c   |  9 +++++----
 block/blkreplay.c  |  3 +++
 block/blkverify.c  |  3 +++
 block/cor.c        | 10 ++++++----
 block/mirror.c     |  2 ++
 block/raw-format.c |  9 +++++----
 block/throttle.c   |  6 ++++--
 7 files changed, 28 insertions(+), 14 deletions(-)

diff --git a/block/blkdebug.c b/block/blkdebug.c
index 589712475a..762ec2527c 100644
--- a/block/blkdebug.c
+++ b/block/blkdebug.c
@@ -398,10 +398,11 @@ static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags,
         goto out;
     }
 
-    bs->supported_write_flags = BDRV_REQ_FUA &
-        bs->file->bs->supported_write_flags;
-    bs->supported_zero_flags = (BDRV_REQ_FUA | BDRV_REQ_MAY_UNMAP) &
-        bs->file->bs->supported_zero_flags;
+    bs->supported_write_flags = BDRV_REQ_WRITE_UNCHANGED |
+        (BDRV_REQ_FUA & bs->file->bs->supported_write_flags);
+    bs->supported_zero_flags = BDRV_REQ_WRITE_UNCHANGED |
+        ((BDRV_REQ_FUA | BDRV_REQ_MAY_UNMAP) &
+            bs->file->bs->supported_zero_flags);
     ret = -EINVAL;
 
     /* Set alignment overrides */
diff --git a/block/blkreplay.c b/block/blkreplay.c
index fe5a9b4a98..b016dbeee7 100755
--- a/block/blkreplay.c
+++ b/block/blkreplay.c
@@ -35,6 +35,9 @@ static int blkreplay_open(BlockDriverState *bs, QDict *options, int flags,
         goto fail;
     }
 
+    bs->supported_write_flags = BDRV_REQ_WRITE_UNCHANGED;
+    bs->supported_zero_flags = BDRV_REQ_WRITE_UNCHANGED;
+
     ret = 0;
 fail:
     return ret;
diff --git a/block/blkverify.c b/block/blkverify.c
index 331365be33..1646404b46 100644
--- a/block/blkverify.c
+++ b/block/blkverify.c
@@ -141,6 +141,9 @@ static int blkverify_open(BlockDriverState *bs, QDict *options, int flags,
         goto fail;
     }
 
+    bs->supported_write_flags = BDRV_REQ_WRITE_UNCHANGED;
+    bs->supported_zero_flags = BDRV_REQ_WRITE_UNCHANGED;
+
     ret = 0;
 fail:
     qemu_opts_del(opts);
diff --git a/block/cor.c b/block/cor.c
index a4cb4e2b84..189e5bd13e 100644
--- a/block/cor.c
+++ b/block/cor.c
@@ -33,11 +33,13 @@ static int cor_open(BlockDriverState *bs, QDict *options, int flags,
         return -EINVAL;
     }
 
-    bs->supported_write_flags = BDRV_REQ_FUA &
-                                    bs->file->bs->supported_write_flags;
+    bs->supported_write_flags = BDRV_REQ_WRITE_UNCHANGED |
+                                (BDRV_REQ_FUA &
+                                    bs->file->bs->supported_write_flags);
 
-    bs->supported_zero_flags = (BDRV_REQ_FUA | BDRV_REQ_MAY_UNMAP) &
-                                    bs->file->bs->supported_zero_flags;
+    bs->supported_zero_flags = BDRV_REQ_WRITE_UNCHANGED |
+                               ((BDRV_REQ_FUA | BDRV_REQ_MAY_UNMAP) &
+                                    bs->file->bs->supported_zero_flags);
 
     return 0;
 }
diff --git a/block/mirror.c b/block/mirror.c
index 820f512c7b..6fdd36d27f 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -1148,6 +1148,8 @@ static void mirror_start_job(const char *job_id, BlockDriverState *bs,
         mirror_top_bs->implicit = true;
     }
     mirror_top_bs->total_sectors = bs->total_sectors;
+    mirror_top_bs->supported_write_flags = BDRV_REQ_WRITE_UNCHANGED;
+    mirror_top_bs->supported_zero_flags = BDRV_REQ_WRITE_UNCHANGED;
     bdrv_set_aio_context(mirror_top_bs, bdrv_get_aio_context(bs));
 
     /* bdrv_append takes ownership of the mirror_top_bs reference, need to keep
diff --git a/block/raw-format.c b/block/raw-format.c
index a378547c99..fe33693a2d 100644
--- a/block/raw-format.c
+++ b/block/raw-format.c
@@ -415,10 +415,11 @@ static int raw_open(BlockDriverState *bs, QDict *options, int flags,
     }
 
     bs->sg = bs->file->bs->sg;
-    bs->supported_write_flags = BDRV_REQ_FUA &
-        bs->file->bs->supported_write_flags;
-    bs->supported_zero_flags = (BDRV_REQ_FUA | BDRV_REQ_MAY_UNMAP) &
-        bs->file->bs->supported_zero_flags;
+    bs->supported_write_flags = BDRV_REQ_WRITE_UNCHANGED |
+        (BDRV_REQ_FUA & bs->file->bs->supported_write_flags);
+    bs->supported_zero_flags = BDRV_REQ_WRITE_UNCHANGED |
+        ((BDRV_REQ_FUA | BDRV_REQ_MAY_UNMAP) &
+            bs->file->bs->supported_zero_flags);
 
     if (bs->probed && !bdrv_is_read_only(bs)) {
         fprintf(stderr,
diff --git a/block/throttle.c b/block/throttle.c
index 95ed06acd8..e298827f95 100644
--- a/block/throttle.c
+++ b/block/throttle.c
@@ -81,8 +81,10 @@ static int throttle_open(BlockDriverState *bs, QDict *options,
     if (!bs->file) {
         return -EINVAL;
     }
-    bs->supported_write_flags = bs->file->bs->supported_write_flags;
-    bs->supported_zero_flags = bs->file->bs->supported_zero_flags;
+    bs->supported_write_flags = bs->file->bs->supported_write_flags |
+                                BDRV_REQ_WRITE_UNCHANGED;
+    bs->supported_zero_flags = bs->file->bs->supported_zero_flags |
+                               BDRV_REQ_WRITE_UNCHANGED;
 
     return throttle_configure_tgm(bs, tgm, options, errp);
 }
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [Qemu-devel] [PATCH 7/9] iotests: Clean up wrap image in 197
  2018-04-16 16:58 [Qemu-devel] [PATCH 0/9] block: Add COR filter driver Max Reitz
                   ` (5 preceding siblings ...)
  2018-04-16 16:58 ` [Qemu-devel] [PATCH 6/9] block: Support BDRV_REQ_WRITE_UNCHANGED in filters Max Reitz
@ 2018-04-16 16:58 ` Max Reitz
  2018-04-20  8:38   ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
  2018-04-20 12:20   ` Alberto Garcia
  2018-04-16 16:58 ` [Qemu-devel] [PATCH 8/9] iotests: Copy 197 for COR filter driver Max Reitz
                   ` (2 subsequent siblings)
  9 siblings, 2 replies; 29+ messages in thread
From: Max Reitz @ 2018-04-16 16:58 UTC (permalink / raw)
  To: qemu-block; +Cc: qemu-devel, Max Reitz, Kevin Wolf, Stefan Hajnoczi, Fam Zheng

Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 tests/qemu-iotests/197 | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tests/qemu-iotests/197 b/tests/qemu-iotests/197
index 5e869fe2b7..3ae4975eec 100755
--- a/tests/qemu-iotests/197
+++ b/tests/qemu-iotests/197
@@ -44,6 +44,7 @@ esac
 _cleanup()
 {
     _cleanup_test_img
+    rm -f "$TEST_WRAP"
     rm -f "$BLKDBG_CONF"
 }
 trap "_cleanup; exit \$status" 0 1 2 3 15
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [Qemu-devel] [PATCH 8/9] iotests: Copy 197 for COR filter driver
  2018-04-16 16:58 [Qemu-devel] [PATCH 0/9] block: Add COR filter driver Max Reitz
                   ` (6 preceding siblings ...)
  2018-04-16 16:58 ` [Qemu-devel] [PATCH 7/9] iotests: Clean up wrap image in 197 Max Reitz
@ 2018-04-16 16:58 ` Max Reitz
  2018-04-20  8:38   ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
  2018-04-16 16:58 ` [Qemu-devel] [PATCH 9/9] iotests: Add test for COR across nodes Max Reitz
  2018-04-20  7:49 ` [Qemu-devel] [PATCH 0/9] block: Add COR filter driver Stefan Hajnoczi
  9 siblings, 1 reply; 29+ messages in thread
From: Max Reitz @ 2018-04-16 16:58 UTC (permalink / raw)
  To: qemu-block; +Cc: qemu-devel, Max Reitz, Kevin Wolf, Stefan Hajnoczi, Fam Zheng

iotest 197 tests copy-on-read using the (now old) copy-on-read flag.
Copy it to 215 and modify it to use the COR filter driver instead.

Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 tests/qemu-iotests/215     | 120 +++++++++++++++++++++++++++++++++++++++++++++
 tests/qemu-iotests/215.out |  26 ++++++++++
 tests/qemu-iotests/group   |   1 +
 3 files changed, 147 insertions(+)
 create mode 100755 tests/qemu-iotests/215
 create mode 100644 tests/qemu-iotests/215.out

diff --git a/tests/qemu-iotests/215 b/tests/qemu-iotests/215
new file mode 100755
index 0000000000..8c4073a439
--- /dev/null
+++ b/tests/qemu-iotests/215
@@ -0,0 +1,120 @@
+#!/bin/bash
+#
+# Test case for copy-on-read into qcow2, using the COR filter driver
+#
+# Copyright (C) 2018 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+
+seq="$(basename $0)"
+echo "QA output created by $seq"
+
+here="$PWD"
+status=1 # failure is the default!
+
+# get standard environment, filters and checks
+. ./common.rc
+. ./common.filter
+
+TEST_WRAP="$TEST_DIR/t.wrap.qcow2"
+BLKDBG_CONF="$TEST_DIR/blkdebug.conf"
+
+# Sanity check: our use of blkdebug fails if $TEST_DIR contains spaces
+# or other problems
+case "$TEST_DIR" in
+    *[^-_a-zA-Z0-9/]*)
+        _notrun "Suspicious TEST_DIR='$TEST_DIR', cowardly refusing to run" ;;
+esac
+
+_cleanup()
+{
+    _cleanup_test_img
+    rm -f "$TEST_WRAP"
+    rm -f "$BLKDBG_CONF"
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+# Test is supported for any backing file; but we force qcow2 for our wrapper.
+_supported_fmt generic
+_supported_proto generic
+_supported_os Linux
+# LUKS support may be possible, but it complicates things.
+_unsupported_fmt luks
+
+echo
+echo '=== Copy-on-read ==='
+echo
+
+# Prep the images
+# VPC rounds image sizes to a specific geometry, force a specific size.
+if [ "$IMGFMT" = "vpc" ]; then
+    IMGOPTS=$(_optstr_add "$IMGOPTS" "force_size")
+fi
+_make_test_img 4G
+$QEMU_IO -c "write -P 55 3G 1k" "$TEST_IMG" | _filter_qemu_io
+IMGPROTO=file IMGFMT=qcow2 IMGOPTS= TEST_IMG_FILE="$TEST_WRAP" \
+    _make_test_img -F "$IMGFMT" -b "$TEST_IMG" | _filter_img_create
+$QEMU_IO -f qcow2 -c "write -z -u 1M 64k" "$TEST_WRAP" | _filter_qemu_io
+
+# Ensure that a read of two clusters, but where one is already allocated,
+# does not re-write the allocated cluster
+cat > "$BLKDBG_CONF" <<EOF
+[inject-error]
+event = "cor_write"
+sector = "2048"
+EOF
+$QEMU_IO -c "open \
+ -o driver=cor,file.driver=blkdebug,file.config=$BLKDBG_CONF,file.image.driver=qcow2 $TEST_WRAP" \
+ -c "read -P 0 1M 128k" | _filter_qemu_io
+
+# Read the areas we want copied. A zero-length read should still be a
+# no-op.  The next read is under 2G, but aligned so that rounding to
+# clusters copies more than 2G of zeroes. The final read will pick up
+# the non-zero data in the same cluster.  Since a 2G read may exhaust
+# memory on some machines (particularly 32-bit), we skip the test if
+# that fails due to memory pressure.
+$QEMU_IO \
+    -c "open -o driver=cor,file.driver=qcow2 $TEST_WRAP" \
+    -c "read 0 0" \
+    | _filter_qemu_io
+output=$($QEMU_IO \
+         -c "open -o driver=cor,file.driver=qcow2 $TEST_WRAP" \
+         -c "read -P 0 1k $((2*1024*1024*1024 - 512))" \
+         2>&1 | _filter_qemu_io)
+case $output in
+    *allocate*)
+        _notrun "Insufficent memory to run test" ;;
+    *) printf '%s\n' "$output" ;;
+esac
+$QEMU_IO \
+    -c "open -o driver=cor,file.driver=qcow2 $TEST_WRAP" \
+    -c "read -P 0 $((3*1024*1024*1024 + 1024)) 1k" \
+    | _filter_qemu_io
+
+# Copy-on-read is incompatible with read-only
+$QEMU_IO \
+    -c "open -r -o driver=cor,file.driver=qcow2 $TEST_WRAP" \
+    2>&1 | _filter_testdir
+
+# Break the backing chain, and show that images are identical, and that
+# we properly copied over explicit zeros.
+$QEMU_IMG rebase -u -b "" -f qcow2 "$TEST_WRAP"
+$QEMU_IO -f qcow2 -c map "$TEST_WRAP"
+_check_test_img
+$QEMU_IMG compare -f $IMGFMT -F qcow2 "$TEST_IMG" "$TEST_WRAP"
+
+# success, all done
+echo '*** done'
+status=0
diff --git a/tests/qemu-iotests/215.out b/tests/qemu-iotests/215.out
new file mode 100644
index 0000000000..70b0f5fb19
--- /dev/null
+++ b/tests/qemu-iotests/215.out
@@ -0,0 +1,26 @@
+QA output created by 215
+
+=== Copy-on-read ===
+
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=4294967296
+wrote 1024/1024 bytes at offset 3221225472
+1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+Formatting 'TEST_DIR/t.wrap.IMGFMT', fmt=IMGFMT size=4294967296 backing_file=TEST_DIR/t.IMGFMT backing_fmt=IMGFMT
+wrote 65536/65536 bytes at offset 1048576
+64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+read 131072/131072 bytes at offset 1048576
+128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+read 0/0 bytes at offset 0
+0 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+read 2147483136/2147483136 bytes at offset 1024
+2 GiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+read 1024/1024 bytes at offset 3221226496
+1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+can't open device TEST_DIR/t.wrap.qcow2: Block node is read-only
+2 GiB (0x80010000) bytes     allocated at offset 0 bytes (0x0)
+1023.938 MiB (0x3fff0000) bytes not allocated at offset 2 GiB (0x80010000)
+64 KiB (0x10000) bytes     allocated at offset 3 GiB (0xc0000000)
+1023.938 MiB (0x3fff0000) bytes not allocated at offset 3 GiB (0xc0010000)
+No errors were found on the image.
+Images are identical.
+*** done
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
index 3e2dcdfa33..f1179ffde7 100644
--- a/tests/qemu-iotests/group
+++ b/tests/qemu-iotests/group
@@ -213,3 +213,4 @@
 212 rw auto quick
 213 rw auto quick
 214 rw auto
+215 rw auto quick
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [Qemu-devel] [PATCH 9/9] iotests: Add test for COR across nodes
  2018-04-16 16:58 [Qemu-devel] [PATCH 0/9] block: Add COR filter driver Max Reitz
                   ` (7 preceding siblings ...)
  2018-04-16 16:58 ` [Qemu-devel] [PATCH 8/9] iotests: Copy 197 for COR filter driver Max Reitz
@ 2018-04-16 16:58 ` Max Reitz
  2018-04-20  8:43   ` Stefan Hajnoczi
  2018-04-20  7:49 ` [Qemu-devel] [PATCH 0/9] block: Add COR filter driver Stefan Hajnoczi
  9 siblings, 1 reply; 29+ messages in thread
From: Max Reitz @ 2018-04-16 16:58 UTC (permalink / raw)
  To: qemu-block; +Cc: qemu-devel, Max Reitz, Kevin Wolf, Stefan Hajnoczi, Fam Zheng

COR across nodes (that is, you have some filter node between the
actually COR target and the node that performs the COR) cannot reliably
work together with the permission system when there is no explicit COR
node that can request the WRITE_UNCHANGED permission for its child.
This is because COR (currently) sneaks its requests by the usual
permission checks, so it can work without a WRITE* permission; but if
there is a filter node in between, that will re-issue the request, which
then passes through the usual check -- and if nobody has requested a
WRITE_UNCHANGED permission, that check will fail.

There is no real direct fix apart from hoping that there is someone who
has requested that permission; in case of just the qemu-io HMP command
(and no guest device), however, that is not the case.  The real real fix
is to implement the copy-on-read flag through an implicitly added COR
node.  Such a node can request the necessary permissions as shown in
this test.

Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 tests/qemu-iotests/216     | 117 +++++++++++++++++++++++++++++++++++++++++++++
 tests/qemu-iotests/216.out |  28 +++++++++++
 tests/qemu-iotests/group   |   1 +
 3 files changed, 146 insertions(+)
 create mode 100755 tests/qemu-iotests/216
 create mode 100644 tests/qemu-iotests/216.out

diff --git a/tests/qemu-iotests/216 b/tests/qemu-iotests/216
new file mode 100755
index 0000000000..2f34f94faa
--- /dev/null
+++ b/tests/qemu-iotests/216
@@ -0,0 +1,117 @@
+#!/usr/bin/env python
+#
+# Copy-on-read tests using a COR filter node
+#
+# Copyright (C) 2018 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+# Creator/Owner: Max Reitz <mreitz@redhat.com>
+#
+# Non-shared storage migration test using NBD server and drive-mirror
+
+import iotests
+from iotests import log, qemu_img_pipe, qemu_io, filter_qemu_io
+
+# Need backing file support
+iotests.verify_image_format(supported_fmts=['qcow2', 'qcow', 'qed', 'vmdk'])
+iotests.verify_platform(['linux'])
+
+log('')
+log('=== Copy-on-read across nodes ===')
+log('')
+
+# The old copy-on-read mechanism without a filter node cannot request
+# WRITE_UNCHANGED permissions for its child.  Therefore it just tries
+# to sneak its write by the usual permission system and holds its
+# fingers crossed.  However, that sneaking does not work so well when
+# there is a filter node in the way: That will receive the write
+# request and re-issue a new one to its child, which this time is a
+# proper write request that will make the permission system cough --
+# unless there is someone at the top (like a guest device) that has
+# requested write permissions.
+#
+# A COR filter node, however, can request the proper permissions for
+# its child and therefore is not hit by this issue.
+
+with iotests.FilePath('base.img') as base_img_path, \
+     iotests.FilePath('top.img') as top_img_path, \
+     iotests.VM() as vm:
+
+    log('--- Setting up images ---')
+    log('')
+
+    qemu_img_pipe('create', '-f', iotests.imgfmt, base_img_path, '64M')
+
+    log(filter_qemu_io(qemu_io(base_img_path, '-c', 'write -P 1 0M 1M')))
+
+    qemu_img_pipe('create', '-f', iotests.imgfmt, '-b', base_img_path,
+                  top_img_path)
+
+    log(filter_qemu_io(qemu_io(top_img_path,  '-c', 'write -P 2 1M 1M')))
+
+    log('')
+    log('--- Doing COR ---')
+    log('')
+
+    # Compare with e.g. the following:
+    #   vm.add_drive_raw('if=none,node-name=node0,copy-on-read=on,driver=raw,' \
+    #                    'file.driver=%s,file.file.filename=%s' %
+    #                       (iotests.imgfmt, top_img_path))
+    # (Remove the blockdev-add instead.)
+    # ((Not tested here because it hits an assertion in the permission
+    #   system.))
+
+    vm.launch()
+
+    log(vm.qmp('blockdev-add',
+                    node_name='node0',
+                    driver='cor',
+                    file={
+                        'driver': 'raw',
+                        'file': {
+                            'driver': 'cor',
+                            'file': {
+                                'driver': 'raw',
+                                'file': {
+                                    'driver': iotests.imgfmt,
+                                    'file': {
+                                        'driver': 'file',
+                                        'filename': top_img_path
+                                    },
+                                    'backing': {
+                                        'driver': iotests.imgfmt,
+                                        'file': {
+                                            'driver': 'file',
+                                            'filename': base_img_path
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                    }))
+
+    # Trigger COR
+    log(vm.qmp('human-monitor-command',
+               command_line='qemu-io node0 "read 0 64M"'))
+
+    vm.shutdown()
+
+    log('')
+    log('--- Checking COR result ---')
+    log('')
+
+    log(filter_qemu_io(qemu_io(base_img_path, '-c', 'discard 0 64M')))
+    log(filter_qemu_io(qemu_io(top_img_path,  '-c', 'read -P 1 0M 1M')))
+    log(filter_qemu_io(qemu_io(top_img_path,  '-c', 'read -P 2 1M 1M')))
diff --git a/tests/qemu-iotests/216.out b/tests/qemu-iotests/216.out
new file mode 100644
index 0000000000..d3fc590d29
--- /dev/null
+++ b/tests/qemu-iotests/216.out
@@ -0,0 +1,28 @@
+
+=== Copy-on-read across nodes ===
+
+--- Setting up images ---
+
+wrote 1048576/1048576 bytes at offset 0
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+
+wrote 1048576/1048576 bytes at offset 1048576
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+
+
+--- Doing COR ---
+
+{u'return': {}}
+{u'return': u''}
+
+--- Checking COR result ---
+
+discard 67108864/67108864 bytes at offset 0
+64 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+
+read 1048576/1048576 bytes at offset 0
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+
+read 1048576/1048576 bytes at offset 1048576
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
index f1179ffde7..2edc377370 100644
--- a/tests/qemu-iotests/group
+++ b/tests/qemu-iotests/group
@@ -214,3 +214,4 @@
 213 rw auto quick
 214 rw auto
 215 rw auto quick
+216 rw auto quick
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 29+ messages in thread

* Re: [Qemu-devel] [PATCH 0/9] block: Add COR filter driver
  2018-04-16 16:58 [Qemu-devel] [PATCH 0/9] block: Add COR filter driver Max Reitz
                   ` (8 preceding siblings ...)
  2018-04-16 16:58 ` [Qemu-devel] [PATCH 9/9] iotests: Add test for COR across nodes Max Reitz
@ 2018-04-20  7:49 ` Stefan Hajnoczi
  9 siblings, 0 replies; 29+ messages in thread
From: Stefan Hajnoczi @ 2018-04-20  7:49 UTC (permalink / raw)
  To: Max Reitz; +Cc: qemu-block, Kevin Wolf, Fam Zheng, qemu-devel, Stefan Hajnoczi

[-- Attachment #1: Type: text/plain, Size: 291 bytes --]

On Mon, Apr 16, 2018 at 06:58:40PM +0200, Max Reitz wrote:
> In our quest to... (Oh, man, I always struggle with writing cover
> letters.  But rarely have I become stuck so early on.)  Orthogonalize?

You were off to a shaky start but it turned out to be a really good
cover letter.

Stefan

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [Qemu-devel] [Qemu-block] [PATCH 1/9] block: Add COR filter driver
  2018-04-16 16:58 ` [Qemu-devel] [PATCH 1/9] " Max Reitz
@ 2018-04-20  8:31   ` Stefan Hajnoczi
  2018-04-20 13:21     ` Max Reitz
  0 siblings, 1 reply; 29+ messages in thread
From: Stefan Hajnoczi @ 2018-04-20  8:31 UTC (permalink / raw)
  To: Max Reitz; +Cc: qemu-block, Kevin Wolf, Fam Zheng, qemu-devel, Stefan Hajnoczi

[-- Attachment #1: Type: text/plain, Size: 352 bytes --]

On Mon, Apr 16, 2018 at 06:58:41PM +0200, Max Reitz wrote:
>  { 'enum': 'BlockdevDriver',
> -  'data': [ 'blkdebug', 'blkverify', 'bochs', 'cloop',
> +  'data': [ 'blkdebug', 'blkverify', 'bochs', 'cloop', 'cor',

"copy-on-read" would be clearer than "cor" for the QMP API and the
block/cor.c source file.  Is there a need to make the name very short?

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [Qemu-devel] [Qemu-block] [PATCH 2/9] block: BLK_PERM_WRITE includes ..._UNCHANGED
  2018-04-16 16:58 ` [Qemu-devel] [PATCH 2/9] block: BLK_PERM_WRITE includes ..._UNCHANGED Max Reitz
@ 2018-04-20  8:32   ` Stefan Hajnoczi
  2018-04-20 12:04   ` Alberto Garcia
  1 sibling, 0 replies; 29+ messages in thread
From: Stefan Hajnoczi @ 2018-04-20  8:32 UTC (permalink / raw)
  To: Max Reitz; +Cc: qemu-block, Kevin Wolf, Fam Zheng, qemu-devel, Stefan Hajnoczi

[-- Attachment #1: Type: text/plain, Size: 411 bytes --]

On Mon, Apr 16, 2018 at 06:58:42PM +0200, Max Reitz wrote:
> Currently we never actually check whether the WRITE_UNCHANGED
> permission has been taken for unchanging writes.  But the one check that
> is commented out checks both WRITE and WRITE_UNCHANGED; and considering
> that WRITE_UNCHANGED is already documented as being weaker then WRITE,

s/then/than/

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [Qemu-devel] [PATCH 3/9] block: Add BDRV_REQ_WRITE_UNCHANGED flag
  2018-04-16 16:58 ` [Qemu-devel] [PATCH 3/9] block: Add BDRV_REQ_WRITE_UNCHANGED flag Max Reitz
@ 2018-04-20  8:33   ` Stefan Hajnoczi
  2018-04-20 12:06   ` [Qemu-devel] [Qemu-block] " Alberto Garcia
  1 sibling, 0 replies; 29+ messages in thread
From: Stefan Hajnoczi @ 2018-04-20  8:33 UTC (permalink / raw)
  To: Max Reitz; +Cc: qemu-block, Kevin Wolf, Fam Zheng, qemu-devel, Stefan Hajnoczi

[-- Attachment #1: Type: text/plain, Size: 506 bytes --]

On Mon, Apr 16, 2018 at 06:58:43PM +0200, Max Reitz wrote:
> This flag signifies that a write request will not change the visible
> disk content.  With this flag set, it is sufficient to have the
> BLK_PERM_WRITE_UNCHANGED permission instead of BLK_PERM_WRITE.
> 
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> ---
>  include/block/block.h | 6 +++++-
>  block/io.c            | 6 +++++-
>  2 files changed, 10 insertions(+), 2 deletions(-)

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [Qemu-devel] [Qemu-block] [PATCH 4/9] block: Set BDRV_REQ_WRITE_UNCHANGED for COR writes
  2018-04-16 16:58 ` [Qemu-devel] [PATCH 4/9] block: Set BDRV_REQ_WRITE_UNCHANGED for COR writes Max Reitz
@ 2018-04-20  8:33   ` Stefan Hajnoczi
  2018-04-20 12:06   ` Alberto Garcia
  1 sibling, 0 replies; 29+ messages in thread
From: Stefan Hajnoczi @ 2018-04-20  8:33 UTC (permalink / raw)
  To: Max Reitz; +Cc: qemu-block, Kevin Wolf, Fam Zheng, qemu-devel, Stefan Hajnoczi

[-- Attachment #1: Type: text/plain, Size: 240 bytes --]

On Mon, Apr 16, 2018 at 06:58:44PM +0200, Max Reitz wrote:
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> ---
>  block/io.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [Qemu-devel] [Qemu-block] [PATCH 6/9] block: Support BDRV_REQ_WRITE_UNCHANGED in filters
  2018-04-16 16:58 ` [Qemu-devel] [PATCH 6/9] block: Support BDRV_REQ_WRITE_UNCHANGED in filters Max Reitz
@ 2018-04-20  8:35   ` Stefan Hajnoczi
  2018-04-20 12:19   ` Alberto Garcia
  1 sibling, 0 replies; 29+ messages in thread
From: Stefan Hajnoczi @ 2018-04-20  8:35 UTC (permalink / raw)
  To: Max Reitz; +Cc: qemu-block, Kevin Wolf, Fam Zheng, qemu-devel, Stefan Hajnoczi

[-- Attachment #1: Type: text/plain, Size: 1405 bytes --]

On Mon, Apr 16, 2018 at 06:58:46PM +0200, Max Reitz wrote:
> Update the rest of the filter drivers to support
> BDRV_REQ_WRITE_UNCHANGED.  They already forward write request flags to
> their children, so we just have to announce support for it.
> 
> This patch does not cover the replication driver because that currently
> does not support flags at all, and because it just grabs the WRITE
> permission for its children when it can, so we should be fine just
> submitting the incoming WRITE_UNCHANGED requests as normal writes.
> 
> It also does not cover format drivers for similar reasons.  They all use
> bdrv_format_default_perms() as their .bdrv_child_perm() implementation
> so they just always grab the WRITE permission for their file children
> whenever possible.  In addition, it often would be difficult to
> ascertain whether incoming unchanging writes end up as unchanging writes
> in their files.  So we just leave them as normal potentially changing
> writes.
> 
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> ---
>  block/blkdebug.c   |  9 +++++----
>  block/blkreplay.c  |  3 +++
>  block/blkverify.c  |  3 +++
>  block/cor.c        | 10 ++++++----
>  block/mirror.c     |  2 ++
>  block/raw-format.c |  9 +++++----
>  block/throttle.c   |  6 ++++--
>  7 files changed, 28 insertions(+), 14 deletions(-)

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [Qemu-devel] [Qemu-block] [PATCH 7/9] iotests: Clean up wrap image in 197
  2018-04-16 16:58 ` [Qemu-devel] [PATCH 7/9] iotests: Clean up wrap image in 197 Max Reitz
@ 2018-04-20  8:38   ` Stefan Hajnoczi
  2018-04-20 12:20   ` Alberto Garcia
  1 sibling, 0 replies; 29+ messages in thread
From: Stefan Hajnoczi @ 2018-04-20  8:38 UTC (permalink / raw)
  To: Max Reitz; +Cc: qemu-block, Kevin Wolf, Fam Zheng, qemu-devel, Stefan Hajnoczi

[-- Attachment #1: Type: text/plain, Size: 230 bytes --]

On Mon, Apr 16, 2018 at 06:58:47PM +0200, Max Reitz wrote:
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> ---
>  tests/qemu-iotests/197 | 1 +
>  1 file changed, 1 insertion(+)

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [Qemu-devel] [Qemu-block] [PATCH 8/9] iotests: Copy 197 for COR filter driver
  2018-04-16 16:58 ` [Qemu-devel] [PATCH 8/9] iotests: Copy 197 for COR filter driver Max Reitz
@ 2018-04-20  8:38   ` Stefan Hajnoczi
  0 siblings, 0 replies; 29+ messages in thread
From: Stefan Hajnoczi @ 2018-04-20  8:38 UTC (permalink / raw)
  To: Max Reitz; +Cc: qemu-block, Kevin Wolf, Fam Zheng, qemu-devel, Stefan Hajnoczi

[-- Attachment #1: Type: text/plain, Size: 620 bytes --]

On Mon, Apr 16, 2018 at 06:58:48PM +0200, Max Reitz wrote:
> iotest 197 tests copy-on-read using the (now old) copy-on-read flag.
> Copy it to 215 and modify it to use the COR filter driver instead.
> 
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> ---
>  tests/qemu-iotests/215     | 120 +++++++++++++++++++++++++++++++++++++++++++++
>  tests/qemu-iotests/215.out |  26 ++++++++++
>  tests/qemu-iotests/group   |   1 +
>  3 files changed, 147 insertions(+)
>  create mode 100755 tests/qemu-iotests/215
>  create mode 100644 tests/qemu-iotests/215.out

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [Qemu-devel] [PATCH 9/9] iotests: Add test for COR across nodes
  2018-04-16 16:58 ` [Qemu-devel] [PATCH 9/9] iotests: Add test for COR across nodes Max Reitz
@ 2018-04-20  8:43   ` Stefan Hajnoczi
  2018-04-20 13:22     ` Max Reitz
  0 siblings, 1 reply; 29+ messages in thread
From: Stefan Hajnoczi @ 2018-04-20  8:43 UTC (permalink / raw)
  To: Max Reitz; +Cc: qemu-block, Kevin Wolf, Fam Zheng, qemu-devel, Stefan Hajnoczi

[-- Attachment #1: Type: text/plain, Size: 347 bytes --]

On Mon, Apr 16, 2018 at 06:58:49PM +0200, Max Reitz wrote:
> diff --git a/tests/qemu-iotests/216 b/tests/qemu-iotests/216
> new file mode 100755
> index 0000000000..2f34f94faa
> --- /dev/null
> +++ b/tests/qemu-iotests/216
> @@ -0,0 +1,117 @@
> +#!/usr/bin/env python

Welcome to the dark side!

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [Qemu-devel] [PATCH 5/9] block/quorum: Support BDRV_REQ_WRITE_UNCHANGED
  2018-04-16 16:58 ` [Qemu-devel] [PATCH 5/9] block/quorum: Support BDRV_REQ_WRITE_UNCHANGED Max Reitz
@ 2018-04-20  8:44   ` Stefan Hajnoczi
  2018-04-20 12:09   ` [Qemu-devel] [Qemu-block] " Alberto Garcia
  1 sibling, 0 replies; 29+ messages in thread
From: Stefan Hajnoczi @ 2018-04-20  8:44 UTC (permalink / raw)
  To: Max Reitz; +Cc: qemu-block, Kevin Wolf, Fam Zheng, qemu-devel, Stefan Hajnoczi

[-- Attachment #1: Type: text/plain, Size: 450 bytes --]

On Mon, Apr 16, 2018 at 06:58:45PM +0200, Max Reitz wrote:
> We just need to forward it to quorum's children (except in case of a
> rewrite because of corruption), but for that we first have to support
> flags in child requests at all.
> 
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> ---
>  block/quorum.c | 19 +++++++++++++------
>  1 file changed, 13 insertions(+), 6 deletions(-)

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [Qemu-devel] [Qemu-block] [PATCH 2/9] block: BLK_PERM_WRITE includes ..._UNCHANGED
  2018-04-16 16:58 ` [Qemu-devel] [PATCH 2/9] block: BLK_PERM_WRITE includes ..._UNCHANGED Max Reitz
  2018-04-20  8:32   ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
@ 2018-04-20 12:04   ` Alberto Garcia
  2018-04-20 13:22     ` Max Reitz
  1 sibling, 1 reply; 29+ messages in thread
From: Alberto Garcia @ 2018-04-20 12:04 UTC (permalink / raw)
  To: Max Reitz, qemu-block; +Cc: Kevin Wolf, Fam Zheng, qemu-devel, Stefan Hajnoczi

On Mon 16 Apr 2018 06:58:42 PM CEST, Max Reitz wrote:
> Currently we never actually check whether the WRITE_UNCHANGED
> permission has been taken for unchanging writes.  But the one check that
> is commented out checks both WRITE and WRITE_UNCHANGED; and considering
> that WRITE_UNCHANGED is already documented as being weaker then WRITE,
> we should probably explicitly document WRITE to include WRITE_UNCHANGED.
>
> Signed-off-by: Max Reitz <mreitz@redhat.com>

Reviewed-by: Alberto Garcia <berto@igalia.com>

s/then/than/ as Stefan mentioned.

Berto

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [Qemu-devel] [Qemu-block] [PATCH 3/9] block: Add BDRV_REQ_WRITE_UNCHANGED flag
  2018-04-16 16:58 ` [Qemu-devel] [PATCH 3/9] block: Add BDRV_REQ_WRITE_UNCHANGED flag Max Reitz
  2018-04-20  8:33   ` Stefan Hajnoczi
@ 2018-04-20 12:06   ` Alberto Garcia
  1 sibling, 0 replies; 29+ messages in thread
From: Alberto Garcia @ 2018-04-20 12:06 UTC (permalink / raw)
  To: Max Reitz, qemu-block; +Cc: Kevin Wolf, Fam Zheng, qemu-devel, Stefan Hajnoczi

On Mon 16 Apr 2018 06:58:43 PM CEST, Max Reitz wrote:
> This flag signifies that a write request will not change the visible
> disk content.  With this flag set, it is sufficient to have the
> BLK_PERM_WRITE_UNCHANGED permission instead of BLK_PERM_WRITE.
>
> Signed-off-by: Max Reitz <mreitz@redhat.com>

Reviewed-by: Alberto Garcia <berto@igalia.com>

Berto

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [Qemu-devel] [Qemu-block] [PATCH 4/9] block: Set BDRV_REQ_WRITE_UNCHANGED for COR writes
  2018-04-16 16:58 ` [Qemu-devel] [PATCH 4/9] block: Set BDRV_REQ_WRITE_UNCHANGED for COR writes Max Reitz
  2018-04-20  8:33   ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
@ 2018-04-20 12:06   ` Alberto Garcia
  1 sibling, 0 replies; 29+ messages in thread
From: Alberto Garcia @ 2018-04-20 12:06 UTC (permalink / raw)
  To: Max Reitz, qemu-block; +Cc: Kevin Wolf, Fam Zheng, qemu-devel, Stefan Hajnoczi

On Mon 16 Apr 2018 06:58:44 PM CEST, Max Reitz wrote:
> Signed-off-by: Max Reitz <mreitz@redhat.com>

Reviewed-by: Alberto Garcia <berto@igalia.com>

Berto

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [Qemu-devel] [Qemu-block] [PATCH 5/9] block/quorum: Support BDRV_REQ_WRITE_UNCHANGED
  2018-04-16 16:58 ` [Qemu-devel] [PATCH 5/9] block/quorum: Support BDRV_REQ_WRITE_UNCHANGED Max Reitz
  2018-04-20  8:44   ` Stefan Hajnoczi
@ 2018-04-20 12:09   ` Alberto Garcia
  1 sibling, 0 replies; 29+ messages in thread
From: Alberto Garcia @ 2018-04-20 12:09 UTC (permalink / raw)
  To: Max Reitz, qemu-block; +Cc: Kevin Wolf, Fam Zheng, qemu-devel, Stefan Hajnoczi

On Mon 16 Apr 2018 06:58:45 PM CEST, Max Reitz wrote:
> We just need to forward it to quorum's children (except in case of a
> rewrite because of corruption), but for that we first have to support
> flags in child requests at all.
>
> Signed-off-by: Max Reitz <mreitz@redhat.com>

Reviewed-by: Alberto Garcia <berto@igalia.com>

Berto

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [Qemu-devel] [Qemu-block] [PATCH 6/9] block: Support BDRV_REQ_WRITE_UNCHANGED in filters
  2018-04-16 16:58 ` [Qemu-devel] [PATCH 6/9] block: Support BDRV_REQ_WRITE_UNCHANGED in filters Max Reitz
  2018-04-20  8:35   ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
@ 2018-04-20 12:19   ` Alberto Garcia
  1 sibling, 0 replies; 29+ messages in thread
From: Alberto Garcia @ 2018-04-20 12:19 UTC (permalink / raw)
  To: Max Reitz, qemu-block; +Cc: Kevin Wolf, Fam Zheng, qemu-devel, Stefan Hajnoczi

On Mon 16 Apr 2018 06:58:46 PM CEST, Max Reitz wrote:
> Update the rest of the filter drivers to support
> BDRV_REQ_WRITE_UNCHANGED.  They already forward write request flags to
> their children, so we just have to announce support for it.
>
> This patch does not cover the replication driver because that currently
> does not support flags at all, and because it just grabs the WRITE
> permission for its children when it can, so we should be fine just
> submitting the incoming WRITE_UNCHANGED requests as normal writes.
>
> It also does not cover format drivers for similar reasons.  They all use
> bdrv_format_default_perms() as their .bdrv_child_perm() implementation
> so they just always grab the WRITE permission for their file children
> whenever possible.  In addition, it often would be difficult to
> ascertain whether incoming unchanging writes end up as unchanging writes
> in their files.  So we just leave them as normal potentially changing
> writes.
>
> Signed-off-by: Max Reitz <mreitz@redhat.com>

Reviewed-by: Alberto Garcia <berto@igalia.com>

Berto

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [Qemu-devel] [Qemu-block] [PATCH 7/9] iotests: Clean up wrap image in 197
  2018-04-16 16:58 ` [Qemu-devel] [PATCH 7/9] iotests: Clean up wrap image in 197 Max Reitz
  2018-04-20  8:38   ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
@ 2018-04-20 12:20   ` Alberto Garcia
  1 sibling, 0 replies; 29+ messages in thread
From: Alberto Garcia @ 2018-04-20 12:20 UTC (permalink / raw)
  To: Max Reitz, qemu-block; +Cc: Kevin Wolf, Fam Zheng, qemu-devel, Stefan Hajnoczi

On Mon 16 Apr 2018 06:58:47 PM CEST, Max Reitz wrote:
> Signed-off-by: Max Reitz <mreitz@redhat.com>

Reviewed-by: Alberto Garcia <berto@igalia.com>

Berto

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [Qemu-devel] [Qemu-block] [PATCH 1/9] block: Add COR filter driver
  2018-04-20  8:31   ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
@ 2018-04-20 13:21     ` Max Reitz
  0 siblings, 0 replies; 29+ messages in thread
From: Max Reitz @ 2018-04-20 13:21 UTC (permalink / raw)
  To: Stefan Hajnoczi
  Cc: qemu-block, Kevin Wolf, Fam Zheng, qemu-devel, Stefan Hajnoczi

[-- Attachment #1: Type: text/plain, Size: 813 bytes --]

On 2018-04-20 10:31, Stefan Hajnoczi wrote:
> On Mon, Apr 16, 2018 at 06:58:41PM +0200, Max Reitz wrote:
>>  { 'enum': 'BlockdevDriver',
>> -  'data': [ 'blkdebug', 'blkverify', 'bochs', 'cloop',
>> +  'data': [ 'blkdebug', 'blkverify', 'bochs', 'cloop', 'cor',
> 
> "copy-on-read" would be clearer than "cor" for the QMP API and the
> block/cor.c source file.  Is there a need to make the name very short?

There definitely is no need.  I decided I'd prefer to type less in the
test cases, so I went for the shorter name.  (I thought blockdev-add was
sufficiently verbose as it is.)

But I don't mind un-abbreviating it either.  (Probably better
considering that blockdev-add is already verbose, so there is no point
in making parts of it artificially dense.)


Thanks for reviewing!

Max


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [Qemu-devel] [PATCH 9/9] iotests: Add test for COR across nodes
  2018-04-20  8:43   ` Stefan Hajnoczi
@ 2018-04-20 13:22     ` Max Reitz
  0 siblings, 0 replies; 29+ messages in thread
From: Max Reitz @ 2018-04-20 13:22 UTC (permalink / raw)
  To: Stefan Hajnoczi
  Cc: qemu-block, Kevin Wolf, Fam Zheng, qemu-devel, Stefan Hajnoczi

[-- Attachment #1: Type: text/plain, Size: 430 bytes --]

On 2018-04-20 10:43, Stefan Hajnoczi wrote:
> On Mon, Apr 16, 2018 at 06:58:49PM +0200, Max Reitz wrote:
>> diff --git a/tests/qemu-iotests/216 b/tests/qemu-iotests/216
>> new file mode 100755
>> index 0000000000..2f34f94faa
>> --- /dev/null
>> +++ b/tests/qemu-iotests/216
>> @@ -0,0 +1,117 @@
>> +#!/usr/bin/env python
> 
> Welcome to the dark side!

:-)

> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [Qemu-devel] [Qemu-block] [PATCH 2/9] block: BLK_PERM_WRITE includes ..._UNCHANGED
  2018-04-20 12:04   ` Alberto Garcia
@ 2018-04-20 13:22     ` Max Reitz
  0 siblings, 0 replies; 29+ messages in thread
From: Max Reitz @ 2018-04-20 13:22 UTC (permalink / raw)
  To: Alberto Garcia, qemu-block
  Cc: Kevin Wolf, Fam Zheng, qemu-devel, Stefan Hajnoczi

[-- Attachment #1: Type: text/plain, Size: 674 bytes --]

On 2018-04-20 14:04, Alberto Garcia wrote:
> On Mon 16 Apr 2018 06:58:42 PM CEST, Max Reitz wrote:
>> Currently we never actually check whether the WRITE_UNCHANGED
>> permission has been taken for unchanging writes.  But the one check that
>> is commented out checks both WRITE and WRITE_UNCHANGED; and considering
>> that WRITE_UNCHANGED is already documented as being weaker then WRITE,
>> we should probably explicitly document WRITE to include WRITE_UNCHANGED.
>>
>> Signed-off-by: Max Reitz <mreitz@redhat.com>
> 
> Reviewed-by: Alberto Garcia <berto@igalia.com>
> 
> s/then/than/ as Stefan mentioned.

Yep, will fix.


Thanks for reviewing!

Max


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 29+ messages in thread

end of thread, other threads:[~2018-04-20 13:22 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-16 16:58 [Qemu-devel] [PATCH 0/9] block: Add COR filter driver Max Reitz
2018-04-16 16:58 ` [Qemu-devel] [PATCH 1/9] " Max Reitz
2018-04-20  8:31   ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2018-04-20 13:21     ` Max Reitz
2018-04-16 16:58 ` [Qemu-devel] [PATCH 2/9] block: BLK_PERM_WRITE includes ..._UNCHANGED Max Reitz
2018-04-20  8:32   ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2018-04-20 12:04   ` Alberto Garcia
2018-04-20 13:22     ` Max Reitz
2018-04-16 16:58 ` [Qemu-devel] [PATCH 3/9] block: Add BDRV_REQ_WRITE_UNCHANGED flag Max Reitz
2018-04-20  8:33   ` Stefan Hajnoczi
2018-04-20 12:06   ` [Qemu-devel] [Qemu-block] " Alberto Garcia
2018-04-16 16:58 ` [Qemu-devel] [PATCH 4/9] block: Set BDRV_REQ_WRITE_UNCHANGED for COR writes Max Reitz
2018-04-20  8:33   ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2018-04-20 12:06   ` Alberto Garcia
2018-04-16 16:58 ` [Qemu-devel] [PATCH 5/9] block/quorum: Support BDRV_REQ_WRITE_UNCHANGED Max Reitz
2018-04-20  8:44   ` Stefan Hajnoczi
2018-04-20 12:09   ` [Qemu-devel] [Qemu-block] " Alberto Garcia
2018-04-16 16:58 ` [Qemu-devel] [PATCH 6/9] block: Support BDRV_REQ_WRITE_UNCHANGED in filters Max Reitz
2018-04-20  8:35   ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2018-04-20 12:19   ` Alberto Garcia
2018-04-16 16:58 ` [Qemu-devel] [PATCH 7/9] iotests: Clean up wrap image in 197 Max Reitz
2018-04-20  8:38   ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2018-04-20 12:20   ` Alberto Garcia
2018-04-16 16:58 ` [Qemu-devel] [PATCH 8/9] iotests: Copy 197 for COR filter driver Max Reitz
2018-04-20  8:38   ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2018-04-16 16:58 ` [Qemu-devel] [PATCH 9/9] iotests: Add test for COR across nodes Max Reitz
2018-04-20  8:43   ` Stefan Hajnoczi
2018-04-20 13:22     ` Max Reitz
2018-04-20  7:49 ` [Qemu-devel] [PATCH 0/9] block: Add COR filter driver Stefan Hajnoczi

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.