Blame SOURCES/kvm-block-Support-BDRV_REQ_WRITE_UNCHANGED-in-filters.patch

ae23c9
From 9cecd3548e9275e7de21801b90c277c7b04cabb4 Mon Sep 17 00:00:00 2001
ae23c9
From: Max Reitz <mreitz@redhat.com>
ae23c9
Date: Mon, 18 Jun 2018 16:12:09 +0200
ae23c9
Subject: [PATCH 042/268] block: Support BDRV_REQ_WRITE_UNCHANGED in filters
ae23c9
ae23c9
RH-Author: Max Reitz <mreitz@redhat.com>
ae23c9
Message-id: <20180618161212.14444-8-mreitz@redhat.com>
ae23c9
Patchwork-id: 80767
ae23c9
O-Subject: [RHV-7.6 qemu-kvm-rhev PATCH 07/10] block: Support BDRV_REQ_WRITE_UNCHANGED in filters
ae23c9
Bugzilla: 1518738
ae23c9
RH-Acked-by: John Snow <jsnow@redhat.com>
ae23c9
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
ae23c9
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
ae23c9
ae23c9
Update the rest of the filter drivers to support
ae23c9
BDRV_REQ_WRITE_UNCHANGED.  They already forward write request flags to
ae23c9
their children, so we just have to announce support for it.
ae23c9
ae23c9
This patch does not cover the replication driver because that currently
ae23c9
does not support flags at all, and because it just grabs the WRITE
ae23c9
permission for its children when it can, so we should be fine just
ae23c9
submitting the incoming WRITE_UNCHANGED requests as normal writes.
ae23c9
ae23c9
It also does not cover format drivers for similar reasons.  They all use
ae23c9
bdrv_format_default_perms() as their .bdrv_child_perm() implementation
ae23c9
so they just always grab the WRITE permission for their file children
ae23c9
whenever possible.  In addition, it often would be difficult to
ae23c9
ascertain whether incoming unchanging writes end up as unchanging writes
ae23c9
in their files.  So we just leave them as normal potentially changing
ae23c9
writes.
ae23c9
ae23c9
Signed-off-by: Max Reitz <mreitz@redhat.com>
ae23c9
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
ae23c9
Reviewed-by: Alberto Garcia <berto@igalia.com>
ae23c9
Message-id: 20180421132929.21610-7-mreitz@redhat.com
ae23c9
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
ae23c9
Signed-off-by: Max Reitz <mreitz@redhat.com>
ae23c9
(cherry picked from commit 228345bf5db8bc97d1c64f062e138d389065d1ab)
ae23c9
Signed-off-by: Max Reitz <mreitz@redhat.com>
ae23c9
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
ae23c9
---
ae23c9
 block/blkdebug.c     |  9 +++++----
ae23c9
 block/blkreplay.c    |  3 +++
ae23c9
 block/blkverify.c    |  3 +++
ae23c9
 block/copy-on-read.c | 10 ++++++----
ae23c9
 block/mirror.c       |  2 ++
ae23c9
 block/raw-format.c   |  9 +++++----
ae23c9
 block/throttle.c     |  6 ++++--
ae23c9
 7 files changed, 28 insertions(+), 14 deletions(-)
ae23c9
ae23c9
diff --git a/block/blkdebug.c b/block/blkdebug.c
ae23c9
index 053372c..526af2a 100644
ae23c9
--- a/block/blkdebug.c
ae23c9
+++ b/block/blkdebug.c
ae23c9
@@ -398,10 +398,11 @@ static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags,
ae23c9
         goto out;
ae23c9
     }
ae23c9
 
ae23c9
-    bs->supported_write_flags = BDRV_REQ_FUA &
ae23c9
-        bs->file->bs->supported_write_flags;
ae23c9
-    bs->supported_zero_flags = (BDRV_REQ_FUA | BDRV_REQ_MAY_UNMAP) &
ae23c9
-        bs->file->bs->supported_zero_flags;
ae23c9
+    bs->supported_write_flags = BDRV_REQ_WRITE_UNCHANGED |
ae23c9
+        (BDRV_REQ_FUA & bs->file->bs->supported_write_flags);
ae23c9
+    bs->supported_zero_flags = BDRV_REQ_WRITE_UNCHANGED |
ae23c9
+        ((BDRV_REQ_FUA | BDRV_REQ_MAY_UNMAP) &
ae23c9
+            bs->file->bs->supported_zero_flags);
ae23c9
     ret = -EINVAL;
ae23c9
 
ae23c9
     /* Set alignment overrides */
ae23c9
diff --git a/block/blkreplay.c b/block/blkreplay.c
ae23c9
index fe5a9b4..b016dbe 100755
ae23c9
--- a/block/blkreplay.c
ae23c9
+++ b/block/blkreplay.c
ae23c9
@@ -35,6 +35,9 @@ static int blkreplay_open(BlockDriverState *bs, QDict *options, int flags,
ae23c9
         goto fail;
ae23c9
     }
ae23c9
 
ae23c9
+    bs->supported_write_flags = BDRV_REQ_WRITE_UNCHANGED;
ae23c9
+    bs->supported_zero_flags = BDRV_REQ_WRITE_UNCHANGED;
ae23c9
+
ae23c9
     ret = 0;
ae23c9
 fail:
ae23c9
     return ret;
ae23c9
diff --git a/block/blkverify.c b/block/blkverify.c
ae23c9
index 754cc9e..da97ee5 100644
ae23c9
--- a/block/blkverify.c
ae23c9
+++ b/block/blkverify.c
ae23c9
@@ -141,6 +141,9 @@ static int blkverify_open(BlockDriverState *bs, QDict *options, int flags,
ae23c9
         goto fail;
ae23c9
     }
