yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-block-Move-request-tracking-to-children-in-copy-offl.patch

ae23c9
From 49b0a4709b289f28c97633d8b3145213df1d8fc1 Mon Sep 17 00:00:00 2001
ae23c9
From: John Snow <jsnow@redhat.com>
ae23c9
Date: Tue, 24 Jul 2018 12:43:07 +0200
ae23c9
Subject: [PATCH 231/268] block: Move request tracking to children in copy
ae23c9
 offloading
ae23c9
ae23c9
RH-Author: John Snow <jsnow@redhat.com>
ae23c9
Message-id: <20180718225511.14878-14-jsnow@redhat.com>
ae23c9
Patchwork-id: 81393
ae23c9
O-Subject: [RHEL-7.6 qemu-kvm-rhev PATCH 13/35] block: Move request tracking to children in copy offloading
ae23c9
Bugzilla: 1207657
ae23c9
RH-Acked-by: Eric Blake <eblake@redhat.com>
ae23c9
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
ae23c9
RH-Acked-by: Fam Zheng <famz@redhat.com>
ae23c9
ae23c9
From: Fam Zheng <famz@redhat.com>
ae23c9
ae23c9
in_flight and tracked requests need to be tracked in every layer during
ae23c9
recursion. For now the only user is qemu-img convert where overlapping
ae23c9
requests and IOThreads don't exist, therefore this change doesn't make
ae23c9
much difference form user point of view, but it is incorrect as part of
ae23c9
the API. Fix it.
ae23c9
ae23c9
Reported-by: Kevin Wolf <kwolf@redhat.com>
ae23c9
Signed-off-by: Fam Zheng <famz@redhat.com>
ae23c9
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
ae23c9
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
ae23c9
(cherry picked from commit 37aec7d75eb0d035a0db4f2cf9ad8b1b0c10f91b)
ae23c9
Signed-off-by: John Snow <jsnow@redhat.com>
ae23c9
---
ae23c9
 block/io.c | 60 +++++++++++++++++++++++++++++-------------------------------
ae23c9
 1 file changed, 29 insertions(+), 31 deletions(-)
ae23c9
ae23c9
diff --git a/block/io.c b/block/io.c
ae23c9
index ac36d1c..136a5d0 100644
ae23c9
--- a/block/io.c
ae23c9
+++ b/block/io.c
ae23c9
@@ -2847,6 +2847,9 @@ static int coroutine_fn bdrv_co_copy_range_internal(BdrvChild *src,
ae23c9
                                                     BdrvRequestFlags flags,
ae23c9
                                                     bool recurse_src)
ae23c9
 {
ae23c9
+    BdrvTrackedRequest src_req, dst_req;
ae23c9
+    BlockDriverState *src_bs = src->bs;
ae23c9
+    BlockDriverState *dst_bs = dst->bs;
ae23c9
     int ret;
ae23c9
 
ae23c9
     if (!src || !dst || !src->bs || !dst->bs) {
ae23c9
@@ -2870,17 +2873,32 @@ static int coroutine_fn bdrv_co_copy_range_internal(BdrvChild *src,
ae23c9
         || src->bs->encrypted || dst->bs->encrypted) {
ae23c9
         return -ENOTSUP;
ae23c9
     }
ae23c9
+
ae23c9
+    bdrv_inc_in_flight(src_bs);
ae23c9
+    bdrv_inc_in_flight(dst_bs);
ae23c9
+    tracked_request_begin(&src_req, src_bs, src_offset,
ae23c9
+                          bytes, BDRV_TRACKED_READ);
ae23c9
+    tracked_request_begin(&dst_req, dst_bs, dst_offset,
ae23c9
+                          bytes, BDRV_TRACKED_WRITE);
ae23c9
+
ae23c9
+    wait_serialising_requests(&src_req);
ae23c9
+    wait_serialising_requests(&dst_req);
ae23c9
     if (recurse_src) {
ae23c9
-        return src->bs->drv->bdrv_co_copy_range_from(src->bs,
ae23c9
-                                                     src, src_offset,
ae23c9
-                                                     dst, dst_offset,
ae23c9
-                                                     bytes, flags);
ae23c9
+        ret = src->bs->drv->bdrv_co_copy_range_from(src->bs,
ae23c9
+                                                    src, src_offset,
ae23c9
+                                                    dst, dst_offset,
ae23c9
+                                                    bytes, flags);
ae23c9
     } else {
ae23c9
-        return dst->bs->drv->bdrv_co_copy_range_to(dst->bs,
ae23c9
-                                                   src, src_offset,
ae23c9
-                                                   dst, dst_offset,
ae23c9
-                                                   bytes, flags);
ae23c9
+        ret = dst->bs->drv->bdrv_co_copy_range_to(dst->bs,
ae23c9
+                                                  src, src_offset,
ae23c9
+                                                  dst, dst_offset,
ae23c9
+                                                  bytes, flags);
ae23c9
     }
ae23c9
+    tracked_request_end(&src_req);
ae23c9
+    tracked_request_end(&dst_req);
ae23c9
+    bdrv_dec_in_flight(src_bs);
ae23c9
+    bdrv_dec_in_flight(dst_bs);
ae23c9
+    return ret;
ae23c9
 }
ae23c9
 
ae23c9
 /* Copy range from @src to @dst.
ae23c9
@@ -2911,29 +2929,9 @@ int coroutine_fn bdrv_co_copy_range(BdrvChild *src, uint64_t src_offset,
ae23c9
                                     BdrvChild *dst, uint64_t dst_offset,
ae23c9
                                     uint64_t bytes, BdrvRequestFlags flags)
ae23c9
 {
ae23c9
-    BdrvTrackedRequest src_req, dst_req;
ae23c9
-    BlockDriverState *src_bs = src->bs;
ae23c9
-    BlockDriverState *dst_bs = dst->bs;
ae23c9
-    int ret;
ae23c9
-
ae23c9
-    bdrv_inc_in_flight(src_bs);
ae23c9
-    bdrv_inc_in_flight(dst_bs);
ae23c9
-    tracked_request_begin(&src_req, src_bs, src_offset,
ae23c9
-                          bytes, BDRV_TRACKED_READ);
ae23c9
-    tracked_request_begin(&dst_req, dst_bs, dst_offset,
ae23c9
-                          bytes, BDRV_TRACKED_WRITE);
ae23c9
-
ae23c9
-    wait_serialising_requests(&src_req);
ae23c9
-    wait_serialising_requests(&dst_req);
ae23c9
-    ret = bdrv_co_copy_range_from(src, src_offset,
ae23c9
-                                  dst, dst_offset,
ae23c9
-                                  bytes, flags);
ae23c9
-
ae23c9
-    tracked_request_end(&src_req);
ae23c9
-    tracked_request_end(&dst_req);
ae23c9
-    bdrv_dec_in_flight(src_bs);
ae23c9
-    bdrv_dec_in_flight(dst_bs);
ae23c9
-    return ret;
ae23c9
+    return bdrv_co_copy_range_from(src, src_offset,
ae23c9
+                                   dst, dst_offset,
ae23c9
+                                   bytes, flags);
ae23c9
 }
ae23c9
 
ae23c9
 static void bdrv_parent_cb_resize(BlockDriverState *bs)
ae23c9
-- 
ae23c9
1.8.3.1
ae23c9