From: Fam Zheng <famz@redhat.com>
To: qemu-devel@nongnu.org
Cc: qemu-block@nongnu.org, Fam Zheng <famz@redhat.com>,
Kevin Wolf <kwolf@redhat.com>, Max Reitz <mreitz@redhat.com>,
Jeff Cody <jcody@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>
Subject: [Qemu-devel] [PATCH 5/6] block: Add backing passthrough implementations for copy_range
Date: Fri, 8 Jun 2018 14:04:16 +0800 [thread overview]
Message-ID: <20180608060417.10170-6-famz@redhat.com> (raw)
In-Reply-To: <20180608060417.10170-1-famz@redhat.com>
Similar to bdrv_co_block_status_from_backing we add the two passthrough
callbacks for copy_range. This will be used by the block driver filters
so that they can support copy offloading.
Signed-off-by: Fam Zheng <famz@redhat.com>
---
block/io.c | 24 ++++++++++++++++++++++++
include/block/block_int.h | 22 ++++++++++++++++++++++
2 files changed, 46 insertions(+)
diff --git a/block/io.c b/block/io.c
index d8039793c2..d1559c9cd5 100644
--- a/block/io.c
+++ b/block/io.c
@@ -1900,6 +1900,30 @@ int coroutine_fn bdrv_co_block_status_from_backing(BlockDriverState *bs,
return BDRV_BLOCK_RAW | BDRV_BLOCK_OFFSET_VALID;
}
+int coroutine_fn bdrv_co_copy_range_from_backing(BlockDriverState *bs,
+ BdrvChild *src, uint64_t src_offset,
+ BdrvChild *dst, uint64_t dst_offset,
+ uint64_t bytes, BdrvRequestFlags flags)
+{
+ if (!src->bs) {
+ return -ENOMEDIUM;
+ }
+ return bdrv_co_copy_range_from(src->bs->backing, src_offset, dst,
+ dst_offset, bytes, flags);
+}
+
+int coroutine_fn bdrv_co_copy_range_to_backing(BlockDriverState *bs,
+ BdrvChild *src, uint64_t src_offset,
+ BdrvChild *dst, uint64_t dst_offset,
+ uint64_t bytes, BdrvRequestFlags flags)
+{
+ if (!dst->bs) {
+ return -ENOMEDIUM;
+ }
+ return bdrv_co_copy_range_to(src, src_offset, dst->bs->backing,
+ dst_offset, bytes, flags);
+}
+
/*
* Returns the allocation status of the specified sectors.
* Drivers not implementing the functionality are assumed to not support
diff --git a/include/block/block_int.h b/include/block/block_int.h
index 2c51cd420f..b488d74c1b 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -1118,6 +1118,28 @@ int coroutine_fn bdrv_co_block_status_from_backing(BlockDriverState *bs,
int64_t *pnum,
int64_t *map,
BlockDriverState **file);
+
+/*
+ * Default implementation for drivers to pass bdrv_co_copy_range_from() to
+ * their backing file.
+ */
+int coroutine_fn bdrv_co_copy_range_from_backing(BlockDriverState *bs,
+ BdrvChild *src, uint64_t src_offset,
+ BdrvChild *dst, uint64_t dst_offset,
+ uint64_t bytes,
+ BdrvRequestFlags flags);
+
+
+/*
+ * Default implementation for drivers to pass bdrv_co_copy_range_to() to their
+ * backing file.
+ */
+int coroutine_fn bdrv_co_copy_range_to_backing(BlockDriverState *bs,
+ BdrvChild *src, uint64_t src_offset,
+ BdrvChild *dst, uint64_t dst_offset,
+ uint64_t bytes,
+ BdrvRequestFlags flags);
+
const char *bdrv_get_parent_name(const BlockDriverState *bs);
void blk_dev_change_media_cb(BlockBackend *blk, bool load, Error **errp);
bool blk_dev_has_removable_media(BlockBackend *blk);
--
2.17.0
next prev parent reply other threads:[~2018-06-08 6:05 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-08 6:04 [Qemu-devel] [PATCH 0/6] mirror: Use copy offloading Fam Zheng
2018-06-08 6:04 ` [Qemu-devel] [PATCH 1/6] file-posix: Fix EINTR handling Fam Zheng
2018-06-15 14:38 ` Stefan Hajnoczi
2018-06-08 6:04 ` [Qemu-devel] [PATCH 2/6] block: Check if block drivers can do copy offloading Fam Zheng
2018-06-15 15:00 ` Stefan Hajnoczi
2018-06-08 6:04 ` [Qemu-devel] [PATCH 3/6] block-backend: Refactor AIO emulation Fam Zheng
2018-06-15 15:21 ` Stefan Hajnoczi
2018-06-08 6:04 ` [Qemu-devel] [PATCH 4/6] block-backend: Add blk_aio_copy_range Fam Zheng
2018-06-15 15:26 ` Stefan Hajnoczi
2018-06-08 6:04 ` Fam Zheng [this message]
2018-06-15 15:30 ` [Qemu-devel] [PATCH 5/6] block: Add backing passthrough implementations for copy_range Stefan Hajnoczi
2018-06-08 6:04 ` [Qemu-devel] [PATCH 6/6] mirror: Use copy offloading Fam Zheng
2018-06-15 16:23 ` Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180608060417.10170-6-famz@redhat.com \
--to=famz@redhat.com \
--cc=jcody@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).