ae23c9
 
ae23c9
+    bs->supported_write_flags = BDRV_REQ_WRITE_UNCHANGED;
ae23c9
+    bs->supported_zero_flags = BDRV_REQ_WRITE_UNCHANGED;
ae23c9
+
ae23c9
     ret = 0;
ae23c9
 fail:
ae23c9
     qemu_opts_del(opts);
ae23c9
diff --git a/block/copy-on-read.c b/block/copy-on-read.c
ae23c9
index 823ec75..6a97208 100644
ae23c9
--- a/block/copy-on-read.c
ae23c9
+++ b/block/copy-on-read.c
ae23c9
@@ -33,11 +33,13 @@ static int cor_open(BlockDriverState *bs, QDict *options, int flags,
ae23c9
         return -EINVAL;
ae23c9
     }
ae23c9
 
ae23c9
-    bs->supported_write_flags = BDRV_REQ_FUA &
ae23c9
-                                    bs->file->bs->supported_write_flags;
ae23c9
+    bs->supported_write_flags = BDRV_REQ_WRITE_UNCHANGED |
ae23c9
+                                (BDRV_REQ_FUA &
ae23c9
+                                    bs->file->bs->supported_write_flags);
ae23c9
 
ae23c9
-    bs->supported_zero_flags = (BDRV_REQ_FUA | BDRV_REQ_MAY_UNMAP) &
ae23c9
-                                    bs->file->bs->supported_zero_flags;
ae23c9
+    bs->supported_zero_flags = BDRV_REQ_WRITE_UNCHANGED |
ae23c9
+                               ((BDRV_REQ_FUA | BDRV_REQ_MAY_UNMAP) &
ae23c9
+                                    bs->file->bs->supported_zero_flags);
ae23c9
 
ae23c9
     return 0;
ae23c9
 }
ae23c9
diff --git a/block/mirror.c b/block/mirror.c
ae23c9
index 99da9c0..003f957 100644
ae23c9
--- a/block/mirror.c
ae23c9
+++ b/block/mirror.c
ae23c9
@@ -1152,6 +1152,8 @@ static void mirror_start_job(const char *job_id, BlockDriverState *bs,
ae23c9
         mirror_top_bs->implicit = true;
ae23c9
     }
ae23c9
     mirror_top_bs->total_sectors = bs->total_sectors;
ae23c9
+    mirror_top_bs->supported_write_flags = BDRV_REQ_WRITE_UNCHANGED;
ae23c9
+    mirror_top_bs->supported_zero_flags = BDRV_REQ_WRITE_UNCHANGED;
ae23c9
     bdrv_set_aio_context(mirror_top_bs, bdrv_get_aio_context(bs));
ae23c9
 
ae23c9
     /* bdrv_append takes ownership of the mirror_top_bs reference, need to keep
ae23c9
diff --git a/block/raw-format.c b/block/raw-format.c
ae23c9
index a378547..fe33693 100644
ae23c9
--- a/block/raw-format.c
ae23c9
+++ b/block/raw-format.c
ae23c9
@@ -415,10 +415,11 @@ static int raw_open(BlockDriverState *bs, QDict *options, int flags,
ae23c9
     }
ae23c9
 
ae23c9
     bs->sg = bs->file->bs->sg;
ae23c9
-    bs->supported_write_flags = BDRV_REQ_FUA &
ae23c9
-        bs->file->bs->supported_write_flags;
ae23c9
-    bs->supported_zero_flags = (BDRV_REQ_FUA | BDRV_REQ_MAY_UNMAP) &
ae23c9
-        bs->file->bs->supported_zero_flags;
ae23c9
+    bs->supported_write_flags = BDRV_REQ_WRITE_UNCHANGED |
ae23c9
+        (BDRV_REQ_FUA & bs->file->bs->supported_write_flags);
ae23c9
+    bs->supported_zero_flags = BDRV_REQ_WRITE_UNCHANGED |
ae23c9
+        ((BDRV_REQ_FUA | BDRV_REQ_MAY_UNMAP) &
ae23c9
+            bs->file->bs->supported_zero_flags);
ae23c9
 
ae23c9
     if (bs->probed && !bdrv_is_read_only(bs)) {
ae23c9
         fprintf(stderr,
ae23c9
diff --git a/block/throttle.c b/block/throttle.c
ae23c9
index 95ed06a..e298827 100644
ae23c9
--- a/block/throttle.c
ae23c9
+++ b/block/throttle.c
ae23c9
@@ -81,8 +81,10 @@ static int throttle_open(BlockDriverState *bs, QDict *options,
ae23c9
     if (!bs->file) {
ae23c9
         return -EINVAL;
ae23c9
     }
ae23c9
-    bs->supported_write_flags = bs->file->bs->supported_write_flags;
ae23c9
-    bs->supported_zero_flags = bs->file->bs->supported_zero_flags;
ae23c9
+    bs->supported_write_flags = bs->file->bs->supported_write_flags |
ae23c9
+                                BDRV_REQ_WRITE_UNCHANGED;
ae23c9
+    bs->supported_zero_flags = bs->file->bs->supported_zero_flags |
ae23c9
+                               BDRV_REQ_WRITE_UNCHANGED;
ae23c9
 
ae23c9
     return throttle_configure_tgm(bs, tgm, options, errp);
ae23c9
 }
ae23c9
-- 
ae23c9
1.8.3.1
ae23c9