ae23c9
From b48a7b70caf3883782f8e90fb58b7f46ef6ace88 Mon Sep 17 00:00:00 2001
ae23c9
From: Max Reitz <mreitz@redhat.com>
ae23c9
Date: Mon, 18 Jun 2018 16:12:06 +0200
ae23c9
Subject: [PATCH 039/268] block: Add BDRV_REQ_WRITE_UNCHANGED flag
ae23c9
ae23c9
RH-Author: Max Reitz <mreitz@redhat.com>
ae23c9
Message-id: <20180618161212.14444-5-mreitz@redhat.com>
ae23c9
Patchwork-id: 80764
ae23c9
O-Subject: [RHV-7.6 qemu-kvm-rhev PATCH 04/10] block: Add BDRV_REQ_WRITE_UNCHANGED flag
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
This flag signifies that a write request will not change the visible
ae23c9
disk content.  With this flag set, it is sufficient to have the
ae23c9
BLK_PERM_WRITE_UNCHANGED permission instead of BLK_PERM_WRITE.
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-4-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 c6035964f8316b504060618d05b5dd434f18595b)
ae23c9
Signed-off-by: Max Reitz <mreitz@redhat.com>
ae23c9
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
ae23c9
---
ae23c9
 block/io.c            | 6 +++++-
ae23c9
 include/block/block.h | 6 +++++-
ae23c9
 2 files changed, 10 insertions(+), 2 deletions(-)
ae23c9
ae23c9
diff --git a/block/io.c b/block/io.c
ae23c9
index bd9a19a..134b2a4 100644
ae23c9
--- a/block/io.c
ae23c9
+++ b/block/io.c
ae23c9
@@ -1501,7 +1501,11 @@ static int coroutine_fn bdrv_aligned_pwritev(BdrvChild *child,
ae23c9
     assert(!waited || !req->serialising);
ae23c9
     assert(req->overlap_offset <= offset);
ae23c9
     assert(offset + bytes <= req->overlap_offset + req->overlap_bytes);
ae23c9
-    assert(child->perm & BLK_PERM_WRITE);
ae23c9
+    if (flags & BDRV_REQ_WRITE_UNCHANGED) {
ae23c9
+        assert(child->perm & (BLK_PERM_WRITE_UNCHANGED | BLK_PERM_WRITE));
ae23c9
+    } else {
ae23c9
+        assert(child->perm & BLK_PERM_WRITE);
ae23c9
+    }
ae23c9
     assert(end_sector <= bs->total_sectors || child->perm & BLK_PERM_RESIZE);
ae23c9
 
ae23c9
     ret = notifier_with_return_list_notify(&bs->before_write_notifiers, req);
ae23c9
diff --git a/include/block/block.h b/include/block/block.h
ae23c9
index 397b5e8..3894edd 100644
ae23c9
--- a/include/block/block.h
ae23c9
+++ b/include/block/block.h
ae23c9
@@ -54,8 +54,12 @@ typedef enum {
ae23c9
     BDRV_REQ_FUA                = 0x10,
ae23c9
     BDRV_REQ_WRITE_COMPRESSED   = 0x20,
ae23c9
 
ae23c9
+    /* Signifies that this write request will not change the visible disk
ae23c9
+     * content. */
ae23c9
+    BDRV_REQ_WRITE_UNCHANGED    = 0x40,
ae23c9
+
ae23c9
     /* Mask of valid flags */
ae23c9
-    BDRV_REQ_MASK               = 0x3f,
ae23c9
+    BDRV_REQ_MASK               = 0x7f,
ae23c9
 } BdrvRequestFlags;
ae23c9
 
ae23c9
 typedef struct BlockSizes {
ae23c9
-- 
ae23c9
1.8.3.1
ae23c9