yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
ae23c9
From 3995a70bd22fb0d3d7fe8edb692d2c03794a779f Mon Sep 17 00:00:00 2001
ae23c9
From: Fam Zheng <famz@redhat.com>
ae23c9
Date: Fri, 29 Jun 2018 06:11:43 +0200
ae23c9
Subject: [PATCH 169/268] raw: Implement copy offloading
ae23c9
ae23c9
RH-Author: Fam Zheng <famz@redhat.com>
ae23c9
Message-id: <20180629061153.12687-4-famz@redhat.com>
ae23c9
Patchwork-id: 81155
ae23c9
O-Subject: [RHEL-7.6 qemu-kvm-rhev PATCH v2 03/13] raw: Implement copy offloading
ae23c9
Bugzilla: 1482537
ae23c9
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
ae23c9
RH-Acked-by: Max Reitz <mreitz@redhat.com>
ae23c9
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
ae23c9
ae23c9
Just pass down to ->file.
ae23c9
ae23c9
Signed-off-by: Fam Zheng <famz@redhat.com>
ae23c9
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
ae23c9
Message-id: 20180601092648.24614-4-famz@redhat.com
ae23c9
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
ae23c9
(cherry picked from commit 72d219e2f916adeec9845473d239571a267f3314)
ae23c9
Signed-off-by: Fam Zheng <famz@redhat.com>
ae23c9
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
ae23c9
---
ae23c9
 block/raw-format.c | 32 ++++++++++++++++++++++++++++++++
ae23c9
 1 file changed, 32 insertions(+)
ae23c9
ae23c9
diff --git a/block/raw-format.c b/block/raw-format.c
ae23c9
index b69a067..f2e468d 100644
ae23c9
--- a/block/raw-format.c
ae23c9
+++ b/block/raw-format.c
ae23c9
@@ -497,6 +497,36 @@ static int raw_probe_geometry(BlockDriverState *bs, HDGeometry *geo)
ae23c9
     return bdrv_probe_geometry(bs->file->bs, geo);
ae23c9
 }
ae23c9
 
ae23c9
+static int coroutine_fn raw_co_copy_range_from(BlockDriverState *bs,
ae23c9
+                                               BdrvChild *src, uint64_t src_offset,
ae23c9
+                                               BdrvChild *dst, uint64_t dst_offset,
ae23c9
+                                               uint64_t bytes, BdrvRequestFlags flags)
ae23c9
+{
ae23c9
+    int ret;
ae23c9
+
ae23c9
+    ret = raw_adjust_offset(bs, &src_offset, bytes, false);
ae23c9
+    if (ret) {
ae23c9
+        return ret;
ae23c9
+    }
ae23c9
+    return bdrv_co_copy_range_from(bs->file, src_offset, dst, dst_offset,
ae23c9
+                                   bytes, flags);
ae23c9
+}
ae23c9
+
ae23c9
+static int coroutine_fn raw_co_copy_range_to(BlockDriverState *bs,
ae23c9
+                                             BdrvChild *src, uint64_t src_offset,
ae23c9
+                                             BdrvChild *dst, uint64_t dst_offset,
ae23c9
+                                             uint64_t bytes, BdrvRequestFlags flags)
ae23c9
+{
ae23c9
+    int ret;
ae23c9
+
ae23c9
+    ret = raw_adjust_offset(bs, &dst_offset, bytes, true);
ae23c9
+    if (ret) {
ae23c9
+        return ret;
ae23c9
+    }
ae23c9
+    return bdrv_co_copy_range_to(src, src_offset, bs->file, dst_offset, bytes,
ae23c9
+                                 flags);
ae23c9
+}
ae23c9
+
ae23c9
 BlockDriver bdrv_raw = {
ae23c9
     .format_name          = "raw",
ae23c9
     .instance_size        = sizeof(BDRVRawState),
ae23c9
@@ -513,6 +543,8 @@ BlockDriver bdrv_raw = {
ae23c9
     .bdrv_co_pwrite_zeroes = &raw_co_pwrite_zeroes,
ae23c9
     .bdrv_co_pdiscard     = &raw_co_pdiscard,
ae23c9
     .bdrv_co_block_status = &raw_co_block_status,
ae23c9
+    .bdrv_co_copy_range_from = &raw_co_copy_range_from,
ae23c9
+    .bdrv_co_copy_range_to  = &raw_co_copy_range_to,
ae23c9
     .bdrv_truncate        = &raw_truncate,
ae23c9
     .bdrv_getlength       = &raw_getlength,
ae23c9
     .has_variable_length  = true,
ae23c9
-- 
ae23c9
1.8.3.1
ae23c9