[Qemu-devel] [PATCH v3 2/9] raw: Implement copy offloading

Fam Zheng posted 9 patches 7 years, 5 months ago
There is a newer version of this series
[Qemu-devel] [PATCH v3 2/9] raw: Implement copy offloading
Posted by Fam Zheng 7 years, 5 months ago
Just pass down to ->file.

Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 block/raw-format.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/block/raw-format.c b/block/raw-format.c
index a378547c99..febddf00c0 100644
--- a/block/raw-format.c
+++ b/block/raw-format.c
@@ -482,6 +482,24 @@ static int raw_probe_geometry(BlockDriverState *bs, HDGeometry *geo)
     return bdrv_probe_geometry(bs->file->bs, geo);
 }
 
+static int coroutine_fn raw_co_copy_range_from(BlockDriverState *bs,
+                                               BdrvChild *src, uint64_t src_offset,
+                                               BdrvChild *dst, uint64_t dst_offset,
+                                               uint64_t bytes, BdrvRequestFlags flags)
+{
+    return bdrv_co_copy_range_from(bs->file, src_offset, dst, dst_offset,
+                                   bytes, flags);
+}
+
+static int coroutine_fn raw_co_copy_range_to(BlockDriverState *bs,
+                                             BdrvChild *src, uint64_t src_offset,
+                                             BdrvChild *dst, uint64_t dst_offset,
+                                             uint64_t bytes, BdrvRequestFlags flags)
+{
+    return bdrv_co_copy_range_to(src, src_offset, bs->file, dst_offset, bytes,
+                                 flags);
+}
+
 BlockDriver bdrv_raw = {
     .format_name          = "raw",
     .instance_size        = sizeof(BDRVRawState),
@@ -498,6 +516,8 @@ BlockDriver bdrv_raw = {
     .bdrv_co_pwrite_zeroes = &raw_co_pwrite_zeroes,
     .bdrv_co_pdiscard     = &raw_co_pdiscard,
     .bdrv_co_block_status = &raw_co_block_status,
+    .bdrv_co_copy_range_from = &raw_co_copy_range_from,
+    .bdrv_co_copy_range_to  = &raw_co_copy_range_to,
     .bdrv_truncate        = &raw_truncate,
     .bdrv_getlength       = &raw_getlength,
     .has_variable_length  = true,
-- 
2.14.3


Re: [Qemu-devel] [PATCH v3 2/9] raw: Implement copy offloading
Posted by Eric Blake 7 years, 5 months ago
On 05/09/2018 09:58 AM, Fam Zheng wrote:
> Just pass down to ->file.
> 
> Signed-off-by: Fam Zheng <famz@redhat.com>
> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
>   block/raw-format.c | 20 ++++++++++++++++++++
>   1 file changed, 20 insertions(+)
> 
> diff --git a/block/raw-format.c b/block/raw-format.c
> index a378547c99..febddf00c0 100644
> --- a/block/raw-format.c
> +++ b/block/raw-format.c
> @@ -482,6 +482,24 @@ static int raw_probe_geometry(BlockDriverState *bs, HDGeometry *geo)
>       return bdrv_probe_geometry(bs->file->bs, geo);
>   }
>   
> +static int coroutine_fn raw_co_copy_range_from(BlockDriverState *bs,
> +                                               BdrvChild *src, uint64_t src_offset,
> +                                               BdrvChild *dst, uint64_t dst_offset,
> +                                               uint64_t bytes, BdrvRequestFlags flags)
> +{
> +    return bdrv_co_copy_range_from(bs->file, src_offset, dst, dst_offset,
> +                                   bytes, flags);

Bug - this fails to take into account s->offset, which occurs when 
opening a raw format protocol over a subset of the overall format protocol.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

Re: [Qemu-devel] [PATCH v3 2/9] raw: Implement copy offloading
Posted by Fam Zheng 7 years, 5 months ago
On Wed, 05/09 10:17, Eric Blake wrote:
> On 05/09/2018 09:58 AM, Fam Zheng wrote:
> > Just pass down to ->file.
> > 
> > Signed-off-by: Fam Zheng <famz@redhat.com>
> > Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
> > ---
> >   block/raw-format.c | 20 ++++++++++++++++++++
> >   1 file changed, 20 insertions(+)
> > 
> > diff --git a/block/raw-format.c b/block/raw-format.c
> > index a378547c99..febddf00c0 100644
> > --- a/block/raw-format.c
> > +++ b/block/raw-format.c
> > @@ -482,6 +482,24 @@ static int raw_probe_geometry(BlockDriverState *bs, HDGeometry *geo)
> >       return bdrv_probe_geometry(bs->file->bs, geo);
> >   }
> > +static int coroutine_fn raw_co_copy_range_from(BlockDriverState *bs,
> > +                                               BdrvChild *src, uint64_t src_offset,
> > +                                               BdrvChild *dst, uint64_t dst_offset,
> > +                                               uint64_t bytes, BdrvRequestFlags flags)
> > +{
> > +    return bdrv_co_copy_range_from(bs->file, src_offset, dst, dst_offset,
> > +                                   bytes, flags);
> 
> Bug - this fails to take into account s->offset, which occurs when opening a
> raw format protocol over a subset of the overall format protocol.

Good catch. I'll fix it in v4. Thanks.

Fam